Skip to content
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

Integrating Azure OpenAI and Cosmos DB with Improved Quart App Functionality #1081

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RahulVadisetty91
Copy link

@RahulVadisetty91 RahulVadisetty91 commented Sep 4, 2024

  1. Summary:
    This pull request brings in a lot of changes in the Quart application and includes the use of Azure OpenAI to generate responses and powerful Cosmos DB integration. It also has better environment and debug settings, frontend, and configurations, and model arguments for AI requests are also introduced. These updates are meant to enhance the user interaction as well as increase the overall performance of the application.

  2. Related Issues:
    These changes aim at enhancing the capacity of Quart application to incorporate AI and strengthen the database connections to deal with challenges such as poor user response and database connection problems.

  3. Discussions:
    Topics of conversation included ways of enhancing the integration of Azure OpenAI for better AI responses and proper methods of connection to Cosmos DB. It was also important to establish a robust environment with the view of ensuring that the processes of developing and debugging are easy.

  4. QA Instructions:

  • Verify the AI response endpoint by checking if the model is capable of interpreting user queries with the help of Azure OpenAI.
  • Ensure that the Cosmos DB connection is made correctly, and that error handling is done appropriately.
  • Check that the debug settings for the environment work as expected and test the frontend for new parameters introduced such as feedback and authentication.
  • Perform tests to verify that the Prepare_model_args function passes the correct arguments to the model.
  1. Merge Plan:
    Once the QA tests are done the branch will be merged into the main branch. It is advisable to ensure all environment variables are in check and well configured in production to help avert problems with the AI and database connectivity.

  2. Motivation and Context:
    The rationale for these updates is to improve on the Quart application’s ability to offer meaningful and useful information to users through the incorporation of Azure OpenAI. The usage of Cosmos DB and better debugging and configuration settings strengthens the application’s stability and the process of development. This update is intended to make the user interface more fluid and engaging to the users while at the same time, strengthening the back end of the application.

Contribution Checklist

  • I have built and tested the code locally and in a deployed app
  • For frontend changes, I have pulled the latest code from main, built the frontend, and committed all static files.
  • This is a change for all users of this app. No code or asset is specific to my use case or my organization.
  • I didn't break any existing functionality 😄

This fork updates the existing Quart application with advanced AI capabilities and improves overall functionality by integrating Azure OpenAI services. The enhancements focus on providing dynamic AI responses, refining client initialization processes, and integrating additional features to leverage artificial intelligence effectively.

 Key Updates

1. AI Integration with Azure OpenAI:
   - Added the `ask_ai` endpoint to handle POST requests for querying Azure OpenAI. This endpoint processes user questions and returns AI-generated responses using the Azure OpenAI service.
   - Implemented `init_openai_client` to configure and initialize the Azure OpenAI client, including API version checks, endpoint setup, and authentication mechanisms.

2. CosmosDB Integration:
   - Integrated CosmosDB initialization with the `init_cosmosdb_client` function, which sets up connections for chat history and feedback mechanisms if configured.
   - Included logging and exception handling to ensure robust initialization and connectivity to CosmosDB.

3. Environment and Debug Settings:
   - Added debug configuration settings based on environment variables to facilitate easier troubleshooting and development.
   - Configured a user agent string for Azure OpenAI requests to improve tracking and support.

4. Static Asset Management:
   - Implemented the `/assets/<path:path>` route to serve static assets from the `static/assets` directory, allowing for better management and delivery of frontend resources.

5. Frontend and Configuration Enhancements:
   - Updated frontend settings to include new configuration options such as feedback and authentication features based on environment settings.
   - Incorporated Microsoft Defender for Cloud integration with conditional settings based on environment variables.

6. Model Argument Preparation:
   - Added the `prepare_model_args` function to construct and prepare arguments for AI model requests, including handling user details and data sources if applicable.

Benefits
- Enhanced User Interaction: By integrating Azure OpenAI, the application can now provide intelligent and contextually relevant responses to user queries.
- Improved Debugging and Monitoring: Enhanced logging and debugging configurations make it easier to manage and troubleshoot issues.
- Flexible Configuration: Updated settings and environment-based configurations offer better control and customization of application behavior.

Usage
To utilize the new AI features:
1. Ensure that the necessary environment variables are set for Azure OpenAI and CosmosDB.
2. Access the `/ai/ask` endpoint to query the AI service and receive responses based on the provided questions.
Integrate Azure OpenAI for AI-Powered Responses
@github-actions github-actions bot added the stale label Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant