Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: user_default_llm configuration doesn't work for OpenAI API compatible LLM factory (#8502)

Stephen Hu938d8dd87830
diff --git a/api/db/services/llm_service.py b/api/db/services/llm_service.py
index e124b5b16a..462eb9d4a2 100644
--- a/api/db/services/llm_service.py
+++ b/api/db/services/llm_service.py
@@ -45,6 +45,18 @@ class TenantLLMService(CommonService):
objs = cls.query(tenant_id=tenant_id, llm_name=mdlnm)
else:
objs = cls.query(tenant_id=tenant_id, llm_name=mdlnm, llm_factory=fid)
+
+ if (not objs) and fid:
+ if fid == "LocalAI":
+ mdlnm += "___LocalAI"
+ elif fid == "HuggingFace":
+ mdlnm += "___HuggingFace"
+ elif fid == "OpenAI-API-Compatible":
+ mdlnm += "___OpenAI-API"
+ elif fid == "VLLM":
+ mdlnm += "___VLLM"
+
+ objs = cls.query(tenant_id=tenant_id, llm_name=mdlnm, llm_factory=fid)
if not objs:
return
return objs[0]