Skip to content

Feature/gemini api#112

Closed
cuipengfei wants to merge 35 commits into
ericc-ch:masterfrom
cuipengfei:feature/gemini-api
Closed

Feature/gemini api#112
cuipengfei wants to merge 35 commits into
ericc-ch:masterfrom
cuipengfei:feature/gemini-api

Conversation

@cuipengfei
Copy link
Copy Markdown
Contributor

Likely buggy.

I have tested it with gemini cli running against 4141 with gemini 2.5 pro model, worked ok.

But for gemini cli to use other models from 4141, not fully tested yet.

cuipengfei and others added 5 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.
Copilot AI review requested due to automatic review settings September 21, 2025 15:56
Copy link
Copy Markdown
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 Google Gemini API compatibility to the server by implementing translation layers between Gemini and OpenAI API formats. It introduces new endpoints for Gemini's generate content, streaming, and token counting operations.

  • Adds Gemini API route handlers with translation between Gemini and OpenAI formats
  • Implements comprehensive type definitions for Gemini API requests and responses
  • Configures server timeout settings for Gemini compatibility

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/start.ts Adds Bun server configuration with increased idle timeout for Gemini
src/server.ts Registers the new Gemini router in the main server
src/routes/generate-content/utils.ts Utility functions for mapping finish reasons between Gemini and OpenAI
src/routes/generate-content/types.ts Complete type definitions for Gemini API structures
src/routes/generate-content/translation.ts Translation logic between Gemini and OpenAI API formats
src/routes/generate-content/route.ts Route definitions for Gemini API endpoints
src/routes/generate-content/handler.ts Request handlers for Gemini generation, streaming, and token counting

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

Comment on lines +333 to +335
const isNonStreaming = (
response: Awaited<ReturnType<typeof createChatCompletions>>,
): response is ChatCompletionResponse => "choices" in response
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

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

The function definition is incomplete - it's missing the closing parenthesis and function body. This will cause a syntax error.

Copilot uses AI. Check for mistakes.
caozhiyuan and others added 23 commits September 24, 2025 16:03
- Add new command line option `--claude-code-env` to generate environment variables for Claude Code
- Update `runServer` function to use new `claudeCodeEnv` option
- Add `claude-code-env` to `start` command options in README.md
…ge assignment in translateChunkToAnthropicEvents message_start
- 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.
@cuipengfei cuipengfei closed this Oct 1, 2025
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.

3 participants