-
Notifications
You must be signed in to change notification settings - Fork 180
feat: add azure model provider #184
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
Conversation
🦋 Changeset detectedLatest commit: f9208d2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Caution Review failedThe pull request is closed. WalkthroughThis update introduces Azure OpenAI as a new model provider, significantly enhancing the system's capabilities for model management and deployment. Key changes include Azure-specific configuration settings, user interaction for model selection, and expanded dependency management. These enhancements improve flexibility and scalability, enabling users to effectively leverage Azure’s infrastructure for their machine learning applications. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AzureConfig
participant ModelAPI
User->>AzureConfig: Request Azure model setup
AzureConfig->>User: Prompt for API Key & Model selection
User->>AzureConfig: Provide API Key & select model
AzureConfig->>ModelAPI: Initialize Azure model with provided settings
ModelAPI-->>AzureConfig: Confirm model setup
AzureConfig-->>User: Azure model is ready for use
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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.
Actionable comments posted: 2
Outside diff range, codebase verification and nitpick comments (2)
templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (1)
73-96
: Ensure all required environment variables are set and validated.The function
initAzureOpenAI
relies on several environment variables. While these variables are used in the codebase, comprehensive validation for all required environment variables is not evident. Ensure thatAZURE_OPENAI_KEY
,AZURE_OPENAI_ENDPOINT
,AZURE_OPENAI_API_VERSION
, andAZURE_OPENAI_DEPLOYMENT
are properly validated to avoid runtime errors.
helpers/providers/azure.ts
contains a validation check forAZURE_OPENAI_KEY
. Similar checks should be implemented for the other required environment variables.Analysis chain
Ensure all required environment variables are set and validated.
The function
initAzureOpenAI
relies on several environment variables. Ensure that these variables are set and validated to avoid runtime errors.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all required environment variables for Azure OpenAI are set. # Test: Check for the presence of required environment variables. Expect: All variables are set. env | grep -E 'AZURE_OPENAI_KEY|AZURE_OPENAI_ENDPOINT|AZURE_OPENAI_API_VERSION|AZURE_OPENAI_DEPLOYMENT'Length of output: 105
Script:
#!/bin/bash # Description: Search for the usage and validation of required environment variables in the codebase. # Search for the usage of AZURE_OPENAI_KEY, AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_VERSION, and AZURE_OPENAI_DEPLOYMENT in the codebase. rg 'process\.env\.(AZURE_OPENAI_KEY|AZURE_OPENAI_ENDPOINT|AZURE_OPENAI_API_VERSION|AZURE_OPENAI_DEPLOYMENT)' -A 3Length of output: 2259
templates/types/streaming/express/src/controllers/engine/settings.ts (1)
73-96
: Ensure all required environment variables are validated.The function
initAzureOpenAI
relies on several environment variables. WhileAZURE_OPENAI_KEY
has a validation check, the environment variablesAZURE_OPENAI_ENDPOINT
,AZURE_OPENAI_API_VERSION
, andAZURE_OPENAI_DEPLOYMENT
do not have any validation checks in the codebase. To avoid potential runtime errors, please add validation checks for these variables.
AZURE_OPENAI_ENDPOINT
AZURE_OPENAI_API_VERSION
AZURE_OPENAI_DEPLOYMENT
Analysis chain
Ensure all required environment variables are set and validated.
The function
initAzureOpenAI
relies on several environment variables. Ensure that these variables are set and validated to avoid runtime errors.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify all required environment variables for Azure OpenAI are set. # Test: Check for the presence of required environment variables. Expect: All variables are set. env | grep -E 'AZURE_OPENAI_KEY|AZURE_OPENAI_ENDPOINT|AZURE_OPENAI_API_VERSION|AZURE_OPENAI_DEPLOYMENT'Length of output: 105
Script:
#!/bin/bash # Description: Search for the initialization and usage of required environment variables in the codebase. # Search for AZURE_OPENAI_KEY rg 'AZURE_OPENAI_KEY' # Search for AZURE_OPENAI_ENDPOINT rg 'AZURE_OPENAI_ENDPOINT' # Search for AZURE_OPENAI_API_VERSION rg 'AZURE_OPENAI_API_VERSION' # Search for AZURE_OPENAI_DEPLOYMENT rg 'AZURE_OPENAI_DEPLOYMENT'Length of output: 2167
Script:
#!/bin/bash # Description: Search for validation and fallback mechanisms for required environment variables in the codebase. # Search for validation of AZURE_OPENAI_KEY rg 'if.*process.env.AZURE_OPENAI_KEY' # Search for validation of AZURE_OPENAI_ENDPOINT rg 'if.*process.env.AZURE_OPENAI_ENDPOINT' # Search for validation of AZURE_OPENAI_API_VERSION rg 'if.*process.env.AZURE_OPENAI_API_VERSION' # Search for validation of AZURE_OPENAI_DEPLOYMENT rg 'if.*process.env.AZURE_OPENAI_DEPLOYMENT'Length of output: 254
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- .changeset/smooth-points-float.md (1 hunks)
- helpers/env-variables.ts (1 hunks)
- helpers/providers/azure.ts (1 hunks)
- helpers/providers/index.ts (3 hunks)
- helpers/python.ts (1 hunks)
- helpers/types.ts (1 hunks)
- templates/components/settings/python/settings.py (3 hunks)
- templates/types/streaming/express/src/controllers/engine/settings.ts (3 hunks)
- templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (2 hunks)
Additional context used
Biome
templates/types/streaming/nextjs/app/api/chat/engine/settings.ts
[error] 48-49: This case is falling through to the next case.
Add a
break
orreturn
statement to the end of this case to prevent fallthrough.(lint/suspicious/noFallthroughSwitchClause)
templates/types/streaming/express/src/controllers/engine/settings.ts
[error] 48-49: This case is falling through to the next case.
Add a
break
orreturn
statement to the end of this case to prevent fallthrough.(lint/suspicious/noFallthroughSwitchClause)
Additional comments not posted (16)
.changeset/smooth-points-float.md (1)
1-5
: LGTM!The changeset metadata is accurate and follows the expected format.
helpers/types.ts (1)
11-11
: LGTM!The new option
"azure"
is correctly added to theModelProvider
type.helpers/providers/index.ts (3)
6-6
: LGTM!The new import statement for
askAzureQuestions
is correctly added.
38-38
: LGTM!The new entry for Azure OpenAI is correctly added to the choices array.
74-76
: LGTM!The new case for Azure OpenAI is correctly added to the switch statement.
templates/types/streaming/express/src/controllers/engine/settings.ts (1)
60-60
: LGTM!The default model in the
initOpenAI
function has been correctly updated to "gpt-3.5-turbo".helpers/providers/azure.ts (3)
6-29
: LGTM!The
ALL_AZURE_OPENAI_CHAT_MODELS
object correctly maps Azure model names to their corresponding OpenAI model names.
31-50
: LGTM!The
ALL_AZURE_OPENAI_EMBEDDING_MODELS
object correctly maps Azure embedding model names to their corresponding OpenAI model names and dimensions.
55-128
: LGTM! But verify user input handling.The
askAzureQuestions
function is correctly implemented. However, ensure that the prompts handle user input and validation correctly.Verification successful
LGTM! But verify user input handling.
The
askAzureQuestions
function is correctly implemented. The validation logic for user input is present. However, ensure that it correctly handles the scenario whereaskModels
is true and theAZURE_OPENAI_KEY
environment variable is not set.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the user input handling in `askAzureQuestions`. # Test: Check for the presence of input validation logic. Expect: Input validation logic is present. rg --type ts 'validate' helpers/providers/azure.tsLength of output: 89
templates/components/settings/python/settings.py (5)
78-78
: Ensure environment variableMODEL
is set.The variable
model
is directly assigned from the environment variable without a default value. Ensure thatMODEL
is set in the environment to avoid potential issues.
80-83
: Ensure environment variableAZURE_OPENAI_API_VERSION
orOPENAI_API_VERSION
is set.The
api_version
variable is assigned from two possible environment variables. Ensure that at least one of these is set to avoid potential issues.
86-92
: LGTM! Generalized configuration structure improves flexibility.The introduction of the
azure_config
dictionary encapsulates Azure-specific settings, improving the modularity and readability of the code.
94-99
: LGTM! Centralized configuration approach for LLM settings.The
llm_config
dictionary now includes Azure-specific settings along withmax_tokens
andtemperature
, enhancing the clarity and maintainability of the code.
105-108
: LGTM! Centralized configuration approach for embedding settings.The
embedding_config
dictionary now includes Azure-specific settings along withdimensions
, enhancing the clarity and maintainability of the code.helpers/python.ts (1)
196-205
: LGTM! Azure-specific dependencies added correctly.The new case for handling "azure" appends the necessary dependencies to the
dependencies
array, ensuring that the Azure provider is supported.helpers/env-variables.ts (1)
277-297
: LGTM! Azure-specific environment variables added correctly.The new conditional block for handling "azure" appends the necessary environment variables to the existing configuration, ensuring that the Azure provider is supported.
templates/types/streaming/express/src/controllers/engine/settings.ts
Outdated
Show resolved
Hide resolved
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (5)
- helpers/env-variables.ts (1 hunks)
- helpers/providers/index.ts (3 hunks)
- helpers/python.ts (1 hunks)
- helpers/types.ts (1 hunks)
- templates/components/settings/python/settings.py (3 hunks)
Files skipped from review as they are similar to previous changes (4)
- helpers/providers/index.ts
- helpers/python.ts
- helpers/types.ts
- templates/components/settings/python/settings.py
Additional comments not posted (1)
helpers/env-variables.ts (1)
277-301
: LGTM! Ensure Azure OpenAI environment variables are correctly utilized.The code changes are approved.
However, ensure that all the newly added Azure OpenAI environment variables are correctly utilized in the codebase.
Verification successful
Azure OpenAI environment variables are correctly utilized.
The environment variables
AZURE_OPENAI_KEY
,AZURE_OPENAI_ENDPOINT
,AZURE_OPENAI_API_VERSION
,AZURE_OPENAI_LLM_DEPLOYMENT
, andAZURE_OPENAI_EMBEDDING_DEPLOYMENT
are appropriately used throughout the codebase.
- Files with usage:
templates/components/settings/python/settings.py
templates/types/streaming/express/src/controllers/engine/settings.ts
templates/types/streaming/nextjs/app/api/chat/engine/settings.ts
helpers/providers/azure.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of Azure OpenAI environment variables in the codebase. # Test: Search for the usage of Azure OpenAI environment variables. Expect: Correct utilization in the codebase. rg --type python -A 5 $'AZURE_OPENAI_KEY|AZURE_OPENAI_ENDPOINT|AZURE_OPENAI_API_VERSION|AZURE_OPENAI_LLM_DEPLOYMENT|AZURE_OPENAI_EMBEDDING_DEPLOYMENT'Length of output: 182
Script:
#!/bin/bash # Description: Verify the usage of Azure OpenAI environment variables in the codebase. # Test: Search for the usage of Azure OpenAI environment variables. Expect: Correct utilization in the codebase. rg -A 5 'AZURE_OPENAI_KEY|AZURE_OPENAI_ENDPOINT|AZURE_OPENAI_API_VERSION|AZURE_OPENAI_LLM_DEPLOYMENT|AZURE_OPENAI_EMBEDDING_DEPLOYMENT'Length of output: 6210
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- templates/types/streaming/express/src/controllers/engine/settings.ts (3 hunks)
- templates/types/streaming/nextjs/app/api/chat/engine/settings.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- templates/types/streaming/express/src/controllers/engine/settings.ts
- templates/types/streaming/nextjs/app/api/chat/engine/settings.ts
98feb92
to
9050e19
Compare
Summary by CodeRabbit
New Features
Bug Fixes
Documentation