LangChain AgentExecutor invoke跟踪记录(三:多工具调用)

没耐心写了直接看输入输出,输出默认都是stop前:

输入:

System: Respond to the human as helpfully and accurately as possible. You have access to the following tools:

Calculator: Useful for when you need to calculate math problems, args: {'calculation': {'description': 'calculation to perform', 'title': 'Calculation', 'type': 'string'}}
DistanceConverter: Converts distance between meters, kilometers, and feet, args: {'distance': {'description': 'The numeric value of the distance to be converted, returning a number (integer or floating-point', 'title': 'Distance', 'type': 'number'}, 'unit': {'description': 'The current unit of the distance into(m, km, or feet)', 'title': 'Unit', 'type': 'string'}, 'to_unit': {'description': 'The target unit to convert the distance into (m, km, or feet)', 'title': 'To Unit', 'type': 'string'}}

Use a json blob to specify a tool by providing an action key (tool name) and an action_input key (tool input).

Valid "action" values: "Final Answer" or Calculator, DistanceConverter

Provide only ONE action per $JSON_BLOB, as shown:

```
{
  "action": $TOOL_NAME,
  "action_input": $INPUT
}
```

Follow this format:

Question: input question to answer
Thought: consider previous and subsequent steps
Action:
```
$JSON_BLOB
```
Observation: action result
... (repeat Thought/Action/Observation N times)
Thought: I know what to respond
Action:
```
{
  "action": "Final Answer",
  "action_input": "Final response to human"
}

Begin! Reminder to ALWAYS respond with a valid json blob of a single action. Use tools if necessary. Respond directly if appropriate. Format is Action:```$JSON_BLOB```then Observation
Human: 光明操场的跑道一圈534米,小明跑了234圈,请问小明一共跑了多少米?转换为千米呢?

```
{
  "action": "Calculator",
  "action_input": "534*234"
}
```
Observation: 124956
Thought: 
 (reminder to respond in a JSON blob no matter what)

 输出:

```
{
  "action": "DistanceConverter",
  "action_input": {
    "distance": 124956,
    "unit": "meters",
    "to_unit": "kilometers"
  }
}
```

 输入:

System: 略

Human: 光明操场的跑道一圈534米,小明跑了234圈,请问小明一共跑了多少米?转换为千米呢?

```
{
  "action": "Calculator",
  "action_input": "534*234"
}
```
Observation: 124956
Thought: ```
{
  "action": "DistanceConverter",
  "action_input": {
    "distance": 124956,
    "unit": "meters",
    "to_unit": "kilometers"
  }
}
```
Observation: 124956.0 meters is equal to 124956.0 kilometers
Thought: 
 (reminder to respond in a JSON blob no matter what)

 输出:

```
{
  "action": "Final Answer",
  
  "action_input": "小明一共跑了124956米,也就是124956.0千米。"
}
```

 最后打印了> Finished chain.

可见简单的多工具情况下,并不是第一轮就分析出整条调用顺序,而是每轮都重新猜测本轮要调用哪个工具。这个合理的。

然后这个DistanceConverter工具解析得不太对,看system其实是有写明单位名称约束的,但我的模型没有做到这一点:

'unit': {'description': 'The current unit of the distance into(m, km, or feet)', 'title': 'Unit', 'type': 'string'}, 'to_unit': {'description': 'The target unit to convert the distance into (m, km, or feet)'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值