from langchain.tools import tool from .base_tool import call_csharp_api, get_tool_prompt from typing import Optional def get_cust_info_default_config(): """get_cust_info 工具的默认配置""" return { "get_cust_info": { "基础描述": "获取指定客户的详细信息", "入参说明": { "backend_url": "后端API地址", "token": "认证令牌", "cusname": "客户名称", }, "返回值说明": {"格式": "一个包含客户信息的字符串"}, "输出格式要求": [ "**客户:**{cusname}", "**性质:**{state}", "**地区:**{areaname}", "**业务员:**{custype}", "**联系人:**{rep}", "**联系方式:**{contact}", "**地址:**{address}", "**常购型号**", "| 型号 | 产品名称 | 单位 | 近6个月采购量 | 上月采购量 |", "| :--- | :--- | :--- | :--- | :--- |", "| mtrlcode | mtrlname | unit | saleqty_halfyear | saleqty_lastmonth |", ], "使用示例": "查一下客户 南华家具", } } tool_description = get_tool_prompt("get_cust_info", get_cust_info_default_config()) def get_cust_info_func( backend_url: str, token: str, cusname: str = "", ) -> str: """实际的函数实现""" print(f"正在获取客户信息{cusname}") return call_csharp_api( backend_url, token, "cust_data_ai", "get_cust_info", {"arg_cusname": cusname}, ) get_cust_info_func.__doc__ = tool_description get_cust_info = tool(get_cust_info_func)