LangChain-POC / tools /BookRetriverRagAgent.py
VIRTUS
refactor: change book retriver agent OO to just a func, AI model change, system_propts and descriptions also changed
9b09327
raw
history blame contribute delete
640 Bytes
from langchain.tools import tool
def get_retrieve_book_context_rag_agent_tool(agent):
@tool(
"Computer science knowledge retriever",
description="Used to retrieve computer science related context and answer the request."
)
def retrieve_book_context_rag_agent(query: str) -> str:
"""Delegate the retrieve query context to the agent.
Args:
query: the full query of th user
"""
result = agent.invoke({
"messages": [{"role": "user", "content": query}]
})
return result["messages"][-1].text
return retrieve_book_context_rag_agent