mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-05-21 00:36:43 +08:00
### What problem does this PR solve? Fixes #14206. This issue is a regression. PR #9520 previously changed Gemini models from `image2text` to `chat` to fix chat-side resolution, but PR #13073 later restored those Gemini entries to `image2text` during model-list updates, which reintroduced the bug. The underlying problem is that Gemini models are multimodal and advertise both `CHAT` and `IMAGE2TEXT`, while tenant model resolution still depends on a single stored `model_type`. That makes chat-only flows such as memory extraction fragile when a compatible model is stored as `image2text`. This PR fixes the issue at the model resolution layer instead of changing `llm_factories.json` again: - keep the stored tenant model type unchanged - try exact `model_type` lookup first - if no exact match is found, fall back only when the model metadata shows the requested capability is supported - coerce the runtime config to the requested type for chat callers - fail fast in memory creation instead of silently persisting `tenant_llm_id=0` This preserves existing multimodal and `image2text` behavior while restoring chat compatibility for memory-related flows. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) ### Testing - Re-checked the current memory creation and memory message extraction paths against the updated resolution logic - Verified locally that a Gemini-style tenant model stored as `image2text` but tagged with `CHAT` can still be resolved for `chat` - Verified `get_model_config_by_type_and_name(..., CHAT, ...)` returns a chat-compatible runtime config - Verified `get_model_config_by_id(..., CHAT)` also returns a chat-compatible runtime config - Verified strict resolution still fails when the model metadata does not advertise chat capability