-
Notifications
You must be signed in to change notification settings - Fork 66
feat: Add support for custom Gemini models and model loading strategies #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
luuquangvu
commented
Jan 13, 2026
- Add support for custom Gemini models and model loading strategies.
- Move all helper functions to utils/helper.
- Update documentation to reflect changes in model configuration.
They are no longer needed since the underlying library issue has been resolved.
…to better handle heavy tasks
… client status checks
…probabilities, and token details; adjust response handling accordingly.
…tput_text` validator, rename `created` to `created_at`, and update response handling accordingly.
…roved streaming of response items. Refactor image generation handling for consistency and add compatibility with output content.
…t` and ensure consistent initialization in image output handling.
…anagement Add dedicated router for /images endpoint and refactor image handling logic for better modularity. Enhance temporary image management with secure naming, token verification, and cleanup functionality.
…l and refactor variable handling
…y` for tools, tool_choice, and streaming settings
…nd update response handling for consistency
…mat for compatibility
…ck to default size
…andling, and improved extension determination
- Introduced `model_strategy` configuration for "append" (default + custom models) or "overwrite" (custom models only). - Enhanced `/v1/models` endpoint to return models based on the configured strategy. - Improved model loading with environment variable overrides and validation. - Refactored model handling logic for improved modularity and error handling.
…eld support - Enhanced `extract_gemini_models_env` to handle nested fields within environment variables. - Updated type hints for more flexibility in model overrides. - Improved `_merge_models_with_env` to better support field-level updates and appending new models.
- Moved utility functions like `strip_code_fence`, `extract_tool_calls`, and `iter_stream_segments` to a centralized helper module. - Removed unused and redundant private methods from `chat.py`, including `_strip_code_fence`, `_strip_tagged_blocks`, and `_strip_system_hints`. - Updated imports and references across modules for consistency. - Simplified tool call and streaming logic by replacing inline implementations with shared helper functions.
- Replaced unused model placeholder in `config.yaml` with an empty list. - Added JSON parsing validators for `model_header` and `models` to enhance flexibility and error handling. - Improved validation to filter out incomplete model configurations.
…N support - Replaced prefix-based parsing with a root key approach. - Added JSON parsing to handle list-based model configurations. - Improved handling of errors and cleanup of environment variables.
…to Python literals - Added `ast.literal_eval` as a fallback for parsing environment variables when JSON decoding fails. - Improved error handling and logging for invalid configurations. - Ensured proper cleanup of environment variables post-parsing.
- Adjusted `TOOL_CALL_RE` regex pattern for better accuracy.
…nvironment variable setup
There was a problem hiding this 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 support for custom Gemini models with configurable loading strategies. It refactors helper functions into a dedicated utils module and updates documentation to reflect the new model configuration options.
Changes:
- Added custom Gemini model configuration with "append" and "overwrite" strategies
- Consolidated helper functions from app/server/chat.py into app/utils/helper.py
- Added environment variable support for custom model configuration
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| config/config.yaml | Added model_strategy and models fields for custom model configuration |
| app/utils/helper.py | Moved and added helper functions including tool call extraction, streaming, and image processing utilities |
| app/utils/config.py | Added GeminiModelConfig class and model configuration parsing with environment variable support |
| app/services/client.py | Removed XML_WRAP_HINT and CODE_BLOCK_HINT constants now imported from helper.py |
| app/server/chat.py | Refactored to use helper functions, added _get_model_by_name and _get_available_models for custom model support, improved image generation error handling |
| README.md | Added documentation for custom model configuration |
| README.zh.md | Added Chinese documentation for custom model configuration and minor formatting fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…nvironment variables; enhance error logging in config validation
…tring or list structure for enhanced flexibility in automated environments
|
@Nativu5 Thank you! |
|
I would like to request permission to merge this PR. Thank you again @Nativu5 ! |