Skip to content

Conversation

xiaoton1
Copy link

Signed-off-by: Wang, Xiaotong [email protected]

Signed-off-by: Wang, Xiaotong <[email protected]>
Copy link
Contributor

Summary of Changes

Hello @xiaoton1, 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!

This pull request significantly advances the system's ability to leverage local Large Language Models and embedding services by integrating Ollama and reconfiguring the OpenAI client to point to a local endpoint. It also expands the range of supported generative models with the addition of "claude-3.7-sonnet" and enhances API robustness by making model parameters conditional. A minor frontend dependency update is also included.

Highlights

  • Local LLM Integration: Introduced configuration for an Ollama embedder and redirected the default OpenAI client base URL to a local endpoint, enabling local LLM inference.
  • New Model Support: Added "claude-3.7-sonnet" to the list of supported generator models, expanding the available language models.
  • API Configuration Robustness: Improved the handling of model parameters by making the "temperature" setting conditional, preventing potential errors when a model configuration does not explicitly define it.
  • Module Path Resolution: Modified the Python system path to ensure proper module imports, likely for local development or specific deployment environments.
  • Frontend Dependency Update: Updated the import path for a syntax highlighter style in the React frontend, aligning with modern ES module conventions.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

Footnotes

  1. 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.

@xiaoton1 xiaoton1 closed this Sep 25, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for local LLMs, primarily by adding configurations for Ollama and adjusting the OpenAI client to point to a local endpoint. The changes are a good step towards local model support, but there are a few critical issues to address. Specifically, a private IP address has been hardcoded in the OpenAIClient, which is a security and portability risk. Additionally, there's a direct manipulation of sys.path which is considered bad practice in Python. I've also included a refactoring suggestion to improve code clarity in the WebSocket handler. Addressing these points will make the implementation more robust, secure, and maintainable.

self._env_api_key_name = env_api_key_name
self._env_base_url_name = env_base_url_name
self.base_url = base_url or os.getenv(self._env_base_url_name, "https://api.openai.com/v1")
self.base_url = base_url or os.getenv(self._env_base_url_name, "http://10.239.142.219:8012/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

Hardcoding a private IP address as a default value is a critical issue. It makes the application non-portable, difficult to configure for other developers or deployment environments, and leaks internal network details. It's much better to use a generic, safe default like localhost or not provide a default at all, forcing the configuration via the OPENAI_BASE_URL environment variable. This ensures the application is secure and easy to set up in any environment.

Suggested change
self.base_url = base_url or os.getenv(self._env_base_url_name, "http://10.239.142.219:8012/")
self.base_url = base_url or os.getenv(self._env_base_url_name, "http://localhost:8012/")

import logging
from dotenv import load_dotenv

sys.path.insert(0, os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Manipulating sys.path directly is generally discouraged as it can make dependency management fragile and code harder to understand. It can lead to issues with module resolution, especially in larger projects or when deployed in different environments. A better approach is to structure your project as a proper Python package and use relative imports, or to install it in editable mode (pip install -e .) for development. This ensures that imports are explicit and reliable.

Comment on lines 459 to +465
model_kwargs = {
"model": request.model,
"stream": True,
"temperature": model_config["temperature"]
#"temperature": model_config["temperature"]
}
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the logic to conditionally add temperature is correct, the implementation leaves a commented-out line of code. This can be confusing for future maintainers. It's cleaner to initialize the dictionary with common parameters and then conditionally add optional ones. This improves readability and maintainability.

Suggested change
model_kwargs = {
"model": request.model,
"stream": True,
"temperature": model_config["temperature"]
#"temperature": model_config["temperature"]
}
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]
model_kwargs = {
"model": request.model,
"stream": True,
}
if "temperature" in model_config:
model_kwargs["temperature"] = model_config["temperature"]

@xiaoton1 xiaoton1 reopened this Sep 25, 2025
@xiaoton1 xiaoton1 marked this pull request as draft September 25, 2025 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant