fix: move example scripts to right folders#164
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
This pull request focuses on correcting the file paths for example scripts within the repository. The primary change involves moving the openai_client.py and openai_javelin_stream&non-stream.js files to their appropriate directories. This adjustment ensures that the example scripts are organized correctly, which improves the overall structure and maintainability of the project.
Highlights
- File Path Correction: The example scripts are moved to their correct directories to maintain proper project structure.
- JavaScript Client Update: The JavaScript example script is updated to use
openai_clientinstead ofopenai. - Base URL Correction: The JavaScript example script's base URL is corrected from
hhttps://api.javelin.live/v1/querytohttps://api.javelin.live/v1/query.
Changelog
- examples/openai/openai_client.py
- The entire file
examples/openai/openai_client.pyis new, containing various functions for interacting with OpenAI, Gemini, Azure OpenAI, DeepSeek, and Mistral models. It includes functionalities such as chat completions, embeddings, streaming chats, function calling, image understanding, structured output, and client registration with Javelin.
- The entire file
- examples/openai/openai_javelin_stream&non-stream.js
- The variable name
openaiis changed toopenai_clientto align with the intended usage. - The base URL is corrected from
hhttps://api.javelin.live/v1/querytohttps://api.javelin.live/v1/queryto ensure proper API endpoint resolution.
- The variable name
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.
In directories deep, where scripts reside,
A path astray, a coder's guide.
With careful move and steady hand,
Order restored, across the land.
Examples aligned, a clearer view,
For future coders, seeing it through.
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 focuses on moving example scripts to the correct folders and updating the OpenAI client initialization in the JavaScript example. The changes in the Python script involve adding several functions to interact with different OpenAI models and registering them with the Javelin client. The JavaScript file updates the client initialization and fixes a typo in the base URL. Overall, the changes seem reasonable, but there are a few areas that could be improved.
Summary of Findings
- Inconsistent client initialization: The Python script initializes the Javelin client globally and then re-initializes it within some functions. This could lead to confusion and potential issues if the configurations are different. Consider using the global client instance consistently.
- Hardcoded API keys: The JavaScript example still contains placeholders for API keys. Ensure these are replaced with environment variables or a secure configuration mechanism before merging.
- Missing error handling: The Python script lacks specific error handling for API calls. Adding try-except blocks with appropriate logging would improve the robustness of the examples.
Merge Readiness
The pull request is not quite ready for merging. The hardcoded API keys in the JavaScript example and the inconsistent client initialization in the Python script need to be addressed. Additionally, adding error handling to the Python script would improve its robustness. I am unable to approve this pull request, and recommend that the author address the issues raised before merging. It is also recommended that others review and approve this code before merging.
|
|
||
| const openai = new OpenAI({ | ||
| const openai_client = new OpenAI({ | ||
| apiKey: "", // add your api key |
There was a problem hiding this comment.
| # Initialize Javelin Client | ||
| def initialize_javelin_client(): | ||
| config = JavelinConfig( | ||
| base_url=javelin_base_url, | ||
| javelin_api_key=javelin_api_key, | ||
| ) | ||
| return JavelinClient(config) |
| else: | ||
| raise Exception(f"Failed to download image: {response.status_code}") |
There was a problem hiding this comment.
No description provided.