SAVE TOKENS #19
Conversation
Co-authored-by: Aditya <91722397+AdityaKodez@users.noreply.github.com>
…8d279 Improve stock market query detection and response quality
Summary by BeetleThis PR refines the AI assistant's system prompt architecture and introduces intelligent tool registration to reduce token overhead. The changes consolidate verbose system instructions into a denser format (~50% reduction), implement heuristic-based tool loading (stock tool only registered when queries contain financial keywords), and cap conversation history at 10 prior messages to prevent unbounded token growth. Additionally, four persona files are streamlined to match the new concise prompt style, removing redundant safety boundaries already covered in the base system prompt. 📁 File Changes Summary (Consolidated across all commits):
Total Changes: 5 files changed, +113 additions, -274 deletions 🗺️ Walkthroughgraph TD
A["User sends message"] --> B{"Contains images?"}
B -->|Yes| C["Route to VISION_MODEL"]
B -->|No| D["Use user's selected model"]
C --> E["buildSystemPrompt()"]
D --> E
E --> F{"Session has stored images?"}
F -->|Yes| G["Add getImage tool instructions"]
F -->|No| H["Skip image tool instructions"]
G --> I["buildActiveTools()"]
H --> I
I --> J{"Query matches STOCK_QUERY_PATTERN?"}
J -->|Yes| K["Register: search + stock + getImage*"]
J -->|No| L["Register: search + getImage*"]
K --> M["generateText() with dynamic tools"]
L --> M
M --> N["buildConversation()"]
N --> O["Cap history at MAX_HISTORY=10"]
O --> P["Return response"]
style E fill:#e1f5ff
style I fill:#fff4e1
style J fill:#ffe1e1
style O fill:#e1ffe1
🎯 Key Changes
📊 Impact Assessment
⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
✅ You're good to merge this PR! No issues found. Great job! Settings⚙️ SettingsSeverity Threshold: 📖 User Guide
|
|
great |
No description provided.