Skip to content

feat(provider) add gemini provider#1507

Merged
xieyxclack merged 20 commits intoagentscope-ai:mainfrom
ekzhu:claude/add-gemini-provider-3Gy4l
Mar 16, 2026
Merged

feat(provider) add gemini provider#1507
xieyxclack merged 20 commits intoagentscope-ai:mainfrom
ekzhu:claude/add-gemini-provider-3Gy4l

Conversation

@ekzhu
Copy link
Collaborator

@ekzhu ekzhu commented Mar 15, 2026

Description

Add Google Gemini as a built-in model provider for CoPaw, using the native google-genai SDK. This introduces a GeminiProvider with support for model discovery, connection checking, and streaming chat via AgentScope's GeminiChatModel. Pre-configured models include Gemini 3.1 Pro, Gemini 3 Flash, Gemini 3.1 Flash Lite, Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 2.5 Flash Lite, and Gemini 2.0 Flash.
Related Issue: N/A

Security Considerations: API keys are handled consistently with existing providers (stored in config, not logged).

Type of Change

  • New feature
  • Documentation

Component(s) Affected

  • Core / Backend (app, agents, config, providers, utils, local_models)
  • Console (frontend web UI)
  • Documentation (website)

Checklist

  • I ran pre-commit run --all-files locally and it passes
  • If pre-commit auto-fixed files, I committed those changes and reran checks
  • I ran tests locally (pytest or as relevant) and they pass
  • Documentation updated (if needed)
  • Ready for review

Testing

  1. Install CoPaw with pip install -e . (google-genai is now a core dependency at >=1.67.0)
  2. Configure a Gemini API key via the console (Settings → Models → Google Gemini) or CLI (copaw models config-key gemini)
  3. Set Gemini as the active LLM and verify chat works with streaming
  4. Verify model discovery returns available Gemini models

Local Verification Evidence

pre-commit run --all-files
# paste summary result

pytest
# paste summary result

Copilot AI review requested due to automatic review settings March 15, 2026 02:35
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 02:35 — with GitHub Actions Waiting
@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 expands CoPaw's capabilities by integrating Google Gemini as a first-class model provider, allowing users to leverage Google's advanced LLMs directly. Concurrently, it broadens the application's international reach by adding comprehensive Japanese and French localization, making the platform more accessible to a wider user base.

Highlights

  • Google Gemini Provider Integration: Added Google Gemini as a new built-in model provider, leveraging the native google-genai SDK for seamless integration.
  • Comprehensive Gemini Support: The Gemini provider includes support for model discovery, connection checking, and streaming chat via AgentScope's GeminiChatModel.
  • Pre-configured Gemini Models: Several Gemini models are pre-configured, including Gemini 3.1 Pro, Gemini 3 Flash, Gemini 3.1 Flash Lite, Gemini 2.5 Pro, Gemini 2.5 Flash, Gemini 2.5 Flash Lite, and Gemini 2.0 Flash.
  • Internationalization Expansion: Introduced Japanese and French translations for both the console UI and the documentation, enhancing global accessibility.

🧠 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
  • console/src/i18n.ts
    • Added import for French translation resources.
    • Included French translation resources in the i18n configuration.
  • console/src/locales/fr.json
    • Added a new file containing French localization strings for the console.
  • pyproject.toml
    • Added google-genai>=1.67.0 as a core dependency.
  • src/copaw/agents/model_factory.py
    • Added conditional import for GeminiChatFormatter and GeminiChatModel from AgentScope.
    • Mapped GeminiChatModel to its corresponding formatter in the chat model formatter map.
  • src/copaw/providers/gemini_provider.py
    • Added a new file defining the GeminiProvider class, implementing methods for connection checking, model fetching, and chat model instance retrieval using the Google Gemini API.
  • src/copaw/providers/provider_manager.py
    • Imported the new GeminiProvider.
    • Defined a list of GEMINI_MODELS with various Gemini versions.
    • Created PROVIDER_GEMINI instance with its configuration details.
    • Registered PROVIDER_GEMINI in the list of built-in providers.
    • Added logic to correctly instantiate GeminiProvider from data based on provider ID or chat model type.
  • website/public/docs/models.en.md
    • Updated the overview of supported LLM providers to explicitly mention Google Gemini.
    • Added a new dedicated section detailing the configuration steps for the Google Gemini provider.
  • website/public/docs/models.fr.md
    • Added a new file containing the French translation of the models documentation, including the Google Gemini provider section.
  • website/public/docs/models.ja.md
    • Added a new file containing the Japanese translation of the models documentation, including the Google Gemini provider section.
  • website/public/docs/models.zh.md
    • Updated the overview of supported LLM providers to explicitly mention Google Gemini.
    • Added a new dedicated section detailing the configuration steps for the Google Gemini provider.
  • website/src/i18n.ts
    • Extended the Lang type to include 'ja' (Japanese) and 'fr' (French).
    • Added Japanese and French translation resources to the website's i18n object.
  • website/src/pages/Docs.tsx
    • Added Japanese and French translations for documentation page titles.
    • Modified the logic for determining the language suffix for documentation files to support Japanese and French.
Activity
  • The pull request was created by ekzhu.
  • The changes include a new feature and documentation updates.
  • Core/Backend, Console, and Documentation components are affected.
  • The author confirmed documentation updates and marked the PR as ready for review.
  • Testing instructions were provided for installing dependencies, configuring API keys, verifying chat functionality, model discovery, and translation rendering.
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 Generative AI Prohibited Use Policy, 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 introduces a new provider for Google Gemini, including the necessary backend logic, dependency updates, and documentation. It also adds French and Japanese translations for the console and website. The implementation of the Gemini provider is solid, but I've noted a couple of areas for improvement regarding unused parameters and exception handling. Additionally, there are some minor grammatical corrections for the new French translation file.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Google Gemini as a built-in model provider for CoPaw using the native google-genai SDK, and adds Japanese and French translations for the website and console UI.

Changes:

  • Introduces GeminiProvider class with model discovery, connection checking, and streaming chat support, integrated into the provider manager and model factory.
  • Adds google-genai>=1.67.0 as a core dependency in pyproject.toml.
  • Adds Japanese and French locale translations for the website (i18n, doc titles, docs page routing) and console frontend, plus translated models documentation.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/copaw/providers/gemini_provider.py New GeminiProvider implementation with connection checks, model fetching, and chat model instantiation
src/copaw/providers/provider_manager.py Registers Gemini as a built-in provider and adds deserialization dispatch
src/copaw/agents/model_factory.py Registers GeminiChatFormatter for GeminiChatModel
pyproject.toml Adds google-genai>=1.67.0 to core dependencies
website/src/pages/Docs.tsx Adds ja/fr doc title translations and updates lang suffix routing
website/src/i18n.ts Adds ja/fr Lang types and full translation records
console/src/locales/fr.json Full French locale for the console UI
console/src/i18n.ts Registers French locale in console i18n
website/public/docs/models.*.md Gemini provider documentation in en/zh/ja/fr
Comments suppressed due to low confidence (1)

website/src/pages/Docs.tsx:399

  • The fallback when a localized doc file is not found fetches ${activeSlug}.md (no language suffix), but doc files in this project are always named with a language suffix (e.g., intro.en.md, intro.zh.md). Since only models.ja.md and models.fr.md exist, Japanese and French users will see blank content for every other documentation page (e.g., intro, quickstart, cli, etc.) because the fallback URL intro.md doesn't exist either. The fallback should fetch ${activeSlug}.en.md instead of ${activeSlug}.md to gracefully show English content when a translation is unavailable.
    const langSuffix = (["zh", "ja", "fr"] as const).includes(lang as any) ? lang : "en";
    const base = (import.meta.env.BASE_URL ?? "/").replace(/\/$/, "") || "";
    const url = `${base}/docs/${activeSlug}.${langSuffix}.md`;
    fetch(url)
      .then((r) => (r.ok ? r.text() : ""))
      .then((text) => {
        if (cancelled) return;
        if (text) {
          setContent(text);
          return;
        }
        return fetch(`${base}/docs/${activeSlug}.md`).then((r) =>
          r.ok ? r.text() : "",
        );

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 02:44 — with GitHub Actions Waiting
claude added 6 commits March 15, 2026 02:47
Add native Gemini support using AgentScope SDK's GeminiChatModel and
GeminiChatFormatter. This includes a new GeminiProvider implementation
that uses the google-genai SDK, registration in ProviderManager with
pre-configured models (Gemini 2.5 Pro/Flash, 2.0 Flash), model factory
formatter mapping, and documentation in both English and Chinese.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
- Update Gemini model list to include latest models (3.1 Pro, 3 Flash,
  3.1 Flash Lite, 2.5 Pro, 2.5 Flash, 2.5 Flash Lite, 2.0 Flash)
- Add French locale (fr.json) for console UI
- Add Japanese and French translations for models documentation
- Add Japanese and French language support to website i18n and docs routing
- Update English and Chinese model docs with latest Gemini model names

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
Adds a `gemini` optional-dependency group (`pip install copaw[gemini]`)
and includes it in the `full` extras, matching the pattern used by ollama.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
Move google-genai from optional to base dependencies, matching how
OpenAI/Anthropic SDKs are treated. Remove lazy import guard in
GeminiProvider and update all docs to remove manual SDK install step.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
Pin to the latest stable release to avoid compatibility issues
with older minor versions.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
Apply prettier formatting to website and console files, fix black
formatting and pylint unused-argument warning in gemini_provider.py.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
@ekzhu ekzhu force-pushed the claude/add-gemini-provider-3Gy4l branch from 2d338fc to 8c0fc65 Compare March 15, 2026 02:48
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 02:48 — with GitHub Actions Waiting
Strip out FR/JA translations (console locale, website docs, website
i18n, Docs.tsx routing) to keep this PR focused on the Gemini provider.
Locale support can be added in a separate follow-up PR.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
Copilot AI review requested due to automatic review settings March 15, 2026 02:50
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 02:50 — with GitHub Actions Waiting
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 02:51 — with GitHub Actions Waiting
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Google Gemini as a built-in model provider for CoPaw, using the native google-genai SDK. It introduces a GeminiProvider class following the established provider pattern, registers it in the provider manager, adds google-genai as a core dependency, and includes documentation in both English and Chinese. The PR also adds French locale support in i18n.ts and applies minor indentation/formatting fixes to several console components.

Changes:

  • New GeminiProvider class with model discovery, connection checking, and streaming chat support, plus registration in ProviderManager and model_factory.py
  • Added google-genai>=1.67.0 as a core dependency and English/Chinese documentation for the Gemini provider
  • Added French locale import in i18n.ts and minor ternary operator indentation fixes across several console components

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/copaw/providers/gemini_provider.py New Gemini provider implementation with connection check, model discovery, and chat model instantiation
src/copaw/providers/provider_manager.py Registers Gemini provider as builtin, adds model list, and deserialization support
src/copaw/agents/model_factory.py Adds GeminiChatModel/GeminiChatFormatter to the formatter map
pyproject.toml Adds google-genai>=1.67.0 as a core dependency
website/public/docs/models.en.md English documentation for Gemini provider setup
website/public/docs/models.zh.md Chinese documentation for Gemini provider setup
console/src/i18n.ts Imports and registers French locale (file missing)
console/src/layouts/Sidebar.tsx Ternary indentation formatting fix
console/src/components/MarkdownCopy/MarkdownCopy.tsx Ternary indentation formatting fix
console/src/pages/Settings/Models/components/cards/RemoteProviderCard.tsx Ternary indentation formatting fix
console/src/pages/Settings/Models/components/modals/ProviderConfigModal.tsx Interface declaration formatting fix
console/src/pages/Control/Sessions/index.tsx Filter callback formatting fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

These are pre-existing prettier issues on main, not introduced by
this PR. Reverting to keep the diff focused on the Gemini provider.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
@ekzhu ekzhu temporarily deployed to maintainer-approved March 15, 2026 02:57 — with GitHub Actions Inactive
@xieyxclack xieyxclack requested review from pan-x-c and qbc2016 March 15, 2026 05:31
Cover check_connection, fetch_models, check_model_connection,
_normalize_models_payload, and update_config using the same
monkeypatch/SimpleNamespace patterns as existing provider tests.

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
Copilot AI review requested due to automatic review settings March 15, 2026 08:06
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 08:06 — with GitHub Actions Waiting
Copilot AI review requested due to automatic review settings March 15, 2026 08:55
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 08:55 — with GitHub Actions Waiting
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Google Gemini as a built-in model provider for CoPaw using the google-genai SDK. It introduces a GeminiProvider class with support for model discovery, connection checking, and streaming chat, along with pre-configured Gemini models and documentation updates.

Changes:

  • New GeminiProvider implementation with model discovery, connection checking, and chat model instantiation via AgentScope's GeminiChatModel
  • Integration into the provider manager, model factory, API router, and pyproject.toml (core dependency)
  • English and Chinese documentation for configuring the Gemini provider

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/copaw/providers/gemini_provider.py New provider class implementing Gemini API integration
src/copaw/providers/provider_manager.py Registers Gemini as a built-in provider with pre-configured models
src/copaw/agents/model_factory.py Adds GeminiChatModel/GeminiChatFormatter to the model-formatter map
src/copaw/app/routers/providers.py Adds GeminiChatModel to the ChatModelName literal type
pyproject.toml Adds google-genai>=1.67.0 as a core dependency
tests/unit/providers/test_gemini_provider.py Unit tests for the new Gemini provider
website/public/docs/models.en.md English documentation for configuring Google Gemini
website/public/docs/models.zh.md Chinese documentation for configuring Google Gemini

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Two issues caused the save to spin indefinitely:
1. generate_content_stream() was not awaited in check_model_connection,
   causing the async for loop to iterate over a coroutine object
2. The Gemini client was created without a timeout, so network calls
   could hang forever on unreachable endpoints

Pass timeout via HttpOptions (in milliseconds) when creating the client,
and add the missing await on generate_content_stream().

https://claude.ai/code/session_01EvXughe7ZQam3dF6w23bE3
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 09:01 — with GitHub Actions Waiting
- Add `except Exception` fallback to check_connection, fetch_models,
  and check_model_connection, matching OpenAI/Anthropic provider pattern
  to handle network errors, DNS failures, and timeouts gracefully
- Add 3 unit tests covering the generic exception fallback paths
- Fix model names in EN/ZH docs to include "Preview" suffix matching
  the actual pre-configured model names in provider_manager.py
- Auto-format from pre-commit (trailing commas, black)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 15, 2026 09:58
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 09:59 — with GitHub Actions Waiting
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Google Gemini as a built-in model provider for CoPaw, using the native google-genai SDK. The implementation follows the established provider pattern (similar to Anthropic and OpenAI providers) with support for connection checking, model discovery, model connection validation, and streaming chat via AgentScope's GeminiChatModel.

Changes:

  • New GeminiProvider class with full provider lifecycle (connection check, model discovery, model connection check, chat model instantiation), plus pre-configured Gemini model list and registration in the provider manager.
  • Integration with the model factory for formatter mapping and API router updates for the new GeminiChatModel literal type.
  • Documentation (English and Chinese) and comprehensive unit tests covering all provider methods.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/copaw/providers/gemini_provider.py New provider implementation using google-genai SDK
src/copaw/providers/provider_manager.py Registers Gemini models, provider instance, and deserialization support
src/copaw/agents/model_factory.py Adds GeminiChatModel/GeminiChatFormatter to the formatter map
src/copaw/app/routers/providers.py Adds GeminiChatModel to the ChatModelName literal type
pyproject.toml Adds google-genai>=1.67.0 as a core dependency
tests/unit/providers/test_gemini_provider.py Comprehensive tests for all GeminiProvider methods
website/public/docs/models.en.md English documentation for Gemini provider setup
website/public/docs/models.zh.md Chinese documentation for Gemini provider setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add pylint disable comment for protected-access (matching other
  provider test files)
- Use 'raise StopAsyncIteration from exc' for proper exception chaining
- Use implicit booleaness for empty list checks

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ekzhu ekzhu requested a deployment to maintainer-approved March 15, 2026 10:06 — with GitHub Actions Waiting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 15, 2026 10:18
@ekzhu ekzhu temporarily deployed to maintainer-approved March 15, 2026 10:18 — with GitHub Actions Inactive
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Google Gemini as a new built-in model provider for CoPaw, using the native google-genai SDK. The implementation follows the established provider pattern (like OpenAI and Anthropic providers) with connection checking, model discovery, model connection verification, and streaming chat support via AgentScope's GeminiChatModel.

Changes:

  • New GeminiProvider class with full provider lifecycle (connection check, model discovery, model connection check, chat model instantiation) and integration into ProviderManager, model factory, and API router.
  • Added google-genai>=1.67.0 as a core dependency, with pre-configured models including Gemini 3.1 Pro Preview, Gemini 3 Flash Preview, and several Gemini 2.x models.
  • English and Chinese documentation updated with Gemini provider setup instructions.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/copaw/providers/gemini_provider.py New provider implementation using native google-genai SDK
src/copaw/providers/provider_manager.py Registers Gemini as builtin provider with pre-configured models and deserialization support
src/copaw/agents/model_factory.py Adds GeminiChatFormatter/GeminiChatModel to the formatter mapping
src/copaw/app/routers/providers.py Adds GeminiChatModel to the ChatModelName literal type
tests/unit/providers/test_gemini_provider.py Comprehensive tests for all provider methods
pyproject.toml Adds google-genai>=1.67.0 as core dependency
website/public/docs/models.en.md English documentation for Gemini provider setup
website/public/docs/models.zh.md Chinese documentation for Gemini provider setup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@pan-x-c pan-x-c left a comment

Choose a reason for hiding this comment

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

LGTM

@yuanxs21 yuanxs21 added the model configure Issue related to the model API. label Mar 16, 2026
Increase timeout to 10
@ekzhu ekzhu temporarily deployed to maintainer-approved March 16, 2026 05:42 — with GitHub Actions Inactive
Copy link
Member

@qbc2016 qbc2016 left a comment

Choose a reason for hiding this comment

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

LGTM.

Copilot AI review requested due to automatic review settings March 16, 2026 08:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review is ineligible. To be eligible to request a review, you need a paid Copilot license, or your organization must enable Copilot code review.

@xieyxclack xieyxclack temporarily deployed to maintainer-approved March 16, 2026 08:20 — with GitHub Actions Inactive
Copy link
Member

@qbc2016 qbc2016 left a comment

Choose a reason for hiding this comment

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

LGTM.

@xieyxclack xieyxclack merged commit aee877d into agentscope-ai:main Mar 16, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

model configure Issue related to the model API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants