longjoedyy пре 1 недеља
родитељ
комит
f402a0177d
2 измењених фајлова са 76 додато и 0 уклоњено
  1. 19 0
      config/tool_config.json
  2. 57 0
      tools/money_tools.py

+ 19 - 0
config/tool_config.json

@@ -52,5 +52,24 @@
             "其他列原样显示"
         ],
         "使用示例": "用户输入:'查询铜管的销售价格' -> 系统调用此工具获取铜管的销售价格"
+    },
+    "get_cusamt": {
+        "基础描述": "获取指定时间范围的收款数据,可指定客户、汇总方式,你根据时间跨度决定最佳的汇总方式",
+        "入参说明": {
+            "backend_url": "后端API地址",
+            "token": "用户认证令牌,用于身份验证",
+            "cusname": "客户名称 或 客户编码, 支持模糊查询",
+            "firstdate": "开始日期,格式YYYY-MM-DD",
+            "lastdate": "结束日期,格式YYYY-MM-DD 23:59:59",
+            "grouptype": "汇总方式,数值, 0:按天;1:按月;2:按年"
+        },
+        "返回值说明": {
+            "格式": "一个包含客户收款数据的字符串",
+            "字段含义": "custname:客户名称, viewdate:收款日期, amt:收款金额,currency:币种,kind:收款类型"
+        },
+        "输出格式要求": [
+            "以表格输出,客户名称列默认要显示,除非用户有其他汇总需求"
+        ],
+        "使用示例": "用户输入:'查询客户A,2025年的收款情况' -> 系统调用此工具获取客户A在2025年1月至12月的收款数据"
     }
 }

+ 57 - 0
tools/money_tools.py

@@ -0,0 +1,57 @@
+from langchain.tools import tool
+from .base_tool import call_csharp_api, get_tool_prompt
+
+
+def get_cusamt_default_config():
+    """get_cusamt 工具的默认配置"""
+    return {
+        "get_cusamt": {
+            "基础描述": "获取指定时间范围的收款数据,可指定客户、汇总方式,你根据时间跨度决定最佳的汇总方式",
+            "入参说明": {
+                "backend_url": "后端API地址",
+                "token": "认证令牌",
+                "cusname": "客户名称 或 客户编码, 支持模糊查询,留空即查询所有客户",
+                "firstdate": "开始日期,格式YYYY-MM-DD",
+                "lastdate": "结束日期,格式YYYY-MM-DD 23:59:59",
+                "grouptype": "汇总方式,数值, 0:按天;1:按月;2:按年",
+            },
+            "返回值说明": {
+                "格式": "一个包含客户收款数据的字符串",
+            },
+            "输出格式要求": ["以表格输出"],
+        }
+    }
+
+
+tool_description = get_tool_prompt("get_cusamt", get_cusamt_default_config())
+
+
+def get_cusamt_func(
+    backend_url: str,
+    token: str,
+    cusname: str,
+    firstdate: str,
+    lastdate: str,
+    grouptype: str,
+) -> str:
+    """实际的函数实现"""
+    print(
+        f"正在获取客户{cusname}在{firstdate}至{lastdate}的收款数据,汇总方式{grouptype}"
+    )
+
+    return call_csharp_api(
+        backend_url,
+        token,
+        "money_data_ai",
+        "get_cusamt",
+        {
+            "arg_cusname": cusname,
+            "arg_firstdate": firstdate,
+            "arg_lastdate": lastdate,
+            "grouptype": grouptype,
+        },
+    )
+
+
+get_cusamt_func.__doc__ = tool_description
+get_cusamt = tool(get_cusamt_func)