New web interface, move llm engine to separate process
This commit is contained in:
91
llm_config.toml
Normal file
91
llm_config.toml
Normal file
@@ -0,0 +1,91 @@
|
||||
gemma = """/root/venvs/gemma_infer/bin/gemma_infer --model /root/models/gemma3_1b.gguf --tokenizer /root/models/gemma3_1b_tokenizer"""
|
||||
#mistral = """/root/venvs/mistral_infer/bin/mistral_infer"""
|
||||
default = """#!/bin/bash
|
||||
|
||||
# Mock LLM engine for testing
|
||||
# This script simulates an LLM engine subprocess that responds to the three commands:
|
||||
# <token_limit/>, <token_count>...</token_count>, and <infer_xml>...</infer_xml>
|
||||
|
||||
# Function to read XML input until a complete closing tag is found
|
||||
read_xml_input() {
|
||||
local input=""
|
||||
local line
|
||||
local char_count=0
|
||||
|
||||
# Read until we get a complete XML command
|
||||
while IFS= read -r line; do
|
||||
input="${input}${line}"
|
||||
char_count=$((char_count + ${#line}))
|
||||
|
||||
# Debug the actual content (first 30 chars)
|
||||
|
||||
if [[ "$input" == *"<token_limit/>"* ]]; then
|
||||
printf "1024"
|
||||
printf "\\004" # EOT character (hex 04)
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$input" == *"<token_count>"*"</token_count>"* ]]; then
|
||||
printf "405"
|
||||
printf "\\004" # EOT character (hex 04)
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$input" == *"<infer_xml>"*"</infer_xml>"* ]]; then
|
||||
generate_response
|
||||
return
|
||||
fi
|
||||
|
||||
done
|
||||
}
|
||||
|
||||
# Function to generate a response token by token
|
||||
generate_response() {
|
||||
printf "<"
|
||||
sleep 0.3
|
||||
|
||||
printf "reason"
|
||||
sleep 0.3
|
||||
|
||||
printf "ing"
|
||||
sleep 0.3
|
||||
|
||||
printf ">"
|
||||
sleep 0.3
|
||||
|
||||
printf "This"
|
||||
sleep 0.3
|
||||
|
||||
printf " is"
|
||||
sleep 0.3
|
||||
|
||||
printf " a"
|
||||
sleep 0.3
|
||||
|
||||
printf " test"
|
||||
sleep 0.3
|
||||
|
||||
printf " response."
|
||||
sleep 0.3
|
||||
|
||||
printf "</"
|
||||
sleep 0.3
|
||||
|
||||
printf "reason"
|
||||
sleep 0.3
|
||||
|
||||
printf "ing"
|
||||
sleep 0.3
|
||||
|
||||
printf ">"
|
||||
sleep 0.3
|
||||
|
||||
printf "\\004"
|
||||
}
|
||||
|
||||
# Main loop - keep reading input and responding
|
||||
iteration=0
|
||||
while true; do
|
||||
iteration=$((iteration + 1))
|
||||
read_xml_input
|
||||
done"""
|
||||
Reference in New Issue
Block a user