mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-06-29 23:41:12 +08:00
fix: restore cross_languages default chat-model fallback for retrieval (#13471)
### What problem does this PR solve? issue #13465 POST /api/v1/retrieval failed with {"code":100,...,"message":"Exception('Model Name is required')"} when cross_languages was provided and no explicit llm_id was passed. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@@ -265,12 +265,15 @@ async def cross_languages(tenant_id, llm_id, query, languages=[]):
|
||||
from common.constants import LLMType
|
||||
from api.db.services.llm_service import LLMBundle
|
||||
from api.db.services.tenant_llm_service import TenantLLMService
|
||||
from api.db.joint_services.tenant_model_service import get_model_config_by_type_and_name
|
||||
from api.db.joint_services.tenant_model_service import get_model_config_by_type_and_name, get_tenant_default_model_by_type
|
||||
|
||||
if llm_id and TenantLLMService.llm_id2llm_type(llm_id) == "image2text":
|
||||
chat_model_config = get_model_config_by_type_and_name(tenant_id, LLMType.IMAGE2TEXT, llm_id)
|
||||
else:
|
||||
chat_model_config = get_model_config_by_type_and_name(tenant_id, LLMType.CHAT, llm_id)
|
||||
if not llm_id:
|
||||
chat_model_config = get_tenant_default_model_by_type(tenant_id, LLMType.CHAT)
|
||||
else:
|
||||
chat_model_config = get_model_config_by_type_and_name(tenant_id, LLMType.CHAT, llm_id)
|
||||
chat_mdl = LLMBundle(tenant_id, chat_model_config)
|
||||
rendered_sys_prompt = PROMPT_JINJA_ENV.from_string(CROSS_LANGUAGES_SYS_PROMPT_TEMPLATE).render()
|
||||
rendered_user_prompt = PROMPT_JINJA_ENV.from_string(CROSS_LANGUAGES_USER_PROMPT_TEMPLATE).render(query=query,
|
||||
|
||||
Reference in New Issue
Block a user