Skip to content

Conversation

cuipengfei
Copy link
Contributor

No description provided.

…API; enhance translation handling for nested function responses
- Implement Gemini API endpoints (generateContent, streamGenerateContent, countTokens)
- Add request/response translation between Gemini and OpenAI formats
- Support function calling with proper tool_call_id mapping
- Handle streaming responses with chunk-by-chunk translation
- Add debug logging system for troubleshooting
- Implement tool call utilities for parameter accumulation
- Add comprehensive test coverage for all Gemini features

This implementation provides full compatibility with Google's Gemini API specification while using GitHub Copilot as the underlying LLM provider.
- Remove CLAUDE.md (local development guide)
- Remove gemini-plan.md (implementation planning doc)
- Simplify .gitignore to only add .env (generic ignore)
@cuipengfei cuipengfei marked this pull request as ready for review October 2, 2025 04:26
@Copilot Copilot AI review requested due to automatic review settings October 2, 2025 04:26
Copy link
Contributor

@Copilot 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

Adds Gemini API compatibility layer: routing, request/response translation, streaming adaptation, tool call handling, and extensive test coverage. Key changes introduce new generate-content route, translation utilities, tool-call accumulation logic, and debug logging.

  • Adds geminiRouter and handlers for generateContent, streamGenerateContent, and countTokens endpoints.
  • Implements translation between Gemini request/response formats and existing OpenAI/Copilot internal structures, including streaming tool call argument accumulation.
  • Introduces comprehensive test suites covering routing, validation, translation edge cases, streaming behavior, and tool call workflows.

Reviewed Changes

Copilot reviewed 18 out of 20 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/server.ts Registers Gemini router to expose new v1beta endpoints.
src/routes/generate-content/route.ts Adds URL pattern routing for generate, stream, and countTokens operations.
src/routes/generate-content/handler.ts Core handlers for non-stream, stream, and token count flows plus fallback streaming conversion.
src/routes/generate-content/translation.ts Large translation layer Gemini <-> OpenAI, tool call/message normalization, streaming chunk translation.
src/routes/generate-content/utils.ts Finish reason mapping utility.
src/routes/generate-content/types.ts Defines Gemini request/response and streaming types.
src/lib/tool-call-utils.ts Tool declaration translation and streaming tool call argument accumulator.
src/lib/debug-logger.ts Debug logging utilities for requests/responses.
tests/generate-content/*.test.ts Extensive new test coverage for routing, validation, translation, streaming, and edge cases.
tests/generate-content/_test-utils.ts Shared test helper utilities.
tests/generate-content/test-types.ts Test-only type helpers.

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

@cuipengfei cuipengfei requested a review from Copilot October 4, 2025 13:57
Copy link
Contributor

@Copilot 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

Copilot reviewed 18 out of 20 changed files in this pull request and generated 8 comments.


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

- Removed outdated translation coverage tests and replaced them with new multi-turn and tool call tests.
- Introduced structured test cases for multi-turn interactions, ensuring proper handling of tool calls and deduplication.
- Improved tool call processing tests, including cleanup of incomplete calls and handling of inline data.
- Streamlined translation test cases to utilize shared utility functions for consistency and clarity.
- Added validation for tool call ID length constraints and ensured proper mapping of tool configurations.
- Enhanced error handling tests to cover various failure scenarios and ensure graceful degradation.
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.

1 participant