Feature/gemini api#112
Closed
cuipengfei wants to merge 35 commits into
Closed
Conversation
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.
Contributor
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
The function definition is incomplete - it's missing the closing parenthesis and function body. This will cause a syntax error.
- 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.
Feature/count token
…se output message type
Feature/gpt 5 codex
…nd state management
…ure in translation tests
refactor: remove claudeCodeEnv option and update environment variable…
Feature/gpt 5 codex
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.