| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- from langchain.tools import tool
- from .base_tool import call_csharp_api, get_tool_prompt
- def get_sale_amt_default_config():
- """get_sale_amt 工具的默认配置"""
- return {
- "get_sale_amt": {
- "基础描述": "获取指定时间范围的销售金额,按月汇总",
- "入参说明": {
- "backend_url": "后端API地址",
- "token": "认证令牌",
- "funtion_name": "函数名称; get_sale_amt_by_month:按月汇总销售额; get_sale_amt_by_day:按天汇总销售额; get_sale_amt_by_produce:产品销售额; get_sale_amt_by_cus:客户销售额;get_sale_amt_by_saler:业务员销售额;get_sale_amt_by_cus_produce:客户产品销售额;get_hot_produce_not_buy:客户未购买过的热销产品",
- "cusname": "客户名称,只有get_hot_produce_not_buy需要",
- "firstdate": "开始日期,格式YYYY-MM-DD",
- "lastdate": "结束日期,格式YYYY-MM-DD 23:59:59",
- },
- "返回值说明": {
- "格式": "一个包含销售金额的字符串",
- },
- "输出格式要求": [
- "重复信息要总结归纳,精简显示",
- ],
- "使用示例": "用户输入:'查看2023年1月1日至2023年12月31日的销售金额' -> 获取2023年1月至12月的销售金额;'2024年前5热销产品是哪些?' -> 获取2024年产品销售额;'2025年前10销售额最高的客户是?' -> 获取2025年客户销售额';'客户A还没买过的热销型号有哪些?'->获取客户未买过近半年的热销款(没有指定时间范围默认近半年)",
- }
- }
- tool_description = get_tool_prompt("get_sale_amt", get_sale_amt_default_config())
- def get_sale_amt_func(
- backend_url: str,
- token: str,
- funtion_name: str,
- firstdate: str,
- lastdate: str,
- cusname: str = "",
- ) -> str:
- """实际的函数实现"""
- print(f"正在获取销售金额{funtion_name},时间范围:{firstdate} 至 {lastdate}")
- return call_csharp_api(
- backend_url,
- token,
- "sale_data_ai",
- funtion_name,
- {"arg_firstdate": firstdate, "arg_lastdate": lastdate, "arg_cusname": cusname},
- )
- get_sale_amt_func.__doc__ = tool_description
- get_sale_amt = tool(get_sale_amt_func)
|