mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: add(azure-ai): support reasoning config for AzureAIClient (#3403)
* add(azure-ai): support reasoning config for AzureAIClient * Update sample * Merge main * improvements * improve sample
This commit is contained in:
@@ -22,12 +22,7 @@ from agent_framework.observability import use_instrumentation
|
||||
from agent_framework.openai import OpenAIResponsesOptions
|
||||
from agent_framework.openai._responses_client import OpenAIBaseResponsesClient
|
||||
from azure.ai.projects.aio import AIProjectClient
|
||||
from azure.ai.projects.models import (
|
||||
MCPTool,
|
||||
PromptAgentDefinition,
|
||||
PromptAgentDefinitionText,
|
||||
RaiConfig,
|
||||
)
|
||||
from azure.ai.projects.models import MCPTool, PromptAgentDefinition, PromptAgentDefinitionText, RaiConfig, Reasoning
|
||||
from azure.core.credentials_async import AsyncTokenCredential
|
||||
from azure.core.exceptions import ResourceNotFoundError
|
||||
from pydantic import ValidationError
|
||||
@@ -51,12 +46,15 @@ else:
|
||||
logger = get_logger("agent_framework.azure")
|
||||
|
||||
|
||||
class AzureAIProjectAgentOptions(OpenAIResponsesOptions):
|
||||
class AzureAIProjectAgentOptions(OpenAIResponsesOptions, total=False):
|
||||
"""Azure AI Project Agent options."""
|
||||
|
||||
rai_config: RaiConfig
|
||||
"""Configuration for Responsible AI (RAI) content filtering and safety features."""
|
||||
|
||||
reasoning: Reasoning # type: ignore[misc]
|
||||
"""Configuration for enabling reasoning capabilities (requires azure.ai.projects.models.Reasoning)."""
|
||||
|
||||
|
||||
TAzureAIClientOptions = TypeVar(
|
||||
"TAzureAIClientOptions",
|
||||
@@ -343,6 +341,10 @@ class AzureAIClient(OpenAIBaseResponsesClient[TAzureAIClientOptions], Generic[TA
|
||||
args["temperature"] = run_options["temperature"]
|
||||
if "top_p" in run_options:
|
||||
args["top_p"] = run_options["top_p"]
|
||||
if "reasoning" in run_options:
|
||||
args["reasoning"] = run_options["reasoning"]
|
||||
if "rai_config" in run_options:
|
||||
args["rai_config"] = run_options["rai_config"]
|
||||
|
||||
# response_format is accessed from chat_options or additional_properties
|
||||
# since the base class excludes it from run_options
|
||||
@@ -408,6 +410,7 @@ class AzureAIClient(OpenAIBaseResponsesClient[TAzureAIClientOptions], Generic[TA
|
||||
"top_p",
|
||||
"text",
|
||||
"text_format",
|
||||
"reasoning",
|
||||
]
|
||||
|
||||
for property in exclude:
|
||||
|
||||
@@ -195,6 +195,7 @@ class AzureAIProjectAgentProvider(Generic[TOptions_co]):
|
||||
opts = dict(default_options) if default_options else {}
|
||||
response_format = opts.get("response_format")
|
||||
rai_config = opts.get("rai_config")
|
||||
reasoning = opts.get("reasoning")
|
||||
|
||||
args: dict[str, Any] = {"model": resolved_model}
|
||||
|
||||
@@ -206,6 +207,8 @@ class AzureAIProjectAgentProvider(Generic[TOptions_co]):
|
||||
)
|
||||
if rai_config:
|
||||
args["rai_config"] = rai_config
|
||||
if reasoning:
|
||||
args["reasoning"] = reasoning
|
||||
|
||||
# Normalize tools and separate MCP tools from other tools
|
||||
normalized_tools = normalize_tools(tools)
|
||||
|
||||
Reference in New Issue
Block a user