Handler function that receives JSON args from the LLM.
Now delegates to the RAGProvider if available.
Source code in wintermute/ai/utils/aws_rag.py
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 | def query_manuals_handler(args: JSONObject) -> JSONObject:
"""Handler function that receives JSON args from the LLM.
Now delegates to the RAGProvider if available."""
query_text = args.get("query")
if not query_text or not isinstance(query_text, str):
return {"error": "No query provided"}
# Attempt to find the default RAG provider (e.g. from the bootstrapped ones)
rag_provider = None
for p_name in llms.providers():
if p_name.startswith("rag-"):
rag_provider = llms.get(p_name)
break
if not rag_provider:
return {
"error": "No RAG provider found. Ensure knowledge bases are bootstrapped."
}
try:
req = ChatRequest(messages=[Message(role="user", content=query_text)])
response = rag_provider.chat(req)
return {"result": response.content}
except Exception as e:
log.error(f"Error in query_manuals_handler: {e}")
return {"error": str(e)}
|