import { JSONSchema7Object } from "json-schema"; import { ChatCompletionTool } from "openai/resources/index.mjs"; export interface GeminiGenerationConfig { stopSequences?: string[]; responseMimeType?: string; candidateCount?: number; maxOutputTokens?: number; temperature?: number; topP?: number; topK?: number; presencePenalty?: number; frequencyPenalty?: number; responseLogprobs?: boolean; logprobs?: number; } export type GeminiObjectSchemaType = "TYPE_UNSPECIFIED" | "STRING" | "NUMBER" | "INTEGER" | "BOOLEAN" | "ARRAY" | "OBJECT"; export interface GeminiObjectSchema { type: GeminiObjectSchemaType; format?: string; title?: string; description?: string; nullable?: boolean; enum?: string[]; maxItems?: string; minItems?: string; properties?: Record; required?: string[]; anyOf?: GeminiObjectSchema[]; propertyOrdering?: string[]; items?: GeminiObjectSchema; minimum?: number; maximum?: number; } export declare function convertOpenAIToolToGeminiFunction(tool: ChatCompletionTool): GeminiToolFunctionDeclaration; export type GeminiTextContentPart = { text: string; }; export type GeminiInlineDataContentPart = { inlineData: { mimeType: string; data: string; }; }; export type GeminiFunctionCallContentPart = { functionCall: { id?: string; name: string; args: JSONSchema7Object; }; }; export type GeminiFunctionResponseContentPart = { functionResponse: { id?: string; name: string; response: JSONSchema7Object; }; }; export type GeminiFileDataContentPart = { fileData: { fileUri: string; mimeType: string; }; }; export type GeminiExecutableCodeContentPart = { executableCode: { language: "PYTHON" | "LANGUAGE_UNSPECIFIED"; code: string; }; }; export type GeminiCodeExecutionResultContentPart = { codeExecutionResult: { outcome: "OUTCOME_UNSPECIFIED" | "OUTCOME_OK" | "OUTCOME_FAILED" | "OUTCOME_DEADLINE_EXCEEDED"; output: string; }; }; export type GeminiChatContentPart = GeminiTextContentPart | GeminiInlineDataContentPart | GeminiFunctionCallContentPart | GeminiFunctionResponseContentPart | GeminiFileDataContentPart | GeminiExecutableCodeContentPart | GeminiCodeExecutionResultContentPart; export interface GeminiChatContent { role?: "user" | "model"; parts: GeminiChatContentPart[]; } export interface GeminiToolFunctionDeclaration { name: string; description: string; parameters?: GeminiObjectSchema; response?: GeminiObjectSchema; } export interface GeminiTool { functionDeclarations?: GeminiToolFunctionDeclaration[]; googleSearchRetrieval?: { dynamicRetrievalConfig: { mode?: "MODE_DYNAMIC" | "MODE_UNSPECIFIED"; dynamicThreshold?: number; }; }; codeExecution?: {}; } export interface GeminiToolConfig { functionCallingConfig?: { mode?: "NONE" | "ANY" | "AUTO"; allowedFunctionNames?: string[]; }; } export interface GeminiChatRequestBody { contents: GeminiChatContent[]; tools?: GeminiTool[]; toolConfig?: GeminiToolConfig; systemInstruction?: GeminiChatContent; generationConfig?: GeminiGenerationConfig; } export interface GeminiChatResponseSuccess { candidates: Candidate[]; promptFeedback: PromptFeedback; usageMetadata: UsageMetadata; } export interface GeminiChatResponseError { error: { message: string; }; } export type GeminiChatResponse = GeminiChatResponseError | GeminiChatResponseSuccess; interface PromptFeedback { blockReason?: BlockReason; safetyRatings: SafetyRating[]; } declare enum BlockReason { BLOCK_REASON_UNSPECIFIED = "BLOCK_REASON_UNSPECIFIED", SAFETY = "SAFETY", OTHER = "OTHER", BLOCKLIST = "BLOCKLIST", PROHIBITED_CONTENT = "PROHIBITED_CONTENT" } interface SafetyRating { harmCategory: HarmCategory; harmProbability: HarmProbability; blocked: boolean; } declare enum HarmCategory { HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED", HARM_CATEGORY_DEROGATORY = "HARM_CATEGORY_DEROGATORY", HARM_CATEGORY_TOXICITY = "HARM_CATEGORY_TOXICITY", HARM_CATEGORY_VIOLENCE = "HARM_CATEGORY_VIOLENCE", HARM_CATEGORY_SEXUAL = "HARM_CATEGORY_SEXUAL", HARM_CATEGORY_MEDICAL = "HARM_CATEGORY_MEDICAL", HARM_CATEGORY_DANGEROUS = "HARM_CATEGORY_DANGEROUS", HARM_CATEGORY_HARASSMENT = "HARM_CATEGORY_HARASSMENT", HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH", HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT", HARM_CATEGORY_DANGEROUS_CONTENT = "HARM_CATEGORY_DANGEROUS_CONTENT", HARM_CATEGORY_CIVIC_INTEGRITY = "HARM_CATEGORY_CIVIC_INTEGRITY" } declare enum HarmProbability { HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED", NEGLIGIBLE = "NEGLIGIBLE", LOW = "LOW", MEDIUM = "MEDIUM", HIGH = "HIGH" } interface UsageMetadata { promptTokenCount: number; cachedContentTokenCount: number; candidatesTokenCount: number; totalTokenCount: number; } interface Candidate { content: GeminiChatContent; finishReason: FinishReason; safetyRatings: SafetyRating[]; tokenCount: number; groundingAttribution?: GroundingAttribution; groundingMetadata?: GroundingMetadata; avgLogprobs?: number; logprobs?: LogprobsResult; index: number; } declare enum FinishReason { FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", STOP = "STOP", MAX_TOKENS = "MAX_TOKENS", SAFETY = "SAFETY", RECITATION = "RECITATION", LANGUAGE = "LANGUAGE", OTHER = "OTHER", BLOCKLIST = "BLOCKLIST", PROHIBITED_CONTENT = "PROHIBITED_CONTENT", SPII = "SPII", MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL" } interface GroundingAttribution { attributionSourceId: AttributionSourceId; groundingSourceContent: string; } interface AttributionSourceId { groundingPassage?: GroundingPassageId; semanticRetrieverChunk?: SemanticRetrieverChunk; } interface GroundingPassageId { passageId: string; partIndex: number; } interface SemanticRetrieverChunk { source: string; chunk: string; } interface GroundingMetadata { groundingSupport?: GroundingSupport[]; webSearchQueries?: string[]; searchEntryPoint?: SearchEntryPoint; retrievalMetadata?: RetrievalMetadata; } interface SearchEntryPoint { renderedContent?: string; sdkBlob?: string; } interface RetrievalMetadata { googleSearchDynamicRetrievalScore?: number; } interface GroundingSupport { groundingChunkIndices: number[]; confidenceScores: number[]; segment: Segment; } interface Segment { partIndex: number; startIndex: number; endIndex: number; text: string; } interface LogprobsResult { topCandidates: TopCandidates[]; chosenCandidates: Candidate[]; } interface TopCandidates { candidates: Candidate[]; } export {};