Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/crewai/src/crewai/llms/providers/azure/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
ChatCompletions,
ChatCompletionsToolCall,
StreamingChatCompletionsUpdate,
JsonSchemaFormat,
)
from azure.core.credentials import (
AzureKeyCredential,
Expand Down Expand Up @@ -278,13 +279,15 @@ def _prepare_completion_params(
}

if response_model and self.is_openai_model:
params["response_format"] = {
"type": "json_schema",
"json_schema": {
"name": response_model.__name__,
"schema": response_model.model_json_schema(),
},
}
response_model_json_schema = response_model.model_json_schema()
response_model_json_schema['additionalProperties'] = False

params["response_format"] = JsonSchemaFormat(
name="Tasks_Response",
schema=response_model_json_schema,
description="Describes the task expected response",
strict=True,
)

# Only include model parameter for non-Azure OpenAI endpoints
# Azure OpenAI endpoints have the deployment name in the URL
Expand Down
Loading