Files
agent-framework/python/samples/getting_started/declarative/openai_responses_agent.py
T
Eduard van Valkenburg 92df9e14bf Python: Introducing support for declarative yaml spec (#2002)
* first work on declarative

* initial version of the declarative support

* fix tests and mypy

* fix parameters of functiontool

* slight logic improvement

* remove path until merge

* updates from comments

* create dispatcher and spec type, json_schema method

* fix mypy, skipping model

* updated lock

* fixed declarative tests and renamed some other test files

* refined loader

* updated lock

* fix mypy

* added readme to samples folder

* fixes from review

* undid test file rename
2025-11-19 16:33:02 +00:00

27 lines
795 B
Python

# Copyright (c) Microsoft. All rights reserved.
import asyncio
from pathlib import Path
from agent_framework.declarative import AgentFactory
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 / "agent-samples" / "openai" / "OpenAIResponses.yaml"
# load the yaml from the path
with yaml_path.open("r") as f:
yaml_str = f.read()
# create the agent from the yaml
agent = AgentFactory().create_agent_from_yaml(yaml_str)
# use the agent
response = await agent.run("Why is the sky blue, answer in Dutch?")
print("Agent response:", response.value)
if __name__ == "__main__":
asyncio.run(main())