Documentation
¶
Overview ¶
Package gemini provides request translation functionality for Gemini CLI to Gemini API compatibility. It handles parsing and transforming Gemini CLI API requests into Gemini 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 Gemini API's expected format.
Package gemini provides request translation functionality for Gemini to Gemini CLI API compatibility. It handles parsing and transforming Gemini API requests into Gemini CLI API format, extracting model information, system instructions, message contents, and tool declarations. The package performs JSON data transformation to ensure compatibility between Gemini API format and Gemini CLI API's expected format.
Index ¶
- func ConvertGeminiCliRequestToGemini(ctx context.Context, _ string, ...) []string
- func ConvertGeminiCliRequestToGeminiNonStream(_ context.Context, _ string, ...) string
- func ConvertGeminiRequestToGeminiCLI(_ string, inputRawJSON []byte, _ bool) []byte
- func GeminiTokenCount(ctx context.Context, count int64) string
- type FunctionCallGroup
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertGeminiCliRequestToGemini ¶
func ConvertGeminiCliRequestToGemini(ctx context.Context, _ string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, _ *any) []string
ConvertGeminiCliRequestToGemini parses and transforms a Gemini CLI API request into Gemini 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 Gemini API. The function performs the following transformations: 1. Extracts the response data from the request 2. Handles alternative response formats 3. Processes array responses by extracting individual response objects
Parameters:
- ctx: The context for the request, used for cancellation and timeout handling
- modelName: The name of the model to use for the request (unused in current implementation)
- rawJSON: The raw JSON request data from the Gemini CLI API
- param: A pointer to a parameter object for the conversion (unused in current implementation)
Returns:
- []string: The transformed request data in Gemini API format
func ConvertGeminiCliRequestToGeminiNonStream ¶
func ConvertGeminiCliRequestToGeminiNonStream(_ context.Context, _ string, originalRequestRawJSON, requestRawJSON, rawJSON []byte, _ *any) string
ConvertGeminiCliRequestToGeminiNonStream converts a non-streaming Gemini CLI request to a non-streaming Gemini response. This function processes the complete Gemini CLI request and transforms it into a single Gemini-compatible JSON response. It extracts the response data from the request and returns it in the expected format.
Parameters:
- ctx: The context for the request, used for cancellation and timeout handling
- modelName: The name of the model being used for the response (unused in current implementation)
- rawJSON: The raw JSON request data from the Gemini CLI API
- param: A pointer to a parameter object for the conversion (unused in current implementation)
Returns:
- string: A Gemini-compatible JSON response containing the response data
func ConvertGeminiRequestToGeminiCLI ¶
ConvertGeminiRequestToGeminiCLI parses and transforms a Gemini CLI API request into Gemini 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 Gemini API. The function performs the following transformations: 1. Extracts the model information from the request 2. Restructures the JSON to match Gemini API format 3. Converts system instructions to the expected format 4. Fixes CLI tool response format and grouping
Parameters:
- modelName: The name of the model to use for the request (unused in current implementation)
- rawJSON: The raw JSON request data from the Gemini CLI API
- stream: A boolean indicating if the request is for a streaming response (unused in current implementation)
Returns:
- []byte: The transformed request data in Gemini API format