Skip to content

Feature/gemini api#12

Merged
cuipengfei merged 17 commits into
devfrom
feature/gemini-api
Oct 2, 2025
Merged

Feature/gemini api#12
cuipengfei merged 17 commits into
devfrom
feature/gemini-api

Conversation

@cuipengfei

Copy link
Copy Markdown
Owner

No description provided.

cuipengfei and others added 12 commits September 21, 2025 23:35
Scope: /src/routes/generate-content/* only

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This reverts commit fa6b612.
- Introduced test types for mocking server responses and payloads.
- Implemented translation coverage tests for OpenAI to Gemini response translation.
- Added translation tests to validate tool configuration and content processing.
- Created validation and routing tests to ensure proper error handling and request validation.
- Enhanced existing tests to cover various edge cases and ensure robust functionality.
Copilot AI review requested due to automatic review settings October 1, 2025 14:10

Copilot AI left a comment

Copy link
Copy Markdown

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 implements a comprehensive Gemini API feature that translates Google's Gemini API format to/from GitHub Copilot's OpenAI-compatible API. The implementation includes bidirectional translation for both streaming and non-streaming responses, tool calling support, token counting, and extensive test coverage.

Key changes:

  • Gemini API routing and request handling for generateContent, streamGenerateContent, and countTokens endpoints
  • Bidirectional translation layer between Gemini and OpenAI API formats with tool call support
  • Streaming response handling with proper JSON parsing and error recovery
  • Comprehensive test suite covering validation, routing, translation, and edge cases

Reviewed Changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/server.ts Adds Gemini router to the main server configuration
src/start.ts Configures server timeout for Gemini API compatibility
src/routes/generate-content/ Complete Gemini API implementation with handlers, routing, translation, and types
src/lib/tool-call-utils.ts Utilities for tool call translation and streaming accumulation
src/lib/debug-logger.ts Debug logging utilities for request/response analysis
tests/generate-content/ Comprehensive test suite covering all Gemini API functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

contents: [{ role: "user", parts: [{ text: "hi" }] }],
})

// 由于错误处理机制,HTTP错误也会转为500

Copilot AI Oct 1, 2025

Copy link

Choose a reason for hiding this comment

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

The comment contains Chinese text. Comments should be in English for consistency with the rest of the codebase.

Copilot uses AI. Check for mistakes.
Comment thread tests/generate-content/validation-and-routing.test.ts Outdated
@cuipengfei cuipengfei merged commit d6b3e4d into dev Oct 2, 2025
1 check passed
@cuipengfei cuipengfei deleted the feature/gemini-api branch October 29, 2025 13:51
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