Skip to content

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

refactor:re order logics in clean_gen_conf (#12391)

Stephen Hu6f2fc2f1cbfb
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py
index e1451c00d0..a9e3c1ab7c 100644
--- a/rag/llm/chat_model.py
+++ b/rag/llm/chat_model.py
@@ -100,6 +100,12 @@ class Base(ABC):
return LLMErrorCode.ERROR_GENERIC
def _clean_conf(self, gen_conf):
+ model_name_lower = (self.model_name or "").lower()
+ # gpt-5 and gpt-5.1 endpoints have inconsistent parameter support, clear custom generation params to prevent unexpected issues
+ if "gpt-5" in model_name_lower:
+ gen_conf = {}
+ return gen_conf
+
if "max_tokens" in gen_conf:
del gen_conf["max_tokens"]
@@ -127,12 +133,6 @@ class Base(ABC):
}
gen_conf = {k: v for k, v in gen_conf.items() if k in allowed_conf}
-
- model_name_lower = (self.model_name or "").lower()
- # gpt-5 and gpt-5.1 endpoints have inconsistent parameter support, clear custom generation params to prevent unexpected issues
- if "gpt-5" in model_name_lower:
- gen_conf = {}
-
return gen_conf
async def _async_chat_streamly(self, history, gen_conf, **kwargs):