Add advanced-rag module: Easy RAG, query compression and expansion, routing, minScore, content injection, chat-memory cost and sources, each with a captured transcript

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017ic4b85ApxQRK2Z8yuzC5r
This commit is contained in:
Claude
2026-11-17 00:59:39 +05:30
parent da39f6437a
commit ae8fe985b4
27 changed files with 1195 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
Rewriter LLM calls after turn 1: 0
Rewriter LLM calls after turn 2: 1
Prompt CompressingQueryTransformer sent to the rewriter on turn 2:
Read and understand the conversation between the User and the AI. Then, analyze the new query from the User. Identify all relevant details, terms, and context from both the conversation and the new query. Reformulate this query into a clear, concise, and self-contained format suitable for information retrieval.
Conversation:
User: What is the refund window for annual plans?
Answer using the following information:
Acme Cloud Refund Policy
Annual plans can be refunded in full within 30 days of purchase. Monthly plans can be refunded within 7 days of the first charge. After those windows, no refund is issued, but you can cancel at any time and keep access until the end of the paid period.
Once a refund is approved, it takes 5 to 10 business days to appear on your card statement. The time depends on your bank, not on Acme Cloud. Refunds always go back to the original payment method; we cannot pay them out to a different card.
If a refund does not show up after 10 business days, contact support with the invoice number so we can send you the acquirer reference number.
Acme Edge Box Hardware Returns
The Acme Edge Box can be returned within 45 days of delivery if it is in its original packaging. Request a return label from the support portal; the label is valid for 14 days.
After our warehouse receives the box, the refund is processed within 3 business days. It then follows the normal card timeline of 5 to 10 business days.
Boxes that arrive damaged or with missing power adapters are inspected first, which can add up to 5 business days.
Acme Cloud Deployments
A standard deployment takes about 4 minutes from push to live. The first 5 percent of traffic goes to the new version as a canary for 2 minutes before the rest is shifted.
A rollback takes about 30 seconds because the previous version stays warm for one hour after every deployment. After that hour, a rollback is a normal 4 minute deployment of the older build.
Deployments are blocked automatically when the error rate of the canary is more than 2 percent above the baseline.
AI: (scripted answer)
User query: How long does it take to show up?
It is very important that you provide only reformulated query and nothing else! Do not prepend a query with anything!
User message the answering LLM received on turn 2:
How long does it take to show up?
Answer using the following information:
Acme Cloud Refund Policy
Annual plans can be refunded in full within 30 days of purchase. Monthly plans can be refunded within 7 days of the first charge. After those windows, no refund is issued, but you can cancel at any time and keep access until the end of the paid period.
Once a refund is approved, it takes 5 to 10 business days to appear on your card statement. The time depends on your bank, not on Acme Cloud. Refunds always go back to the original payment method; we cannot pay them out to a different card.
If a refund does not show up after 10 business days, contact support with the invoice number so we can send you the acquirer reference number.
Acme Edge Box Hardware Returns
The Acme Edge Box can be returned within 45 days of delivery if it is in its original packaging. Request a return label from the support portal; the label is valid for 14 days.
After our warehouse receives the box, the refund is processed within 3 business days. It then follows the normal card timeline of 5 to 10 business days.
Boxes that arrive damaged or with missing power adapters are inspected first, which can add up to 5 business days.
Acme Cloud Deployments
A standard deployment takes about 4 minutes from push to live. The first 5 percent of traffic goes to the new version as a canary for 2 minutes before the rest is shifted.
A rollback takes about 30 seconds because the previous version stays warm for one hour after every deployment. After that hour, a rollback is a normal 4 minute deployment of the older build.
Deployments are blocked automatically when the error rate of the canary is more than 2 percent above the baseline.
Rewriter prompt size in characters, turn 2 / 3 / 4: 2256 / 3998 / 5748
With storeRetrievedContentInChatMemory(false), turn 2 / 3 / 4: 565 / 616 / 675
Prompt sent to the rewriter on turn 2 with storeRetrievedContentInChatMemory(false):
Read and understand the conversation between the User and the AI. Then, analyze the new query from the User. Identify all relevant details, terms, and context from both the conversation and the new query. Reformulate this query into a clear, concise, and self-contained format suitable for information retrieval.
Conversation:
User: What is the refund window for annual plans?
AI: (scripted answer)
User query: How long does it take to show up?
It is very important that you provide only reformulated query and nothing else! Do not prepend a query with anything!
User message the answering LLM still received on turn 4 (augmented: true)