Skip to content

Commit 9cfeff4

Browse files
committed
add support for o1/3 and fix type input
1 parent 4279a64 commit 9cfeff4

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

llm_dialog_manager/agent.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -394,16 +394,21 @@ def format_messages_for_api(
394394
if model.endswith("-openai"):
395395
model = model[:-7] # Remove last 7 characters ("-openai")
396396
client = openai.OpenAI(api_key=api_key, base_url=base_url)
397-
# Set response_format based on json_format
398-
response_format = {"type": "json_object"} if json_format else {"type": "plain_text"}
399-
400-
response = client.chat.completions.create(
401-
model=model,
402-
messages=formatted_messages,
403-
max_tokens=max_tokens,
404-
temperature=temperature,
405-
response_format=response_format # Added response_format
406-
)
397+
398+
# Create base parameters
399+
params = {
400+
"model": model,
401+
"messages": formatted_messages,
402+
}
403+
404+
# Add optional parameters
405+
if json_format:
406+
params["response_format"] = {"type": "json_object"}
407+
if not ("o1" in model or "o3" in model):
408+
params["max_tokens"] = max_tokens
409+
params["temperature"] = temperature
410+
411+
response = client.chat.completions.create(**params)
407412
return response.choices[0].message.content
408413

409414
# Release the API key after successful use

0 commit comments

Comments
 (0)