Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(model_runtime): ensure compatibility with O1 models by adjusting token parameters (#10537)

-LAN-867bf70f1a62
diff --git a/api/core/model_runtime/model_providers/openai/llm/llm.py b/api/core/model_runtime/model_providers/openai/llm/llm.py
index 922e5e13141..68317d71796 100644
--- a/api/core/model_runtime/model_providers/openai/llm/llm.py
+++ b/api/core/model_runtime/model_providers/openai/llm/llm.py
@@ -617,6 +617,10 @@ class OpenAILargeLanguageModel(_CommonOpenAI, LargeLanguageModel):
# o1 compatibility
block_as_stream = False
if model.startswith("o1"):
+ if "max_tokens" in model_parameters:
+ model_parameters["max_completion_tokens"] = model_parameters["max_tokens"]
+ del model_parameters["max_tokens"]
+
if stream:
block_as_stream = True
stream = False