Skip to content

Support OpenRouter as Embedder#491

Open
romanzdk wants to merge 2 commits intoAsyncFuncAI:mainfrom
romanzdk:main
Open

Support OpenRouter as Embedder#491
romanzdk wants to merge 2 commits intoAsyncFuncAI:mainfrom
romanzdk:main

Conversation

@romanzdk
Copy link

Solves #490

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the system's flexibility by integrating OpenRouter as a new embedding provider. This allows users to access a broader spectrum of embedding models, leveraging OpenRouter's unified API for diverse AI capabilities. The changes include core configuration updates and extensive documentation to ensure a smooth setup and usage experience for this new option.

Highlights

  • OpenRouter Embedder Support: Added comprehensive support for OpenRouter as a new embedding provider, allowing users to leverage its diverse range of embedding models through an OpenAI-compatible endpoint.
  • Documentation Updates: Updated README.md and api/README.md with detailed instructions on how to enable, configure, and use OpenRouter embeddings, including environment variable settings and model selection.
  • Configuration Integration: Integrated OpenRouter into the system's configuration logic (api/config.py and api/config/embedder.json) to ensure it is properly recognized and initialized alongside existing embedder types.
  • Flexible Model Selection: Provided options to change the default OpenRouter embedding model (openai/text-embedding-3-small) via embedder.json to any OpenAI-compatible model available on OpenRouter.

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

Changelog
  • README.md
    • Updated the 'Flexible Embeddings' section to list OpenRouter as a supported option.
    • Added a new row to the embedder configuration table detailing OpenRouter, its API key, and default model.
    • Introduced a dedicated section 'Using OpenRouter Embeddings' with setup instructions for .env and Docker.
    • Provided guidance on how to customize the OpenRouter embedding model via api/config/embedder.json.
    • Revised the environment variable table to clarify OPENROUTER_API_KEY requirements for embeddings and updated DEEPWIKI_EMBEDDER_TYPE options.
  • api/README.md
    • Updated the description for OPENROUTER_API_KEY to explicitly mention its requirement for OpenRouter embeddings.
    • Modified the general embedder configuration note to include openrouter as a valid DEEPWIKI_EMBEDDER_TYPE option.
  • api/config.py
    • Extended the load_embedder_config function to process embedder_openrouter client classes.
    • Modified get_embedder_config to retrieve OpenRouter-specific configurations when embedder_type is 'openrouter'.
    • Added a new function is_openrouter_embedder to check for active OpenRouter embedding usage.
    • Updated get_embedder_type to include 'openrouter' in its return values and incorporate the new is_openrouter_embedder check.
    • Included embedder_openrouter in the list of keys for updating the main configs dictionary.
  • api/config/embedder.json
    • Added a new JSON configuration block named embedder_openrouter.
    • Configured embedder_openrouter to use OpenAIClient with OpenRouter's API base URL, OPENROUTER_API_KEY, a batch size of 500, and openai/text-embedding-3-small as the default model.
  • api/tools/embedder.py
    • Updated the docstring for get_embedder to include 'openrouter' as a possible embedder_type.
    • Modified the get_embedder function to correctly select and return the embedder_openrouter configuration when specified by embedder_type or current_type.
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 adds support for OpenRouter as an embedding provider, which is a great addition. The changes include updating documentation in README.md and api/README.md, adding configuration in api/config/embedder.json, and updating the logic in api/config.py and api/tools/embedder.py to handle the new embedder type.

The changes are well-implemented. I have one suggestion for api/config.py to improve the consistency and robustness of the new is_openrouter_embedder function by making it inspect the configuration object, similar to the other embedder-checking functions. This will make the code more maintainable in the long run.

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