Skip to content

Conversation

@luuquangvu
Copy link
Collaborator

  • 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.
…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.
…y` for tools, tool_choice, and streaming settings
…nd update response handling for consistency
…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.
@luuquangvu luuquangvu requested a review from Nativu5 January 13, 2026 02:34
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 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
@luuquangvu luuquangvu requested a review from Nativu5 January 15, 2026 03:23
…tring or list structure for enhanced flexibility in automated environments
@luuquangvu
Copy link
Collaborator Author

@Nativu5 Thank you!

@luuquangvu
Copy link
Collaborator Author

I would like to request permission to merge this PR. Thank you again @Nativu5 !

@luuquangvu luuquangvu merged commit a583ded into Nativu5:main Jan 22, 2026
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.

2 participants