Repository navigation
Fix: /chat/completions not aware of conversation_id - #15162
Conversation
📝 WalkthroughWalkthroughThe ChangesSession ID Parameter Fallback
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Documentation Updates 1 document(s) were updated by changes in this PR: What is the complete API flow for building a frontend UI with RAGFlow, covering dialogs, conversations, message history, streaming responses, and deletion?View Changes@@ -189,6 +189,8 @@
}
```
+> **Note:** Either `session_id` or `conversation_id` can be used interchangeably to identify the session/conversation.
+
**Payload — Second message (includes ALL previous history):**
```json
{ |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/apps/restful_apis/chat_api.py (1)
1074-1074: ⚡ Quick winAdd a log for the
conversation_idfallback path.This introduces a new request-handling flow but doesn’t emit any trace when fallback is used, which makes debugging client behavior harder.
Proposed change
- session_id = req.pop("session_id", "") or req.pop("conversation_id", "") or "" + raw_session_id = req.pop("session_id", "") or "" + raw_conversation_id = req.pop("conversation_id", "") or "" + session_id = raw_session_id or raw_conversation_id + if raw_conversation_id and not raw_session_id: + logging.info("session_completion received conversation_id fallback")As per coding guidelines, "**/*.py: Add logging for new flows".
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@api/apps/restful_apis/chat_api.py` at line 1074, The single-line assignment that sets session_id from req.pop("session_id", "") or falls back to req.pop("conversation_id", "") should be expanded so we detect when the fallback is used and emit a log; specifically, first attempt to pop "session_id" into a local variable (session_id), then if empty pop "conversation_id" (conversation_id) and when conversation_id is used, call the module's logger (e.g., logger.info/debug) to record that the conversation_id fallback path was taken and include the conversation_id value and any relevant request identifier; update the code around the session_id handling in chat_api.py accordingly so the new flow is logged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@api/apps/restful_apis/chat_api.py`:
- Line 1074: The single-line assignment that sets session_id from
req.pop("session_id", "") or falls back to req.pop("conversation_id", "") should
be expanded so we detect when the fallback is used and emit a log; specifically,
first attempt to pop "session_id" into a local variable (session_id), then if
empty pop "conversation_id" (conversation_id) and when conversation_id is used,
call the module's logger (e.g., logger.info/debug) to record that the
conversation_id fallback path was taken and include the conversation_id value
and any relevant request identifier; update the code around the session_id
handling in chat_api.py accordingly so the new flow is logged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ae4474df-d6aa-4f80-9f15-36a2b26e207a
📒 Files selected for processing (1)
api/apps/restful_apis/chat_api.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #15162 +/- ##
=======================================
Coverage 93.12% 93.12%
=======================================
Files 10 10
Lines 713 713
Branches 116 116
=======================================
Hits 664 664
Misses 29 29
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What problem does this PR solve?
Fix /chat/completions not aware of conversation_id
Type of change