Python: openai updates (#388)

* openai updates

* rebuild of openai structure

* updated responses structure

* renamed sample

* added file id support to code interpreter

* added hosted file ids to code interpretor

* mypy fixes

* removed default az cred from codebase

* updated agent name setup

* added kwargs to entra methods

* and further kwargs

* extra comment

* updated all samples

* readded custom get methods for responses

* updated int tests with ad credential

* missed one
This commit is contained in:
Eduard van Valkenburg
2025-08-12 08:14:22 +02:00
committed by GitHub
Unverified
parent 19676978e9
commit df9d85d1f0
53 changed files with 1668 additions and 1470 deletions
@@ -4,8 +4,8 @@ import asyncio
from random import randint
from typing import Annotated
from agent_framework import ChatClientAgent
from agent_framework.azure import AzureChatClient
from azure.identity import DefaultAzureCredential
from pydantic import Field
@@ -22,8 +22,7 @@ async def non_streaming_example() -> None:
print("=== Non-streaming Response Example ===")
# Create agent with Azure Chat Client
agent = ChatClientAgent(
chat_client=AzureChatClient(),
agent = AzureChatClient(ad_credential=DefaultAzureCredential()).create_agent(
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -39,8 +38,7 @@ async def streaming_example() -> None:
print("=== Streaming Response Example ===")
# Create agent with Azure Chat Client
agent = ChatClientAgent(
chat_client=AzureChatClient(),
agent = AzureChatClient(ad_credential=DefaultAzureCredential()).create_agent(
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -7,6 +7,7 @@ from typing import Annotated
from agent_framework import ChatClientAgent
from agent_framework.azure import AzureChatClient
from azure.identity import DefaultAzureCredential
from pydantic import Field
@@ -31,7 +32,7 @@ async def tools_on_agent_level() -> None:
# Tools are provided when creating the agent
# The agent can use these tools for any query during its lifetime
agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a helpful assistant that can provide weather and time information.",
tools=[get_weather, get_time], # Tools defined at agent creation
)
@@ -61,7 +62,7 @@ async def tools_on_run_level() -> None:
# Agent created without tools
agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a helpful assistant.",
# No tools defined here
)
@@ -91,7 +92,7 @@ async def mixed_tools_example() -> None:
# Agent created with some base tools
agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a comprehensive assistant that can help with various information requests.",
tools=[get_weather], # Base tool available for all queries
)
@@ -6,6 +6,7 @@ from typing import Annotated
from agent_framework import ChatClientAgent, ChatClientAgentThread
from agent_framework.azure import AzureChatClient
from azure.identity import DefaultAzureCredential
from pydantic import Field
@@ -22,7 +23,7 @@ async def example_with_automatic_thread_creation() -> None:
print("=== Automatic Thread Creation Example ===")
agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -47,7 +48,7 @@ async def example_with_thread_persistence() -> None:
print("Using the same thread across multiple conversations to maintain context.\n")
agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -80,7 +81,7 @@ async def example_with_existing_thread_messages() -> None:
print("=== Existing Thread Messages Example ===")
agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)
@@ -102,7 +103,7 @@ async def example_with_existing_thread_messages() -> None:
# Create a new agent instance but use the existing thread with its message history
new_agent = ChatClientAgent(
chat_client=AzureChatClient(),
chat_client=AzureChatClient(ad_credential=DefaultAzureCredential()),
instructions="You are a helpful weather agent.",
tools=get_weather,
)