Skip to content

Commit 1950057

Browse files
author
Maryanne Gichohi
committed
Add AI Agent sample console app
1 parent fea7f99 commit 1950057

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import asyncio
2+
import os
3+
from agent_framework.declarative import AgentFactory
4+
from azure.identity.aio import AzureCliCredential
5+
from azure.identity import DefaultAzureCredential
6+
from azure.appconfiguration.provider import load
7+
8+
async def main():
9+
endpoint = os.environ["APP_CONFIGURATION_ENDPOINT"]
10+
credential = DefaultAzureCredential()
11+
12+
config = load(endpoint=endpoint, credential=credential)
13+
14+
yaml_str = config["Agent:Spec"]
15+
16+
async with (
17+
AzureCliCredential() as credential,
18+
AgentFactory(client_kwargs={"async_credential": credential, "project_endpoint": config["Agent:ProjectEndpoint"]}).create_agent_from_yaml(yaml_str) as agent,
19+
):
20+
while True:
21+
print("How can I help? (type 'quit' to exit)")
22+
23+
user_input = input("User: ")
24+
25+
if user_input.lower() in ['quit', 'exit', 'bye']:
26+
break
27+
28+
response = await agent.run(user_input)
29+
print("Agent response: ", response.text)
30+
input("Press enter to continue...")
31+
32+
print("Exiting... Goodbye...")
33+
34+
if __name__ == "__main__":
35+
asyncio.run(main())
196 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)