-
-
Notifications
You must be signed in to change notification settings - Fork 209
Feature/add gemini api support #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature/add gemini api support #122
Conversation
…forcing model requirement
…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)
There was a problem hiding this 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.
…message processing
…nd enhance streaming response handling
There was a problem hiding this 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.
No description provided.