mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 15:31:05 +08:00
Fixes #15587 ## Problem `AzureEmbed.__init__` in `rag/llm/embedding_model.py` and `AzureGptV4.__init__` in `rag/llm/cv_model.py` both call `json.loads(key)` unconditionally: ```python api_key = json.loads(key).get("api_key", "") api_version = json.loads(key).get("api_version", "2024-02-01") ``` When a user stores a plain API key string (not a JSON object) in the model configuration — which is a valid and common way to configure Azure OpenAI — `json.loads` raises `JSONDecodeError`. This makes the model fail to initialize and causes document parsing/embedding to return a 500 error. ## Fix Wrap `json.loads` in `try/except (json.JSONDecodeError, TypeError)` and fall back to using the raw string as the `api_key` with the default `api_version`. This is the same pattern already applied to the Azure chat model in PR #15604. ## Files changed - `rag/llm/embedding_model.py` — `AzureEmbed.__init__` - `rag/llm/cv_model.py` — `AzureGptV4.__init__` Fixes #15857 --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: Wang Qi <wangq8@outlook.com>