feat(providers): add Google GenerateContent and Imagen API packages#79
Conversation
Add standalone provider package for Google Generate Content API with mixin
pattern for capability-agnostic reuse.
## Client (GoogleGenerateContentClient mixin)
- HTTP POST/streaming to /v1beta/models/{model}:generateContent endpoint
- Usage parsing: promptTokenCount, candidatesTokenCount, totalTokenCount
- Content extraction from candidates[0].content.parts
- Finish reason mapping (STOP, MAX_TOKENS, SAFETY, etc.)
- API key authentication via x-goog-api-key header
## Parameters
- TemperatureMapper: temperature float [0.0-2.0]
- TopPMapper: nucleus sampling top_p
- TopKMapper: top-k sampling
- MaxTokensMapper: maxOutputTokens
- StopSequencesMapper: custom stop sequences
- SystemInstructionMapper: system_instruction content block
- ResponseFormatMapper: JSON schema via responseSchema
- Supports single BaseModel and list[BaseModel]
- Uses StrictRefResolvingJsonSchemaGenerator for schema generation
- ToolsMapper: function declarations for tool use
- ToolChoiceMapper: tool_config with function_calling_config
## Streaming (GoogleGenerateContentStream mixin)
- SSE event parsing for streamGenerateContent endpoint
- Text delta extraction from candidates[0].content.parts
- Finish reason and usage tracking in final events
## Config
- API base URL: https://generativelanguage.googleapis.com
- API version: v1beta
- Endpoints: generateContent, streamGenerateContent
… API mixin - Update GoogleTextGenerationClient to extend GoogleGenerateContentClient mixin - Simplify client by delegating HTTP, usage parsing, and metadata to API layer - Update parameter mappers to extend base API mappers - Update streaming to extend base API stream class - Add celeste-google as workspace dependency
## Client (GoogleImagenClient mixin)
- HTTP POST to /v1beta/models/{model_id}:predict endpoint
- Parse predictions[] array from response
- No usage metadata (Imagen API doesn't provide it)
- Metadata filtering for safety attributes
## Parameters
- SampleCountMapper: parameters.sampleCount for num_images
- AspectRatioMapper: parameters.aspectRatio
- ImageSizeMapper: parameters.imageSize
## Config
- API base URL: https://generativelanguage.googleapis.com
- Endpoint: /v1beta/models/{model_id}:predict
## Strategy Pattern - GoogleImageGenerationClient delegates to model-specific strategies - GeminiImageGenerationClient uses GoogleGenerateContentClient mixin - ImagenImageGenerationClient uses GoogleImagenClient mixin - Model ID → Strategy mapping for automatic dispatch ## Gemini Strategy - Extends GoogleGenerateContentClient for multimodal image generation - Uses responseModalities: ['Image'] for image output - Parses inlineData from candidates[].content.parts[] ## Imagen Strategy - Extends GoogleImagenClient for Imagen API - Parses predictions[] array from response - Maps to ImageArtifact with base64 data ## Parameters - Split into gemini_parameters.py and imagen_parameters.py - Extend base API mappers from celeste-google package ## Other Changes - Add celeste-google as workspace dependency - Remove old adapter pattern (gemini_api.py, imagen_api.py, config.py) - Update tests for new strategy pattern
Without num_images parameter, Imagen may return multiple images (list) instead of a single ImageArtifact, causing test assertion to fail.
PR Review: Google GenerateContent and Imagen API PackagesSummaryThis PR introduces a well-architected mixin-based provider package for Google's APIs. The refactoring successfully reduces code duplication and improves maintainability. Overall, this is high-quality work with strong architectural decisions. ✅ StrengthsExcellent Architecture:
Code Quality:
Extensibility:
|
Pull Request ReviewSummaryThis PR introduces the ✅ StrengthsArchitecture & Design
Code Quality
|
Summary
Introduces the
celeste-googleprovider package with shared API implementations for Google's GenerateContent and Imagen APIs. This follows the same mixin pattern established withceleste-anthropic, enabling capability-agnostic code reuse across text generation, image generation, and future capabilities.Architecture
Changes
1. Google GenerateContent API (
celeste-google.generate_content)Client Mixin:
/v1beta/models/{model}:generateContentParameters:
Streaming:
2. Google Imagen API (
celeste-google.imagen)Client Mixin:
/v1beta/models/{model}:predictParameters:
3. Text Generation Migration
GoogleTextGenerationClientnow extendsGoogleGenerateContentClientmixinTextGenerationInput→ parts conversion4. Image Generation Migration
GoogleImageGenerationClientdispatches to model-specific strategiesGeminiImageGenerationClientusesGoogleGenerateContentClientfor multimodalImagenImageGenerationClientusesGoogleImagenClientfor Imagen APIBenefits
Test Plan