agentscope-ai / agentscope-ai/QwenPaw

[Feature]: Add Vertex AI Gemini provider

Abierto
#4,030 2 comentarios 0 reacciones 1 asignado Reclamado por @pan-x-c Ver en GitHub
enhancement
Lenguaje dominante
TypeScript
Estrellas
35k
Forks
3.1k
Merge medio
1 d 13 h
PR fusionados (30 d)
228

Descripción

## Summary

Add support for using Google Gemini models through Vertex AI. QwenPaw currently supports Gemini via the Gemini Developer API, but users who require Google Cloud billing, IAM/auth, governance, regional routing, or Vertex AI access cannot configure that path directly.

## Component(s) Affected

- [x] Core / Backend (app, agents, config, providers, utils, local_models)
- [ ] Console (frontend web UI)
- [ ] Channels (DingTalk, Feishu, QQ, Discord, iMessage, etc.)
- [ ] Skills
- [ ] CLI
- [x] Documentation (website)
- [x] Tests
- [ ] CI/CD
- [ ] Scripts / Deploy

## Problem / Motivation

QwenPaw has a built-in Google Gemini provider, but it appears to target the Gemini Developer API / AI Studio API-key flow.

From the current implementation, `GeminiProvider` creates a `google-genai` client with `api_key=...`, and the built-in provider base URL is `https://generativelanguage.googleapis.com`. I did not find provider configuration for Vertex AI fields such as `vertexai=True`, Google Cloud `project`, `location`, or Application Default Credentials.

This makes it difficult for users who need to use Gemini through Vertex AI, for example because of:

- Google Cloud billing and quota management
- IAM / Application Default Credentials
- enterprise governance requirements
- regional model access through Vertex AI
- existing GCP infrastructure policies

## Proposed Solution

Add a separate built-in provider for Vertex AI Gemini, for example `vertex-gemini`, rather than changing the existing `gemini` provider.

A separate provider would keep the current Gemini Developer API behavior unchanged for users who use AI Studio / API-key auth, while adding a clear path for Vertex AI users.

Possible implementation direction:

- Add a provider class such as `VertexGeminiProvider`.
- Use Google Gen AI SDK Vertex mode, for example:
- `genai.Client(vertexai=True, project=..., location=...)`
- or environment variables:
- `GOOGLE_GENAI_USE_VERTEXAI=true`
- `GOOGLE_CLOUD_PROJECT=`
- `GOOGLE_CLOUD_LOCATION=`
- Register the provider in `ProviderManager`.
- Include at least one default Vertex-compatible Gemini model.
- Add unit tests for client initialization, connection check, model discovery or configured models, and model connection check.
- Update `website/public/docs/models.*.md` with Vertex AI setup instructions.
- Include connection test evidence and a chat screenshot in the PR.

Open questions for maintainers:

1. Would a native `vertex-gemini` built-in provider be acceptable?
2. Should Vertex AI support be a separate provider, or an option inside the existing `gemini` provider?
3. Should QwenPaw expose `project` and `location` as provider config fields, or rely on environment variables / ADC?
4. Would maintainers prefer using Vertex AI’s OpenAI-compatible Chat Completions endpoint instead of native `google-genai` Vertex mode?

## Alternatives Considered

Use the existing `gemini` provider:

This does not seem sufficient because it currently uses API-key auth and the Gemini Developer API endpoint, not Vertex AI project/location auth.

Use a custom OpenAI-compatible provider:

Vertex AI provides an OpenAI-compatible Chat Completions endpoint, but it uses Google Cloud authentication / short-lived OAuth tokens rather than a normal static API key. That may not fit QwenPaw’s current custom provider configuration cleanly without extra token refresh handling or a proxy.

Modify the existing `gemini` provider:

This might work, but it could make the current Gemini API-key flow more complex. A separate provider seems safer and clearer for users.

## Additional Context

Relevant current code:

- `src/qwenpaw/providers/gemini_provider.py`
- `GeminiProvider._client()` currently creates `genai.Client(api_key=self.api_key, ...)`
- `get_chat_model_instance()` passes `api_key=self.api_key` to `GeminiChatModel`

- `src/qwenpaw/providers/provider_manager.py`
- built-in Gemini provider ID: `gemini`
- provider name: `Google Gemini`
- base URL: `https://generativelanguage.googleapis.com`

Relevant docs:

- Google Gen AI SDK supports Vertex AI with `vertexai=True`, `project`, and `location`, or with environment variables:
- `GOOGLE_GENAI_USE_VERTEXAI=true`
- `GOOGLE_CLOUD_PROJECT`
- `GOOGLE_CLOUD_LOCATION`

Google Gen AI SDK docs:
https://googleapis.github.io/python-genai/

Vertex AI OpenAI-compatible endpoint docs:
https://docs.cloud.google.com/vertex-ai/generative-ai/docs/start/openai

## Willing to Contribute

- [x] I am willing to open a PR for this feature (after discussion).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.