mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-23 03:26:53 +08:00
Fix: "AttributeError(\"'list' object has no attribute 'get'\")" (#12518)
### What problem does this PR solve? https://github.com/infiniflow/ragflow/issues/12515 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -425,7 +425,7 @@ async def chat_completion_openai_like(tenant_id, chat_id):
|
||||
],
|
||||
}
|
||||
if need_reference:
|
||||
response["choices"][0]["message"]["reference"] = chunks_format(answer.get("reference", []))
|
||||
response["choices"][0]["message"]["reference"] = chunks_format(answer.get("reference", {}))
|
||||
|
||||
return jsonify(response)
|
||||
|
||||
|
||||
@ -38,6 +38,8 @@ def get_value(d, k1, k2):
|
||||
|
||||
|
||||
def chunks_format(reference):
|
||||
if not reference or (reference is not dict):
|
||||
return []
|
||||
return [
|
||||
{
|
||||
"id": get_value(chunk, "chunk_id", "id"),
|
||||
|
||||
Reference in New Issue
Block a user