- Extract LLM generation into `execute_llm_generation` and simplify keyword handling. - Prepend system prompt and session context to LLM prompts in `BotOrchestrator`. - Parse incoming WebSocket messages as JSON and use the `content` field. - Add async `get_session_context` and stop injecting Redis context into conversation history. - Change default LLM URL to `http://48.217.66.81:8080` throughout the project. - Use the existing DB pool instead of creating a separate custom connection. - Update `start.bas` to call LLM and set a new context string. - Refactor web client message handling: separate event processing, improve streaming logic, reset streaming state on thinking end, and remove unused test functions.
93 lines
2.2 KiB
Bash
Executable file
93 lines
2.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$SCRIPT_DIR"
|
|
OUTPUT_FILE="$SCRIPT_DIR/prompt.out"
|
|
|
|
rm -f "$OUTPUT_FILE"
|
|
echo "Consolidated LLM Context" > "$OUTPUT_FILE"
|
|
|
|
prompts=(
|
|
"./prompts/dev/shared.md"
|
|
"./Cargo.toml"
|
|
"./prompts/dev/generation.md"
|
|
)
|
|
|
|
for file in "${prompts[@]}"; do
|
|
if [ -f "$file" ]; then
|
|
cat "$file" >> "$OUTPUT_FILE"
|
|
echo "" >> "$OUTPUT_FILE"
|
|
fi
|
|
done
|
|
|
|
dirs=(
|
|
#"auth"
|
|
#"automation"
|
|
#"basic"
|
|
"bot"
|
|
#"channels"
|
|
#"config"
|
|
#"context"
|
|
#"email"
|
|
#"file"
|
|
#"llm"
|
|
#"llm_legacy"
|
|
#"org"
|
|
"session"
|
|
"shared"
|
|
#"tests"
|
|
#"tools"
|
|
#"web_automation"
|
|
#"whatsapp"
|
|
)
|
|
|
|
filter_rust_file() {
|
|
sed -E '/^\s*\/\//d' "$1" | \
|
|
sed -E '/info!\s*\(/d' | \
|
|
sed -E '/debug!\s*\(/d' | \
|
|
sed -E '/trace!\s*\(/d'
|
|
}
|
|
|
|
for dir in "${dirs[@]}"; do
|
|
find "$PROJECT_ROOT/src/$dir" -name "*.rs" | while read -r file; do
|
|
echo "$file" >> "$OUTPUT_FILE"
|
|
filter_rust_file "$file" >> "$OUTPUT_FILE"
|
|
echo "" >> "$OUTPUT_FILE"
|
|
done
|
|
done
|
|
|
|
# Additional specific files
|
|
files=(
|
|
"$PROJECT_ROOT/src/main.rs"
|
|
"$PROJECT_ROOT/src/basic/keywords/hear_talk.rs"
|
|
"$PROJECT_ROOT/templates/annoucements.gbai/annoucements.gbdialog/start.bas"
|
|
"$PROJECT_ROOT/templates/annoucements.gbai/annoucements.gbdialog/auth.bas"
|
|
)
|
|
|
|
for file in "${files[@]}"; do
|
|
if [[ "$file" == *.rs ]]; then
|
|
echo "$file" >> "$OUTPUT_FILE"
|
|
filter_rust_file "$file" >> "$OUTPUT_FILE"
|
|
else
|
|
echo "$file" >> "$OUTPUT_FILE"
|
|
cat "$file" >> "$OUTPUT_FILE"
|
|
fi
|
|
done
|
|
|
|
# Remove all blank lines and reduce whitespace greater than 1 space
|
|
sed -i 's/[[:space:]]*$//' "$OUTPUT_FILE"
|
|
sed -i '/^$/d' "$OUTPUT_FILE"
|
|
sed -i 's/ \+/ /g' "$OUTPUT_FILE"
|
|
|
|
# Calculate and display token count (approximation: words * 1.3)
|
|
WORD_COUNT=$(wc -w < "$OUTPUT_FILE")
|
|
TOKEN_COUNT=$(echo "$WORD_COUNT * 1.3 / 1" | bc)
|
|
FILE_SIZE=$(wc -c < "$OUTPUT_FILE")
|
|
|
|
echo "" >> "$OUTPUT_FILE"
|
|
|
|
echo "Approximate token count: $TOKEN_COUNT"
|
|
echo "Context size: $FILE_SIZE bytes"
|
|
|
|
cat "$OUTPUT_FILE" | xclip -selection clipboard
|
|
echo "Content copied to clipboard (xclip)"
|