|
|
@@ -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)
|