Replies: 3 comments 1 reply
-
To pass a runnable config to a tool within an
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import tool
@tool
def get_some_sauce(input: str, config: RunnableConfig):
# Your tool logic here
pass
config = {"user_id": 123, "conversation_id": 1234}
agent_executor = AgentExecutor(
agent=agent,
llm=llm,
tools=tools,
verbose=True,
handle_parsing_errors=True,
callbacks=[FileCallbackHandler("logs/genai.log")]
).withConfig(config=config) This setup ensures that when the To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
-
I have already done that but the runnableConfig is not passed to the Tool |
Beta Was this translation helpful? Give feedback.
-
@dosui have done that but this does not propagate my config in the runnable tool.Sent from my iPhoneOn 13 Dec 2024, at 1:40 AM, dosubot[bot] ***@***.***> wrote:
To pass a runnable config to a tool within an AgentExecutor, you need to ensure that your tool is set up to accept a RunnableConfig parameter. LangChain will automatically populate this parameter with the correct config value when the tool is invoked. Here's how you can achieve this:
Define your tool with a RunnableConfig parameter:
from langchain_core.runnables import RunnableConfig
from langchain_core.tools import tool
@tool
def get_some_sauce(input: str, config: RunnableConfig):
# Your tool logic here
pass
When you configure your AgentExecutor, use the withConfig method to pass the configuration:
config = {"user_id": 123, "conversation_id": 1234}
agent_executor = AgentExecutor(
agent=agent,
llm=llm,
tools=tools,
verbose=True,
handle_parsing_errors=True,
callbacks=[FileCallbackHandler("logs/genai.log")]
).withConfig(config=config)
This setup ensures that when the AgentExecutor is invoked, the RunnableConfig is passed to the get_some_sauce tool, allowing it to access the configuration values like user_id and conversation_id [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
I have an agent executor like
config = {"user_id" : 123 , "conversation_id" : 1234}
AgentExecutor(
agent=agent,
llm=llm,
tools=tools,
verbose=True,
handle_parsing_errors=True,
callbacks=[FileCallbackHandler("logs/genai.log")],
).withConfig(config=config)
and I have a tool
@tool()
def get_some_sauce(input: str, config: RunnableConfig):
add_route(
I want the agent executor when invoked to pass down the runnable config to the tool. How to achieve this?
Beta Was this translation helpful? Give feedback.
All reactions