Skip to content

fix(sdk): pass extra_headers to validate_credentials in OAICompatLarg…#279

Open
TeemoSun wants to merge 1 commit intolanggenius:mainfrom
TeemoSun:fix/validate-credentials-extra-headers
Open

fix(sdk): pass extra_headers to validate_credentials in OAICompatLarg…#279
TeemoSun wants to merge 1 commit intolanggenius:mainfrom
TeemoSun:fix/validate-credentials-extra-headers

Conversation

@TeemoSun
Copy link

@TeemoSun TeemoSun commented Jan 8, 2026

…eLanguageModel

Ensure extra_headers are accepted by validate_credentials to support custom Host and providers requiring special headers.

Pull Request Checklist

Thank you for your contribution! Before submitting your PR, please make sure you have completed the following checks:

Compatibility Check

  • I have checked whether this change affects the backward compatibility of the plugin declared in README.md
  • I have checked whether this change affects the forward compatibility of the plugin declared in README.md
  • If this change introduces a breaking change, I have discussed it with the project maintainer and specified the release version in the README.md
  • I have described the compatibility impact and the corresponding version number in the PR description
  • I have checked whether the plugin version is updated in the README.md

Available Checks

  • Code has passed local tests
  • Relevant documentation has been updated (if necessary)

…eLanguageModel

Ensure extra_headers are accepted by validate_credentials to support
custom Host and providers requiring special headers.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @TeemoSun, 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 refines the credential validation mechanism within the SDK's OpenAI-compatible large language model interface. By enabling the validate_credentials function to accept and utilize extra_headers, it significantly enhances the flexibility and robustness of the system. This ensures that the SDK can seamlessly integrate with a broader range of LLM providers that may require specific HTTP headers for authentication or configuration, thereby improving overall adaptability.

Highlights

  • Enhanced Credential Validation: The validate_credentials method in OAICompatibleLargeLanguageModel now correctly processes extra_headers provided in the credentials.
  • Improved Provider Compatibility: This change allows the SDK to support custom Host headers and other provider-specific headers during credential validation, increasing compatibility with various OpenAI-compatible LLM providers.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

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 correctly adds support for extra_headers within the validate_credentials method, aligning its behavior with the _generate method and enhancing compatibility with various API providers that require custom headers. My review includes one suggestion to make the implementation more concise and efficient, which could also be applied to other parts of the code for consistency.

Comment on lines +176 to +181
extra_headers = credentials.get("extra_headers")
if extra_headers is not None:
headers = {
**headers,
**extra_headers,
}
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 current implementation is correct, it can be made more concise and idiomatic by using dict.update(). This approach modifies the headers dictionary in-place, which is slightly more efficient as it avoids creating a new dictionary object.

For consistency, you might consider applying the same refactoring to the _generate method where a similar pattern exists (lines 415-420).

            extra_headers = credentials.get("extra_headers")
            if extra_headers:
                headers.update(extra_headers)

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