feat: update universal endpoint scripts#195
Conversation
There was a problem hiding this comment.
Hello @abhijitjavelin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Hello! Gemini or gemini-code-assist here, providing a summary of this pull request to help everyone get up to speed quickly.
This pull request, titled "feat: update universal endpoint scripts", appears to focus on refining how providers (like OpenAI, Azure OpenAI, and Bedrock) are registered with the Javelin client, particularly in the context of "universal endpoints". The changes involve simplifying the registration calls in example scripts by removing the explicit route_name parameter and adjusting the SDK's internal logic to handle default route names. Additionally, new fields related to secret management have been added to the Secret model.
Highlights
- SDK Registration Logic Updates: The Javelin SDK's
register_providermethod now defaults theroute_nameif not explicitly provided. Specifically for Bedrock, if noroute_nameis given, it will default to "amazon". Thex-javelin-providerheader setting based on the base URL has also been removed from theregister_providermethod. - Secret Model Enhancements: The
Secretmodel has been updated to include a newSecretTypeenum (AWS, KUBERNETES) and two new fields:secret_nameandsecrets_provider, indicating the name and type of the secret source.
Changelog
Click here to see the changelog
- examples/azure-openai/azure-universal.py
- Updated the
AzureOpenAIclient initialization to specifyapi_version="2023-09-15-preview"and removed other parameters (lines 34-37). - Removed the
route_nameargument from thejavelin_client.register_azureopenaicall (line 40).
- Updated the
- examples/bedrock/bedrock_client_universal.py
- Removed the
route_nameargument from thejavelin_client.register_bedrockcall (line 29).
- Removed the
- examples/openai/openai-universal.py
- Removed the
route_nameargument from theclient.register_openaicall (line 42).
- Removed the
- javelin_sdk/client.py
- Removed the line setting the
x-javelin-providerheader based on the base URL inregister_provider(line 202). - Added logic in
register_providerto defaultroute_nametoprovider_nameifroute_nameis not provided (line 202). - Changed the default value for the
route_nameparameter inregister_openaiandregister_azureopenaimethods fromNoneto""(lines 524, 529). - Changed the default value for the
route_nameparameter in theregister_bedrockmethod fromNoneto""(line 549). - Added logic within
register_bedrockto explicitly setroute_nameto "amazon" if it is not provided (lines 585-586).
- Removed the line setting the
- javelin_sdk/models.py
- Added the
SecretTypeenum with values "aws" and "kubernetes" (lines 353-355). - Added
secret_nameandsecrets_providerfields to theSecretmodel (lines 373-374).
- Added the
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
A route name removed,
Default logic improved,
Secrets now typed,
Code neatly swiped,
Universal path approved.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Code Review
The pull request updates the universal endpoint scripts, primarily focusing on simplifying the registration process for different providers (Azure OpenAI, Bedrock, OpenAI) by removing the explicit route_name parameter in the registration methods and providing a default route name. Additionally, it introduces a SecretType enum and updates the Secret model to include secret_name and secrets_provider fields.
Summary of Findings
- Default Route Names: The
route_nameparameter is removed from the registration methods, and default route names are used. Ensure that these defaults are appropriate for all use cases, or provide configuration options for users to override them. - SecretType Default: The
secrets_providerfield defaults toSecretType.KUBERNETES. Verify that this is the most common or appropriate default. - Azure OpenAI Configuration: The
azure_endpointandapi_keyparameters are removed from theAzureOpenAIinitialization. Ensure that these values are now being sourced from environment variables or another configuration mechanism, and that appropriate checks are in place to handle missing values.
Merge Readiness
The pull request introduces useful simplifications and enhancements. However, it's important to ensure that the default route names and secret provider are appropriate for all use cases, and that the Azure OpenAI configuration is handled correctly. I would recommend addressing these points before merging. I am unable to directly approve this pull request, and other reviewers should also review this code before merging.
| def register_openai(self, openai_client: Any, route_name: str = "") -> Any: | ||
| return self.register_provider( | ||
| openai_client, provider_name="openai", route_name=route_name | ||
| ) | ||
|
|
||
| def register_azureopenai(self, openai_client: Any, route_name: str = None) -> Any: | ||
| def register_azureopenai(self, openai_client: Any, route_name: str = "") -> Any: | ||
| return self.register_provider( | ||
| openai_client, provider_name="azureopenai", route_name=route_name | ||
| ) |
There was a problem hiding this comment.
The default value for route_name in register_openai and register_azureopenai is changed from None to "". While this aligns with the intention of using a default route name, it might be more explicit to keep it as None and handle the default assignment within the register_provider method. This would centralize the logic for default route name assignment.
| def register_openai(self, openai_client: Any, route_name: str = "") -> Any: | |
| return self.register_provider( | |
| openai_client, provider_name="openai", route_name=route_name | |
| ) | |
| def register_azureopenai(self, openai_client: Any, route_name: str = None) -> Any: | |
| def register_azureopenai(self, openai_client: Any, route_name: str = "") -> Any: | |
| return self.register_provider( | |
| openai_client, provider_name="azureopenai", route_name=route_name | |
| ) | |
| def register_openai(self, openai_client: Any, route_name: str = None) -> Any: | |
| return self.register_provider( | |
| openai_client, provider_name="openai", route_name=route_name | |
| ) | |
| def register_azureopenai(self, openai_client: Any, route_name: str = None) -> Any: | |
| return self.register_provider( | |
| openai_client, provider_name="azureopenai", route_name=route_name | |
| ) |
| secret_name: str = Field(default=None, description="Secret Name of the Secret") | ||
| secrets_provider: SecretType = Field(default=SecretType.KUBERNETES, description="Type of the secret: aws or kubernetes") |
No description provided.