diff --git a/.gitignore b/.gitignore index cb8e9674..07699e34 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ docs/ venv/ backend/venv/ env/ -.env +# .env .venv build/ develop-eggs/ diff --git a/backend/.env b/backend/.env new file mode 100644 index 00000000..80f12a39 --- /dev/null +++ b/backend/.env @@ -0,0 +1,2 @@ +INTEGRATION_API_BASE=http://192.168.100.230:8891 +INTEGRATION_API_KEY=I76mSQZQEPYU6TubMhjh-xLsCgWC0gSIg5MncJFHFCvqvVlg-gZ_BvwO_UEL2nh diff --git a/backend/app/api/chat.py b/backend/app/api/chat.py index 0dbd56cf..095996f3 100644 --- a/backend/app/api/chat.py +++ b/backend/app/api/chat.py @@ -253,12 +253,12 @@ def submit_feedback(): return jsonify({'error': 'Missing user or agent context'}), 500 # 构造查询:限定在当前用户和 Agent 范围内 - query = ChatLog.query.filter_by(user_id=user.id, agent_id=agent.id) + chat_logs_query = db.session.query(ChatLog).filter_by(user_id=user.id, agent_id=agent.id) if conversation_id: - query = query.filter_by(conversation_id=conversation_id) + chat_logs_query = chat_logs_query.filter_by(conversation_id=conversation_id) # 取最新一条对话日志 - chat_log = query.order_by(ChatLog.created_at.desc()).first() + chat_log = chat_logs_query.order_by(ChatLog.created_at.desc()).first() if not chat_log: return jsonify({'error': 'ChatLog not found'}), 404 diff --git a/backend/app/config.py b/backend/app/config.py index 6aeb809b..27c838a7 100644 --- a/backend/app/config.py +++ b/backend/app/config.py @@ -72,6 +72,7 @@ class DevelopmentConfig(Config): DEBUG = True SQLALCHEMY_DATABASE_URI = os.getenv( 'DATABASE_URL', + # 'postgresql://postgres:123456@8.152.207.171:5432/hxops_db', 'postgresql://postgres:difyai123456@localhost:5432/hxops_db', ) diff --git a/backend/app/services/dify.py b/backend/app/services/dify.py index 879ea889..1930f323 100644 --- a/backend/app/services/dify.py +++ b/backend/app/services/dify.py @@ -129,7 +129,9 @@ class DifyService: DifyService._collect_metadata(retriever_resources, attribution_parts, data) elif event in ('message_end', 'agent_message', 'workflow_finished'): - if data.get('answer'): + # Keep metadata from non-message events, but avoid appending + # intermediate workflow/agent outputs into final user answer. + if event == 'message_end' and data.get('answer'): full_answer.append(data.get('answer', '')) DifyService._collect_metadata(retriever_resources, attribution_parts, data) diff --git a/frontend/dist/index.html b/frontend/dist/index.html index d45ce5c3..89620a59 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -7,13 +7,14 @@ - + -