 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package geminiCLI provides request translation functionality for Gemini to OpenAI API. It handles parsing and transforming Gemini API requests into OpenAI Chat Completions API format, extracting model information, generation config, message contents, and tool declarations. The package performs JSON data transformation to ensure compatibility between Gemini API format and OpenAI API's expected format.
Package geminiCLI provides response translation functionality for OpenAI to Gemini API. This package handles the conversion of OpenAI Chat Completions API responses into Gemini API-compatible JSON format, transforming streaming events and non-streaming responses into the format expected by Gemini API clients. It supports both streaming and non-streaming modes, handling text content, tool calls, and usage metadata appropriately.
Index ¶
- func ConvertGeminiCLIRequestToOpenAI(modelName string, inputRawJSON []byte, stream bool) []byte
- func ConvertOpenAIResponseToGeminiCLI(ctx context.Context, modelName string, ...) []string
- func ConvertOpenAIResponseToGeminiCLINonStream(ctx context.Context, modelName string, ...) string
- func GeminiCLITokenCount(ctx context.Context, count int64) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertGeminiCLIRequestToOpenAI ¶
ConvertGeminiCLIRequestToOpenAI parses and transforms a Gemini API request into OpenAI Chat Completions API format. It extracts the model name, generation config, message contents, and tool declarations from the raw JSON request and returns them in the format expected by the OpenAI API.
func ConvertOpenAIResponseToGeminiCLI ¶
func ConvertOpenAIResponseToGeminiCLI(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) []string
ConvertOpenAIResponseToGeminiCLI converts OpenAI Chat Completions streaming response format to Gemini API format. This function processes OpenAI streaming chunks and transforms them into Gemini-compatible JSON responses. It handles text content, tool calls, and usage metadata, outputting responses that match the Gemini API format.
Parameters:
- ctx: The context for the request.
- modelName: The name of the model.
- rawJSON: The raw JSON response from the OpenAI API.
- param: A pointer to a parameter object for the conversion.
Returns:
- []string: A slice of strings, each containing a Gemini-compatible JSON response.
func ConvertOpenAIResponseToGeminiCLINonStream ¶
func ConvertOpenAIResponseToGeminiCLINonStream(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) string
ConvertOpenAIResponseToGeminiCLINonStream converts a non-streaming OpenAI response to a non-streaming Gemini CLI response.
Parameters:
- ctx: The context for the request.
- modelName: The name of the model.
- rawJSON: The raw JSON response from the OpenAI API.
- param: A pointer to a parameter object for the conversion.
Returns:
- string: A Gemini-compatible JSON response.
Types ¶
This section is empty.