How to make tools store custom variables in Agent's state when using create_deep_agent()?
#2649
Unanswered
Sai Akhilesh Ande (akhil189)
asked this question in
Q&A
Replies: 1 comment
|
Tools in a Here is the minimal pattern for your case: from typing import Annotated, List
from langgraph.graph import add_messages
from langchain_core.documents import Document
import operator
class AgentState(TypedDict):
messages: Annotated[list, add_messages]
retrieved_context: Annotated[List[Document], operator.add]
sql_query: str
@tool
def retriever_tool(query: str, state: AgentState) -> dict:
docs = vectorstore.similarity_search(query)
return {"retrieved_context": docs}
@tool
def sql_tool(question: str, state: AgentState) -> dict:
query = build_sql(question, state["retrieved_context"])
return {"sql_query": query}
@tool
def report_tool(state: AgentState) -> str:
df = run_query(state["sql_query"])
df.to_csv("report.csv")
return "report.csv"The key points: pass |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have a workflow with 3 tools (SQL tool, Retriever Tool, Report Tool).
Retriever Tool - retrieves context from a
vectorstore(List[Document])SQL Tool - creates a valid SQL query
Report Tool - accepts a SQL query and creates a csv report
Based on user query, the agent has to call one or more tools. The workflow is specified in skills. I need my tools to
ToolMessageto the main agentI need them in agent's state because:
How to achieve the same with
create_deep_agent()?All reactions