mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-01 01:25:32 +08:00
fix: correct session reference initialization to prevent dialogue misalignment (#12343)
## Summary Fixes #12311 Changes the `reference` field initialization from `[{}]` to `[]` in session creation. ### Problem When creating a session via the SDK API, the `reference` field was incorrectly initialized as `[{}]`. This caused: - First dialogue round: Empty reference - Second dialogue round: Reference pointing to first round's data - Overall misalignment between dialogue rounds and their references ### Solution Changed the initialization to `[]` (empty list), which: - Matches the `Conversation` model's expected default - Ensures references grow correctly one-to-one with assistant responses - Aligns with the service layer's expectations ### Testing After applying this fix: 1. Create a session via `POST /api/v1/chats/{conversation_id}/sessions` 2. Send multiple questions via `POST /api/v1/chats/{conversation_id}/completions` 3. View the conversation on web - references should now align correctly with each dialogue round
This commit is contained in:
@ -60,7 +60,7 @@ async def create(tenant_id, chat_id):
|
||||
"name": req.get("name", "New session"),
|
||||
"message": [{"role": "assistant", "content": dia[0].prompt_config.get("prologue")}],
|
||||
"user_id": req.get("user_id", ""),
|
||||
"reference": [{}],
|
||||
"reference": [],
|
||||
}
|
||||
if not conv.get("name"):
|
||||
return get_error_data_result(message="`name` can not be empty.")
|
||||
|
||||
Reference in New Issue
Block a user