Skip to content

Commit

Permalink
fix: remove json_schema if response format is disabled. (#12014)
Browse files Browse the repository at this point in the history
Signed-off-by: -LAN- <laipz8200@outlook.com>
  • Loading branch information
laipz8200 authored Dec 23, 2024
1 parent d0dd8b7 commit af2888d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/core/model_runtime/model_providers/openai/llm/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ def _generate(

# 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:
Expand Down Expand Up @@ -593,6 +597,8 @@ def _chat_generate(
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 = {}

Expand Down

0 comments on commit af2888d

Please sign in to comment.