URL
https://python.langchain.com/v0.1/docs/use_cases/tool_use/human_in_the_loop/
待办事项清单:
- 我为这个问题添加了一个非常描述性的标题。
- 如果适用,我包含了一个指向我参考的文档页面的链接。
当前文档的问题:
我查看了human_in_the_loop的文档,但是不知道在agent tools中应该怎么做。我有一个工具列表。有些需要人工审批,有些则不需要。所以如何过滤这些工具。
我的代码如下:
tools = [
StructuredTool.from_function(
func=calculate,
name="calculate",
description="Useful for when you need to answer questions about simple calculations",
args_schema=CalculatorInput,
),
StructuredTool.from_function(
func=toolsNeedApproval ,
name="toolsNeedApproval",
description="This tool need human approval .",
args_schema=toolsNeedApprovalInput,
),
StructuredTool.from_function(
func=normalTool,
name="normalTool",
description="This tool is a normal tool .",
args_schema=normalToolInput,
),
]
callback = CustomAsyncIteratorCallbackHandler()
model = get_ChatOpenAI(
model_name=model_name,
temperature=temperature,
max_tokens=max_tokens,
callbacks=[callback],
)
model.bind_tools(tools, tool_choice="any")
llm_chain = LLMChain(llm=model, prompt=prompt_template_agent)
agent = LLMSingleActionAgent(
llm_chain=llm_chain,
output_parser=output_parser,
stop=["\nObservation:", "Observation"],
allowed_tools=tool_names,
)
agent_executor = AgentExecutor.from_agent_and_tools(agent=agent,
tools=tools,
verbose=True,
memory=memory,
)
agent_executor.acall(query, callbacks=[callback], include_run_info=True)
...
关于内容的想法或请求:
我不知道如何在agent tools中添加人工审批功能。
1条答案
按热度按时间ktecyv1j1#
这是一个关于人类在中间的参考代码片段,我建议你将其添加到你感兴趣的工具中,这样每当该工具被调用时,我们都会调用这个函数,然后决定是否继续执行。
例如:
创建一个名为MongoSearch的工具,用于搜索mongoDb数据库。