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: remove json_schema if response format is disabled. (#12014)

-LAN-af2888d39476
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 b73ce8752f1..73cd7e3c341 100644
--- a/api/core/model_runtime/model_providers/openai/llm/llm.py
+++ b/api/core/model_runtime/model_providers/openai/llm/llm.py
@@ -421,7 +421,11 @@ class OpenAILargeLanguageModel(_CommonOpenAI, LargeLanguageModel):
# text completion model
response = client.completions.create(
- prompt=prompt_messages[0].content, model=model, stream=stream, **model_parameters, **extra_model_kwargs
+ prompt=prompt_messages[0].content,
+ model=model,
+ stream=stream,
+ **model_parameters,
+ **extra_model_kwargs,
)
if stream:
@@ -593,6 +597,8 @@ class OpenAILargeLanguageModel(_CommonOpenAI, LargeLanguageModel):
model_parameters["response_format"] = {"type": "json_schema", "json_schema": schema}
else:
model_parameters["response_format"] = {"type": response_format}
+ elif "json_schema" in model_parameters:
+ del model_parameters["json_schema"]
extra_model_kwargs = {}