mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
91e3bbda83
Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/f70f7d19-9256-4eec-b7db-28007d74440c Co-authored-by: sphenry <6749825+sphenry@users.noreply.github.com>
31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
import asyncio
|
|
from pathlib import Path
|
|
|
|
from agent_framework.declarative import AgentFactory
|
|
from azure.identity.aio import AzureCliCredential
|
|
from dotenv import load_dotenv
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv()
|
|
|
|
|
|
async def main():
|
|
"""Create an agent from a declarative yaml specification and run it."""
|
|
# get the path
|
|
current_path = Path(__file__).parent
|
|
yaml_path = current_path.parent.parent.parent.parent / "declarative-agents" / "agent-samples" / "foundry" / "MicrosoftLearnAgent.yaml"
|
|
# create the agent from the yaml
|
|
async with (
|
|
AzureCliCredential() as credential,
|
|
AgentFactory(client_kwargs={"credential": credential}, safe_mode=False).create_agent_from_yaml_path(
|
|
yaml_path
|
|
) as agent,
|
|
):
|
|
response = await agent.run("How do I create a storage account with private endpoint using bicep?")
|
|
print("Agent response:", response.text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|