mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
### Related issues Closes #15358 <!-- After filing upstream, replace XXXX with your issue number. --> --- ### What problem does this PR solve? `POST /api/v1/openai/<chat_id>/chat/completions` forwards `messages` to `async_chat` without normalizing `content`. Downstream, `dialog_service` assumes string content: ```python re.sub(r"##\d+\$\$", "", m["content"]) ``` OpenAI-compatible clients may send `content` as an **array** of parts (text, `image_url`, etc.), including text-only arrays. That causes `TypeError` and HTTP **500** instead of a valid response or a clear **400**. `openai_api.py` also reads `messages[-1]["content"]` directly for `prompt` without handling list-shaped content. This PR normalizes array `content` to a string (concatenating `type: text` parts) before calling `async_chat`, matching a minimal OpenAI-compat path. Image parts can be documented as unsupported or handled in a follow-up if vision integration is required.