 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package geminiCLI provides request translation functionality for Gemini CLI to Codex API compatibility. It handles parsing and transforming Gemini CLI API requests into Codex API format, extracting model information, system instructions, message contents, and tool declarations. The package performs JSON data transformation to ensure compatibility between Gemini CLI API format and Codex API's expected format.
Package geminiCLI provides response translation functionality for Codex to Gemini CLI API compatibility. This package handles the conversion of Codex API responses into Gemini CLI-compatible JSON format, transforming streaming events and non-streaming responses into the format expected by Gemini CLI API clients.
Index ¶
- func ConvertCodexResponseToGeminiCLI(ctx context.Context, modelName string, ...) []string
- func ConvertCodexResponseToGeminiCLINonStream(ctx context.Context, modelName string, ...) string
- func ConvertGeminiCLIRequestToCodex(modelName string, inputRawJSON []byte, stream bool) []byte
- func GeminiCLITokenCount(ctx context.Context, count int64) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertCodexResponseToGeminiCLI ¶
func ConvertCodexResponseToGeminiCLI(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) []string
ConvertCodexResponseToGeminiCLI converts Codex streaming response format to Gemini CLI format. This function processes various Codex event types and transforms them into Gemini-compatible JSON responses. It handles text content, tool calls, and usage metadata, outputting responses that match the Gemini CLI API format. The function wraps each converted response in a "response" object to match the Gemini CLI API structure.
Parameters:
- ctx: The context for the request, used for cancellation and timeout handling
- modelName: The name of the model being used for the response
- rawJSON: The raw JSON response from the Codex API
- param: A pointer to a parameter object for maintaining state between calls
Returns:
- []string: A slice of strings, each containing a Gemini-compatible JSON response wrapped in a response object
func ConvertCodexResponseToGeminiCLINonStream ¶
func ConvertCodexResponseToGeminiCLINonStream(ctx context.Context, modelName string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, param *any) string
ConvertCodexResponseToGeminiCLINonStream converts a non-streaming Codex response to a non-streaming Gemini CLI response. This function processes the complete Codex response and transforms it into a single Gemini-compatible JSON response. It wraps the converted response in a "response" object to match the Gemini CLI API structure.
Parameters:
- ctx: The context for the request, used for cancellation and timeout handling
- modelName: The name of the model being used for the response
- rawJSON: The raw JSON response from the Codex API
- param: A pointer to a parameter object for the conversion
Returns:
- string: A Gemini-compatible JSON response wrapped in a response object
func ConvertGeminiCLIRequestToCodex ¶
ConvertGeminiCLIRequestToCodex parses and transforms a Gemini CLI API request into Codex API format. It extracts the model name, system instruction, message contents, and tool declarations from the raw JSON request and returns them in the format expected by the Codex API. The function performs the following transformations: 1. Extracts the inner request object and promotes it to the top level 2. Restores the model information at the top level 3. Converts systemInstruction field to system_instruction for Codex compatibility 4. Delegates to the Gemini-to-Codex conversion function for further processing
Parameters:
- modelName: The name of the model to use for the request
- rawJSON: The raw JSON request data from the Gemini CLI API
- stream: A boolean indicating if the request is for a streaming response
Returns:
- []byte: The transformed request data in Codex API format
Types ¶
This section is empty.