优化DifyQueryRetrieval类,新增top_k参数以支持检索结果的数量控制,同时重构相关方法以提升性能和可维护性。更新DifyTool类,新增获取应用会话和消息信息的方法。修复DifyExporter类中的代码格式问题,调整日期参数的默认值。

This commit is contained in:
2025-07-10 08:36:12 +08:00
parent ec3db656a5
commit 23f522dde5
4 changed files with 28 additions and 15 deletions
+16 -2
View File
@@ -68,7 +68,6 @@ class PgSql:
self.connection.close()
self.connection = None
def get_appinfo(self, appid:str)->dict | None:
"""
根据应用 ID 从 'apps' 表中获取应用信息。
@@ -97,7 +96,6 @@ class PgSql:
except (Exception, psycopg2.Error) as error:
raise Exception(f"Error while getting tenant_id by appid: {error}")
def get_messages_info(self, appid:str, query:str)->dict | None:
"""
根据应用 ID 和查询内容从 'messages' 表中获取消息信息。
@@ -246,6 +244,7 @@ class PgSql:
raise Exception(f"Error while getting conversation_messages: {error}")
return rating
class DifyTool:
"""
提供用于获取 Dify 应用调试信息的工具类。
@@ -322,6 +321,21 @@ class DifyTool:
}
except Exception as e:
raise Exception(f"Error in get_message_debug_info_by_query: {e}")
def get_app_conversations(self, appid:str)->list[str] | None:
"""
根据应用 ID 从 'conversations' 表中获取应用会话信息。
"""
return self.dify_pgsql.get_app_conversations(appid)
def get_conversation_messages(self, conversation_id:str):
"""
根据会话 ID 从 'messages' 表中获取会话消息信息。
"""
return self.dify_pgsql.get_app_conversations(conversation_id)
def get_message_rating(self, msg_id):
return self.dify_pgsql.get_message_rating(msg_id)
class BaseWorkflowChat:
"""