e768098d0e
tools_continuous_delivery / Private PyPI non-main branch release (push) Has been skipped
tools_continuous_delivery / Private PyPI main branch release (push) Failing after 2m42s
Publish Promptflow Doc / Build (push) Has been cancelled
Publish Promptflow Doc / Deploy (push) Has been cancelled
Flake8 Lint / flake8 (push) Has been cancelled
Spell check CI / Spell_Check (push) Has been cancelled
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
"""
|
|
Alternative client for teams using Microsoft Foundry as their model hub.
|
|
|
|
NOTE: This file demonstrates a **standalone agent test** — it uses Agent
|
|
directly without the Executor + WorkflowBuilder pattern. This is intentional
|
|
for quickly verifying Foundry connectivity. For production workflows, see the
|
|
samples in phase-2-rebuild/ which show the full Executor/WorkflowBuilder
|
|
pattern.
|
|
|
|
Use FoundryChatClient (from agent_framework.foundry) when connecting to a
|
|
Foundry project endpoint.
|
|
|
|
Prerequisites:
|
|
pip install agent-framework-foundry azure-identity
|
|
Set in .env: FOUNDRY_PROJECT_ENDPOINT, FOUNDRY_MODEL
|
|
"""
|
|
|
|
import asyncio
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
from agent_framework import Agent
|
|
from agent_framework.foundry import FoundryChatClient
|
|
from azure.identity import DefaultAzureCredential
|
|
|
|
load_dotenv()
|
|
|
|
# Endpoint format: https://<resource>.services.ai.azure.com
|
|
client = FoundryChatClient(
|
|
project_endpoint=os.environ["FOUNDRY_PROJECT_ENDPOINT"],
|
|
model=os.environ["FOUNDRY_MODEL"],
|
|
credential=DefaultAzureCredential(),
|
|
)
|
|
|
|
agent = Agent(
|
|
client=client,
|
|
name="DocQAAgent",
|
|
instructions="You are a precise document Q&A assistant.",
|
|
)
|
|
|
|
|
|
async def main():
|
|
result = await agent.run("What is the refund policy?")
|
|
print(result)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|