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
@@ -5,6 +5,7 @@ from random import randint
from typing import Annotated
from agent_framework.azure import AzureAssistantsClient
from azure.identity import DefaultAzureCredential
from pydantic import Field
@@ -17,7 +18,7 @@ def get_weather(
async def main() -> None:
async with AzureAssistantsClient() as client:
async with AzureAssistantsClient(ad_credential=DefaultAzureCredential()) as client:
message = "What's the weather in Amsterdam and in Paris?"
stream = False
print(f"User: {message}")
@@ -5,6 +5,7 @@ from random import randint
from typing import Annotated
from agent_framework.azure import AzureChatClient
from azure.identity import DefaultAzureCredential
from pydantic import Field
@@ -17,7 +18,7 @@ def get_weather(
async def main() -> None:
client = AzureChatClient()
client = AzureChatClient(ad_credential=DefaultAzureCredential())
message = "What's the weather in Amsterdam and in Paris?"
stream = False
print(f"User: {message}")
@@ -5,6 +5,7 @@ from random import randint
from typing import Annotated
from agent_framework.azure import AzureResponsesClient
from azure.identity import DefaultAzureCredential
from pydantic import Field
@@ -17,7 +18,7 @@ def get_weather(
async def main() -> None:
client = AzureResponsesClient()
client = AzureResponsesClient(ad_credential=DefaultAzureCredential())
message = "What's the weather in Amsterdam and in Paris?"
stream = False
print(f"User: {message}")
@@ -5,6 +5,7 @@ from random import randint
from typing import Annotated
from agent_framework.foundry import FoundryChatClient
from azure.identity.aio import DefaultAzureCredential
from pydantic import Field
@@ -17,7 +18,7 @@ def get_weather(
async def main() -> None:
async with FoundryChatClient() as client:
async with FoundryChatClient(async_ad_credential=DefaultAzureCredential()) as client:
message = "What's the weather in Amsterdam and in Paris?"
stream = False
print(f"User: {message}")
@@ -19,13 +19,13 @@ def get_weather(
async def main() -> None:
client = OpenAIChatClient()
message = "What's the weather in Amsterdam and in Paris?"
stream = False
stream = True
print(f"User: {message}")
if stream:
print("Assistant: ", end="")
async for chunk in client.get_streaming_response(message, tools=get_weather):
if str(chunk):
print(str(chunk), end="")
if chunk.text:
print(chunk.text, end="")
print("")
else:
response = await client.get_response(message, tools=get_weather)
@@ -17,15 +17,15 @@ def get_weather(
async def main() -> None:
client = OpenAIResponsesClient(ai_model_id="gpt-4o-mini")
client = OpenAIResponsesClient()
message = "What's the weather in Amsterdam and in Paris?"
stream = False
print(f"User: {message}")
if stream:
print("Assistant: ", end="")
async for chunk in client.get_streaming_response(message, tools=get_weather):
if str(chunk):
print(str(chunk), end="")
if chunk.text:
print(chunk.text, end="")
print("")
else:
response = await client.get_response(message, tools=get_weather)