先跳过 定额信息的提取
This commit is contained in:
@@ -270,6 +270,51 @@ class DifyTool:
|
||||
except (Exception, psycopg2.Error) as error:
|
||||
raise Exception(f"Error while getting conversation_messages: {error}")
|
||||
return None
|
||||
|
||||
def execute_custom_sql(self, sql, params=None, fetch_type='all'):
|
||||
"""
|
||||
执行自定义的SQL查询或命令。
|
||||
|
||||
Args:
|
||||
sql: 要执行的SQL语句
|
||||
params: SQL参数(可选),用于参数化查询
|
||||
fetch_type: 结果获取类型,可选值:'all'(返回所有行), 'one'(返回单行), 'none'(不返回结果)
|
||||
|
||||
Returns:
|
||||
根据fetch_type返回查询结果:
|
||||
- fetch_type='all': 返回包含所有行的列表,每行是一个字典
|
||||
- fetch_type='one': 返回单行字典,如果没有结果则返回None
|
||||
- fetch_type='none': 返回受影响的行数
|
||||
|
||||
Raises:
|
||||
Exception: 如果执行SQL时发生错误
|
||||
"""
|
||||
with self.pg_sql_lock:
|
||||
try:
|
||||
with self.connection.cursor() as cursor:
|
||||
# 执行SQL语句
|
||||
cursor.execute(sql, params or ())
|
||||
|
||||
# 根据fetch_type处理结果
|
||||
if fetch_type == 'all':
|
||||
result = cursor.fetchall()
|
||||
if result:
|
||||
colnames = [desc[0] for desc in cursor.description]
|
||||
return [dict(zip(colnames, row)) for row in result]
|
||||
return []
|
||||
elif fetch_type == 'one':
|
||||
result = cursor.fetchone()
|
||||
if result:
|
||||
colnames = [desc[0] for desc in cursor.description]
|
||||
return dict(zip(colnames, result))
|
||||
return None
|
||||
elif fetch_type == 'none':
|
||||
# 对于UPDATE, INSERT, DELETE等操作,返回受影响的行数
|
||||
return cursor.rowcount
|
||||
else:
|
||||
raise ValueError(f"不支持的fetch_type: {fetch_type}")
|
||||
except (Exception, psycopg2.Error) as error:
|
||||
raise Exception(f"Error executing custom SQL: {error}")
|
||||
|
||||
"""
|
||||
提供用于获取 Dify 应用调试信息的工具类。
|
||||
|
||||
@@ -355,7 +355,11 @@ class AsyncIntentRecognizer:
|
||||
"dinge_info_list":{{"dinge_code_list":["xxxx","xxxx"], "dinge_name_list":["xxxx","xxxx"]}},
|
||||
"qingdan_info":{{"qingdan_code_list":["xxxx","xxxx"], "qingdan_name_list":["xxxx","xxxx"]}}
|
||||
}}"""
|
||||
|
||||
# 暂时跳过提取定额清单信息,本环节还未梳理清楚套用规则。
|
||||
return {
|
||||
"dinge_info_list":{"dinge_code_list":[], "dinge_name_list":[]},
|
||||
"qingdan_info":{"qingdan_code_list":[], "qingdan_name_list":[]}
|
||||
}
|
||||
try:
|
||||
# response = await self._llm.ainvoke(prompt, response_format={"type": "json_object"}, extra_body={"enable_thinking": False})
|
||||
response = await self._llm.ainvoke(prompt, response_format={"type": "json_object"})
|
||||
|
||||
Reference in New Issue
Block a user