删除不再使用的脚本文件,更新数据库连接配置为环境变量,优化Dify对比测试逻辑,增强日志记录.
This commit is contained in:
+13
-12
@@ -39,11 +39,11 @@ class PgSql:
|
||||
try:
|
||||
# 连接数据库
|
||||
self.connection = psycopg2.connect(
|
||||
user="postgres",
|
||||
password="difyai123456",
|
||||
host="172.20.0.145",
|
||||
port=5432,
|
||||
database="dify"
|
||||
user=os.getenv("DIFY_PG_USER"),
|
||||
password=os.getenv("DIFY_PG_PASSWORD"),
|
||||
host=os.getenv("DIFY_PG_HOST"),
|
||||
port=os.getenv("DIFY_PG_PORT"),
|
||||
database=os.getenv("DIFY_PG_DATABASE")
|
||||
)
|
||||
|
||||
except (Exception, psycopg2.Error) as error:
|
||||
@@ -160,11 +160,11 @@ class PgSql:
|
||||
""",
|
||||
(workflow_run_id,)
|
||||
)
|
||||
result = cursor.fetchall()
|
||||
if result:
|
||||
colnames = [desc[0] for desc in cursor.description]
|
||||
return [dict(zip(colnames, row)) for row in result]
|
||||
return None
|
||||
result = cursor.fetchall()
|
||||
if result:
|
||||
colnames = [desc[0] for desc in cursor.description]
|
||||
return [dict(zip(colnames, row)) for row in result]
|
||||
return None
|
||||
except (Exception, psycopg2.Error) as error:
|
||||
raise Exception(f"Error while getting workflow_node_executions_info: {error}")
|
||||
|
||||
@@ -263,7 +263,8 @@ class BaseWorkflowChat:
|
||||
析构函数,在对象被销毁时自动关闭数据库连接。
|
||||
确保在对象生命周期结束时释放数据库资源。
|
||||
"""
|
||||
self.dify_tool.close_connection()
|
||||
# DifyTool类已经在其__del__方法中关闭了数据库连接,无需在此重复调用
|
||||
pass
|
||||
|
||||
def create_chat_message(self, query: str):
|
||||
"""
|
||||
@@ -464,7 +465,7 @@ class NewWorkflowChat(BaseWorkflowChat):
|
||||
elif workflow_node["title"] == "提取处理后的知识":
|
||||
outputs = json.loads(workflow_node["outputs"])["knowledge_list"]
|
||||
retrieve_title, max_score, min_score, avg_score = self.get_retrieve_info(query=query, outputs=outputs, reranker_sorce_info=reranker_sorce)
|
||||
elif workflow_node["title"] == "问题优化结果解析":
|
||||
elif workflow_node["title"] == "意图识别结果解析":
|
||||
outputs = json.loads(workflow_node["outputs"])
|
||||
rewrite_query = outputs["optimize_query"]
|
||||
llm_result_json = json.loads(workflow_node['inputs'])["llm_result"]
|
||||
|
||||
Reference in New Issue
Block a user