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.