feat : : implement session-based local caching to reduce redundant Su…#143
Open
Soniyakmt wants to merge 2 commits into
Open
feat : : implement session-based local caching to reduce redundant Su…#143Soniyakmt wants to merge 2 commits into
Soniyakmt wants to merge 2 commits into
Conversation
… output and prevent TTS regressions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #87
summary:
Added local response caching for GenAI to reduce repeated Sugar-AI requests and improve response speed for repeated questions.
What changed
I had made: Added [cache.py] with an LRU-style [ResponseCache]
and Updated [gguf_inference.py] to:
Use a session-level response cache
return cached answers for identical questions
store successful and blocked responses in the cache
Limit the cache size to avoid unbounded memory growth
Coverage: Caches both successful responses and blocked profanity responses.
Caching Logic: Normalises question text (lowercase, trimmed), uses SHA256 for keys, and limits cache size to prevent memory issues.
Updated: [gguf_inference.py] - Integrates caching into [GGUFInference.ask_question()] to check for cached responses before generating new ones.
Note
: Cache keys are normalised to ignore extra whitespace/casing
. If persistence is enabled via [cache_file], the cache can survive restarts