geminiCLI

package
v6.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2025 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertGeminiCLIRequestToOpenAI

func ConvertGeminiCLIRequestToOpenAI(modelName string, inputRawJSON []byte, stream bool) []byte

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.

func GeminiCLITokenCount added in v6.2.33

func GeminiCLITokenCount(ctx context.Context, count int64) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL