Use the semantic cache for repeat questions
Turn on the semantic answer cache, verify an answer with a thumbs-up, and watch a reworded question get answered without a model call.
After reading this page you will be able to:
- Enable the cache for a tenant
- Create a verified entry
- Confirm a cache hit and purge it
Beginner15 minService deskDockerTeams
Prerequisites
- A running Liyagent instance where Liya answers questions (a model is configured).
Steps
- Turn the cache on.
curl -b cookies.txt -X PUT http://127.0.0.1:8787/api/semantic-cache \ -H "Content-Type: application/json" -d '{"enabled": true, "threshold": 0.95, "ttl_s": 604800}' - Ask Liya (web chat or Teams):
How do I reset my VPN token? - Give the answer a thumbs-up. It is now a verified entry:
GET /api/semantic-cache/entries. - Ask it differently:
What's the way to reset the token for VPN?The answer arrives immediately. The usage row shows no model tokens. - Give that answer a thumbs-down. The entry is dropped at once, and the next ask goes to the model.
- Purge everything when done:
POST /api/semantic-cache/purgewith the body{}.
Note
An entry is only served if your own retrieval returns every source the answer used, with the same content. Change a source article and the cache steps aside.