-
Notifications
You must be signed in to change notification settings - Fork 73
Create Python ChatApp example for AI configuration #1065
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
base: main
Are you sure you want to change the base?
Conversation
I've updated the description, this should be a console app, so Flask isn't needed. |
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
I've converted the app from a Flask web application to a console app similar to the .NET Core implementation. The changes include removing Flask dependencies, implementing a console-based interface with a continuous loop, and updating the documentation. All templates have been removed since they're not needed for a console app. See commit caf9cd0. |
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
examples/Python/ChatApp/app.py
Outdated
index, prop = parts | ||
if index not in message_configs: | ||
message_configs[index] = {} | ||
message_configs[index][prop.lower()] = config[key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrm9084 is there a way to do data binding so users don't need to parse configuration manually like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented data binding for the configuration using Pydantic in 6466ad8. This approach allows us to bind configuration values directly to model classes without manual parsing. The implementation includes a bind_config_section
utility function that automatically maps configuration values to Pydantic models, handling nested structures like the messages list. This makes the code more maintainable and eliminates the manual parsing previously done in the get_model_configuration
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented the data binding functionality without using an external dependency. The solution uses plain Python classes with type annotations and from_dict methods to handle the configuration binding. The bind_config_section function now works with standard Python classes instead of Pydantic models, while maintaining the same functionality for binding nested structures like messages. See commit d377f84.
Co-authored-by: zhenlan <10566826+zhenlan@users.noreply.github.com>
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
Co-authored-by: zhenlan <10566826+zhenlan@users.noreply.github.com>
Co-authored-by: zhenlan <10566826+zhenlan@users.noreply.github.com>
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
…redential Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
I've fixed the auth and model issues. But the app doesn't actually take in user input to chat. |
Co-authored-by: mrm9084 <1054559+mrm9084@users.noreply.github.com>
I've implemented user input functionality for the chat application in 00136bd. Now the app allows users to have a continuous conversation with the AI model. The app displays the initial messages from the configuration, gets an AI response, and then prompts the user for input. The conversation history is maintained throughout the session while still refreshing configuration parameters at the beginning of each cycle. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a Python ChatApp sample that mirrors the .NET Core ChatApp sample, enabling chat interactions via both web and console interfaces.
- Implements a Flask-based application that integrates Azure App Configuration and Azure OpenAI.
- Defines model classes for messages and model configurations with dynamic configuration refresh support.
- Includes updated dependency declarations and comprehensive setup documentation.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
examples/Python/ChatApp/requirements.txt | Added necessary dependencies for Azure and OpenAI integration |
examples/Python/ChatApp/models.py | Added data model classes for Message and ModelConfiguration |
examples/Python/ChatApp/app.py | Implemented Flask app with configuration refresh and chat logic |
examples/Python/ChatApp/README.md | Documented setup, usage instructions, and configuration details |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR adds a Python ChatApp example that mirrors the functionality of the .NET Core ChatApp sample for AI configuration.
Key Features
azure-appconfiguration-provider
for configuration managementImplementation Details
Message
andModelConfiguration
classesFiles Added
app.py
- Main Flask application with Azure OpenAI integrationmodels.py
- Contains data model classes for Message and ModelConfigurationrequirements.txt
- Dependencies with latest stable versionsREADME.md
- Setup and usage documentationtemplates/
- HTML templates for the web interfaceFixes #1064.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.