-
Notifications
You must be signed in to change notification settings - Fork 77
Add AI Agent sample console app #1115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1950057
Add AI Agent sample console app
b1204f1
Add README.md
164d85f
Address PR comments
72f7442
Improve ReadMe
f8d8936
Address PR comments
17dc90e
Address PR comments
d15b704
Include package version
31cb4d8
Update package version
0d44ce2
Add extra line
c4c90d6
Add extra line
dc02afa
Update app.py
MaryanneNjeri d1c89fb
Address comments
26d5446
Merge branch 'user/maryanne/agent_sample_app' of https://github.com/A…
62423b7
Update examples/Python/ChatAgent/README.md
MaryanneNjeri eec7227
Update examples/Python/ChatAgent/README.md
MaryanneNjeri 8159576
Include agent-framework-core with package version in requirements.txt
bff2000
Merge branch 'user/maryanne/agent_sample_app' of https://github.com/A…
9390fd3
Minor update in ReadMe
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # Azure App Configuration - AI Agent chat application | ||
|
|
||
| This sample demonstrates using Azure App Configuration to load agent YAML specifications that define AI agent behavior, prompts, and model configurations for a chat application. | ||
|
|
||
| ## Features | ||
|
|
||
| - Integrates with Azure AI Agent Framework to create a conversational AI agent | ||
| - Loads agent YAML specifications from Azure App Configuration. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Python 3.8 or later | ||
| - An Azure subscription with access to: | ||
| - Azure App Configuration service | ||
| - Microsoft Foundry project | ||
| - Required environment variables: | ||
| - `AZURE_APPCONFIGURATION_ENDPOINT`: Endpoint URL of your Azure App Configuration instance | ||
|
|
||
| ## Setup | ||
|
|
||
| 1. Clone the repository | ||
| 1. Install the required packages: | ||
|
|
||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| 1. Configure your Azure App Configuration store with the agent YAML specification: | ||
|
|
||
| ```yaml | ||
| kind: Prompt | ||
| name: WeatherAgent | ||
| description: Weather Agent | ||
| instructions: You are a helpful assistant. | ||
| model: | ||
| id: gpt-4.1 | ||
| connection: | ||
| kind: remote | ||
| ``` | ||
|
|
||
| 1. Configure your Azure App Configuration store with project endpoint: | ||
|
|
||
| ```console | ||
| Agent:ProjectEndpoint - Your Foundry project endpoint | ||
| ``` | ||
|
|
||
| 1. Set the required environment variables: | ||
|
|
||
| ```bash | ||
| export AZURE_APPCONFIGURATION_ENDPOINT="https://your-appconfig.azconfig.io" | ||
| ``` | ||
|
|
||
| ## Running the Application | ||
MaryanneNjeri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Start the console application: | ||
|
|
||
| ```bash | ||
| python app.py | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import asyncio | ||
| import os | ||
| from agent_framework.declarative import AgentFactory | ||
| from azure.identity.aio import AzureCliCredential | ||
| from azure.identity import DefaultAzureCredential | ||
| from azure.appconfiguration.provider import load | ||
|
|
||
| async def main(): | ||
| endpoint = os.environ["APP_CONFIGURATION_ENDPOINT"] | ||
MaryanneNjeri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| credential = DefaultAzureCredential() | ||
|
|
||
| config = load(endpoint=endpoint, credential=credential) | ||
|
|
||
| yaml_str = config["Agent:Spec"] | ||
MaryanneNjeri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| async with ( | ||
| AzureCliCredential() as credential, | ||
MaryanneNjeri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| AgentFactory(client_kwargs={"async_credential": credential, "project_endpoint": config["Agent:ProjectEndpoint"]}).create_agent_from_yaml(yaml_str) as agent, | ||
| ): | ||
| while True: | ||
| print("How can I help? (type 'quit' to exit)") | ||
|
|
||
| user_input = input("User: ") | ||
|
|
||
| if user_input.lower() in ['quit', 'exit', 'bye']: | ||
| break | ||
|
|
||
| response = await agent.run(user_input) | ||
| print("Agent response: ", response.text) | ||
| input("Press enter to continue...") | ||
|
|
||
| print("Exiting... Goodbye...") | ||
|
|
||
| if __name__ == "__main__": | ||
| asyncio.run(main()) | ||
MaryanneNjeri marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.