You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The agent which manages / orchestrate the workflow:
graph_builder = StateGraph(EmailAgentState)
graph_builder.add_node("EmailAgent", self.call_agent_model_node)
graph_builder.add_node("EmailTools", ToolNode([email_processing_tool]))
graph_builder.add_edge(START, "EmailAgent")
graph_builder.add_conditional_edges(
# if the EmailAgent node returns a tool message, your graph moves to the EmailTools node to call the respective tool.
"EmailAgent", self.route_agent_graph_edge, ["EmailTools", END]
)
graph_builder.add_edge("EmailTools", "EmailAgent")
self._agent = graph_builder.compile(store=self._in_memory_store, name=self._agentName)
Invoke the agent:
async for step in self._agent.with_config({"graph": self._graph, "email_state": email_state, "thread_id": uuid7str()}).astream(
{"messages": [{"role": "user", "content": message_with_criteria}]},
stream_mode="values",
):
step["messages"][-1].pretty_print()
Description
init_chat_model would bind_tools to a @tool which requires access to the model and/or another StateGraph which are all constructed in the constructor of an application. Here are my questions:
(1) How to pass the graph and/or model to the @tool? Would using configurable_fields in init_chat_model be the best option considering the performance impact it may have on every super-step call that it has to pass these large data structure around?
(2) How to manage the resource context so that they are shutdown / closed properly thoughout the lifetime of the hosting application?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Initialize the LLM chat model:
The tool which the model binds to:
The
StateGraph
used by the@tool
:The agent which manages / orchestrate the workflow:
Invoke the agent:
Description
init_chat_model
wouldbind_tools
to a@tool
which requires access to the model and/or anotherStateGraph
which are all constructed in the constructor of an application. Here are my questions:(1) How to pass the graph and/or model to the
@tool
? Would usingconfigurable_fields
ininit_chat_model
be the best option considering the performance impact it may have on every super-step call that it has to pass these large data structure around?(2) How to manage the resource context so that they are shutdown / closed properly thoughout the lifetime of the hosting application?
System Info
Beta Was this translation helpful? Give feedback.
All reactions