mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-03 04:50:52 +08:00
- Introduced request and response translation functions to enable compatibility between OpenAI Chat Completions API and Antigravity. - Registered translation utilities for both streaming and non-streaming scenarios. - Added support for reasoning content, tool calls, and metadata handling. - Established request normalization and embedding for Antigravity-compatible payloads. - Added new fields to `Params` struct for better tracking of finish reasons, usage metadata, and tool usage. - Refactored handling of response transitions, final events, and state-driven logic in `ConvertAntigravityResponseToClaude`. - Introduced `appendFinalEvents` and `resolveStopReason` helper functions for cleaner separation of concerns. - Added `TotalTokenCount` field to `Params` struct for enhanced token tracking. - Updated token count calculations to fallback on `TotalTokenCount` when specific counts are missing. - Introduced `hasNonZeroUsageMetadata` function to validate presence of token data in `usage_metadata`.
21 lines
512 B
Go
21 lines
512 B
Go
package gemini
|
|
|
|
import (
|
|
. "github.com/router-for-me/CLIProxyAPI/v6/internal/constant"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/interfaces"
|
|
"github.com/router-for-me/CLIProxyAPI/v6/internal/translator/translator"
|
|
)
|
|
|
|
func init() {
|
|
translator.Register(
|
|
Gemini,
|
|
Antigravity,
|
|
ConvertGeminiRequestToAntigravity,
|
|
interfaces.TranslateResponse{
|
|
Stream: ConvertAntigravityResponseToGemini,
|
|
NonStream: ConvertAntigravityResponseToGeminiNonStream,
|
|
TokenCount: GeminiTokenCount,
|
|
},
|
|
)
|
|
}
|