当前位置:   article > 正文

Qwen-Agent自定义Tool

qwen-agent

qwen-agent项目部署

1、下载qwen-agent

https://github.com/QwenLM/Qwen-Agent
  • 1

2、安装依赖环境

pip3 install -r requirements.txt
  • 1

自定义Tool

cd qwen_agent/tools
  • 1

在这里插入图片描述
参考其他的工具,我这里创建了一个查询手机号归属地的工具get_mobile_address.py:

import json
import urllib.parse
from typing import Union

from qwen_agent.tools.base import BaseTool, register_tool


@register_tool('get_mobile_address')
class MobileAddress(BaseTool):
    description = '手机号归属地查询服务,输入手机号,返回该手机号的归属地。'
    parameters = [{
        'name': 'mobile',
        'type': 'string',
        'description': '输入的手机号',
        'required': True
    }]

    def call(self, params: Union[str, dict], **kwargs) -> str:
        params = self._verify_json_format_args(params)

        prompt = params['mobile']
        url = "https://eolink.o.apispace.com/teladress/teladress"
		payload = {"mobile":f"{prompt}"}
		headers = {
			"X-APISpace-Token":"v1a524e7ctm4h87illkgmxxxxxxxxx",
			"Content-Type":"application/x-www-form-urlencoded"
		}
		response=requests.request("POST", url, data=payload, headers=headers)
		return response.text
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

工具创建好之后,还需要在__init__.py中添加,要不然加载该工具的时候会报错:
在这里插入图片描述

调用工具

创建一个通用的工具调用服务:

import json
import os

import json5
import urllib.parse
from qwen_agent.agents import Assistant
from qwen_agent.tools.base import BaseTool, register_tool

llm_cfg = {
    'model': 'qwen:14b',
    'model_server': 'http://10.8.xx.xxx:11434/v1',
    'generate_cfg': {
        'top_p': 0.8
    }
}
system = '你扮演一个助手,会调用工具'

tools = ['image_gen','get_mobile_address']
bot = Assistant(llm=llm_cfg,
                system_message=system,
                function_list=tools)

messages = []
while True:
    query = input('user question: ')
    messages.append({'role': 'user', 'content': query})
    response = []
    for response in bot.run(messages=messages):
        print('bot response:', response)
    messages.extend(response)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

调用工具结果:

bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get', 'arguments': ''}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile', 'arguments': ''}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': ''}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': ''}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': ''}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': ''}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile":'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "17'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "176'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "17692'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "176922'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223x'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xx'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxx'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码17'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码176'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码17692'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码176922'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223x'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xx'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxx'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n-'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n-'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n-'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:03'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:031'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n-'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的主人'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的主人来自'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的主人来自哪个'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的主人来自哪个地区'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的主人来自哪个地区。'}]
bot response: [{'role': 'assistant', 'content': '', 'function_call': {'name': 'get_mobile_address', 'arguments': '{"mobile": "1769223xxxx"}'}}, {'role': 'function', 'content': '{"tradeNo":"9643077250786157612","chargeStatus":1,"message":"成功","data":{"orderNo":"111","handleTime":"2024-03-06 18:10:03","province":"河北","city":"保定","provinceCode":"0312","isp":"联通","mobile":"1769223xxxx","postCode":"071000","cityCode":"130600"},"code":"200000"}', 'name': 'get_mobile_address'}, {'role': 'assistant', 'content': '查询结果显示,电话号码1769223xxxx的归属地信息如下:\n\n- 省份:河北\n- 城市:保定\n- 省份代码:0312\n- 运营商:联通\n\n请根据这些信息来确认电话号码的主人来自哪个地区。'}]
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

当然,我们还可以将以上的代码改造成API服务,这样只要调用接口传入参数就可以了:

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from qwen_agent.agents import Assistant

app = FastAPI()

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

llm_cfg = {
    'model': 'qwen:14b',
    'model_server': 'http://10.8.xx.xxx:11434/v1',
    'generate_cfg': {
        'top_p': 0.8
    }
}

system = '你扮演一个助手,会调用工具'

tools = ['image_gen','get_mobile_address']
bot = Assistant(llm=llm_cfg,
                system_message=system,
                function_list=tools)

@app.post("/v1/tools", response_model=str)
def get_embeddings2(prompt: dict):
    messages = []
    messages.append(prompt)
    for response in bot.run(messages=messages):
        print('bot response:', response)

if __name__ == '__main__':
    uvicorn.run(app, host='0.0.0.0', port=8000, workers=1)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/454097
推荐阅读
相关标签
  

闽ICP备14008679号