mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-01 16:25:44 +08:00
Fix: chats_openai in none stream condition (#13495)
### What problem does this PR solve? Fix: chats_openai in none stream condition #13453 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -40,6 +40,9 @@ def get_value(d, k1, k2):
|
||||
def chunks_format(reference):
|
||||
if not reference or not isinstance(reference, dict):
|
||||
return []
|
||||
raw_chunks = reference.get("chunks", [])
|
||||
if not isinstance(raw_chunks, list):
|
||||
return []
|
||||
return [
|
||||
{
|
||||
"id": get_value(chunk, "chunk_id", "id"),
|
||||
@@ -55,7 +58,8 @@ def chunks_format(reference):
|
||||
"term_similarity": chunk.get("term_similarity"),
|
||||
"doc_type": get_value(chunk, "doc_type_kwd", "doc_type"),
|
||||
}
|
||||
for chunk in reference.get("chunks", [])
|
||||
for chunk in raw_chunks
|
||||
if isinstance(chunk, dict)
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -762,7 +762,7 @@ def test_openai_nonstream_branch_unit(monkeypatch):
|
||||
|
||||
res = _run(inspect.unwrap(module.chat_completion_openai_like)("tenant-1", "chat-1"))
|
||||
assert res["choices"][0]["message"]["content"] == "world"
|
||||
|
||||
|
||||
|
||||
@pytest.mark.p2
|
||||
def test_agents_openai_compatibility_unit(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user