- Updated the handle_query function to include explicit instructions preventing internal prompt text from appearing in user-facing responses.
- Modified the blend_prompt within handle_query to ensure the model synthesizes answers without echoing prompts or instructions.
- Enhanced the AnswerExpander class's expand method to encourage concise responses by setting a limit of 4 sentences when detail=False.
- Added clear separators and labels in prompts to guide the model in structuring responses effectively.
- Enabled public link creation by setting `share=True` in Gradio's launch method.
- Maintained existing functionalities such as caching, retrieval, and web search integrations.
- Improved logging for better debugging and transparency in prompt and response handling.
IMMEDIATE HISTORY WAS WORKING FINE
fix: Correct handle_query prompts to use plain text and prevent internal instructions in user responses
- Updated the handle_query function to construct prompts as plain text strings without using dictionaries.
- Refined prompt instructions to ensure internal instructions are not included in user-facing answers.
- Removed any conversational preambles that could be echoed back by the LLM.
- Ensured that the GeminiLLM class remains unchanged and sends prompts as strings.
- Enabled public link creation by setting `share=True` in Gradio's launch method.
- Enhanced logging to aid in debugging prompt and response handling.
fix: Refine handle_query prompts to exclude internal instructions from user responses 1
- Updated the handle_query function to remove conversational preambles that were being included in user-facing answers.
- Added explicit instructions within prompts to prevent the model from echoing back any part of the prompt.
- Structured prompts clearly with separators and labels to guide the model in generating clean, relevant responses.
- Ensured that only the synthesized and enhanced answers are presented to the user without any internal prompt text.
last working 1e7a57d99fc7d6862f193e11598041bc6e68fb7a
fix: Remove internal prompt instructions from user-facing responses
- Updated prompt constructions in `handle_query` and `AnswerExpander` to use direct instructions without conversational preambles.
- Modified `GeminiLLM` class to utilize system and user roles, ensuring internal instructions are not echoed back to users.
- Ensured that all responses returned to users are free from embedded prompt instructions.
- Enhanced prompt clarity for better content generation and user experience.
- Maintained existing functionalities such as caching, retrieval, and web search integrations.
Caching (Persistent Storage)
A new JSON-based cache (query_cache.json) is loaded at startup and saved upon new queries.
Before doing any retrieval or calls to the LLM, we check if a similar query (by cosine similarity of embeddings) is in the cache.
If the similarity is above SIMILARITY_THRESHOLD_CACHE, we return that cached answer immediately (“cache hit”).
Otherwise, we proceed as before and store the new answer to the cache for future fast retrieval.
Detail Control
Added a detail parameter to handle_query() and expand() that modifies the prompt.
In the Gradio UI, a checkbox toggles “In-Depth Answer?” for a more detailed response.
Performance Improvements
Short-circuit queries with high cache similarity to avoid embedding/cross-encoder re-computation and LLM calls.
The rest of the logic is unchanged, so you still get the same retrieval flow and expansions if not served from the cache.