mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Python: updated azure ai inference sample (#5028)
* updated azure ai inference sample * openai multimodel fix * update language
This commit is contained in:
committed by
GitHub
Unverified
parent
acaadc9c45
commit
4b9856e66f
@@ -6,7 +6,7 @@ import struct
|
||||
from pathlib import Path
|
||||
|
||||
from agent_framework import Content, Message
|
||||
from agent_framework.foundry import FoundryChatClient
|
||||
from agent_framework.openai import OpenAIChatClient, OpenAIChatCompletionClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
@@ -14,6 +14,13 @@ load_dotenv()
|
||||
|
||||
ASSETS_DIR = Path(__file__).resolve().parents[2] / "shared" / "sample_assets"
|
||||
|
||||
"""
|
||||
Leverage multimodel capabilities of different models.
|
||||
|
||||
Uses the OpenAIChatClient and OpenAIChatCompletionClient to demonstrate multimodal input handling with the gpt-4o and gpt-4o-audio-preview models, respectively. The sample includes demonstrations for image, audio, and PDF inputs, showcasing how to create appropriate Content objects and send them in messages to the chat clients.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def load_sample_pdf() -> bytes:
|
||||
"""Read the bundled sample PDF for tests."""
|
||||
@@ -46,7 +53,7 @@ def create_sample_audio() -> str:
|
||||
|
||||
async def test_image() -> None:
|
||||
"""Test image analysis with OpenAI."""
|
||||
client = FoundryChatClient(model="gpt-4o")
|
||||
client = OpenAIChatClient(model="gpt-4o")
|
||||
|
||||
image_uri = create_sample_image()
|
||||
message = Message(
|
||||
@@ -63,7 +70,7 @@ async def test_image() -> None:
|
||||
|
||||
async def test_audio() -> None:
|
||||
"""Test audio analysis with OpenAI."""
|
||||
client = FoundryChatClient(model="gpt-4o-audio-preview")
|
||||
client = OpenAIChatCompletionClient(model="gpt-4o-audio-preview-2025-06-03")
|
||||
|
||||
audio_uri = create_sample_audio()
|
||||
message = Message(
|
||||
@@ -80,7 +87,7 @@ async def test_audio() -> None:
|
||||
|
||||
async def test_pdf() -> None:
|
||||
"""Test PDF document analysis with OpenAI."""
|
||||
client = FoundryChatClient(model="gpt-4o")
|
||||
client = OpenAIChatClient(model="gpt-4o")
|
||||
|
||||
pdf_bytes = load_sample_pdf()
|
||||
message = Message(
|
||||
|
||||
Reference in New Issue
Block a user