donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
55 lines • 2.49 kB
TypeScript
import { JSONSchema7 } from 'json-schema';
import { AssistantMessage, GptMessage, ProposedToolCallsMessage, StructuredOutputMessage } from '../models/GptMessage';
import { GptClient, ToolOption } from './GptClient';
import { GoogleGeminiConfig } from '../models/GptConfig';
/**
* Implementation using the Google API
* @see https://ai.google.dev/api/all-methods#service:-generativelanguage.googleapis.com
*/
export declare class GoogleGptClient extends GptClient {
private readonly googleGeminiConfig;
private static readonly API_URL;
private static readonly REQUEST_TIMEOUT_MILLISECONDS;
private static readonly API_KEY_HEADER_NAME;
private static readonly CONTENT_TYPE;
private readonly headers;
/**
* Create a new instance.
* @param apiKey The Google API key to use for all requests with this client.
* @param modelName See https://ai.google.dev/gemini-api/docs/models/gemini for the list of models.
* @param apiUrl The URL of the API to use for all requests with this client.
*/
constructor(googleGeminiConfig: GoogleGeminiConfig);
ping(): Promise<void>;
getMessage(messages: GptMessage[]): Promise<AssistantMessage>;
getStructuredOutput(messages: GptMessage[], jsonSchema: JSONSchema7): Promise<StructuredOutputMessage>;
getToolCalls(messages: GptMessage[], tools: ToolOption[]): Promise<ProposedToolCallsMessage>;
/**
* Fix the "assert1" field issue in tool call parameters
* Recursively search and replace any field containing "assert1" with "assert"
*/
private static fixAssertFields;
private mapErrorResponseToDonobuException;
private makeRequest;
private static chatRequestMessageFromGptMessage;
private static toolChoiceFromTool;
/**
* Creates a new JSON schema compatible with Google's API.
*/
private static createGoogleCompatibleJsonSchema;
/**
* Recursively removes all "additionalProperties" fields from the JSON
* schema since Google does not support that keyword.
**/
private static removeAdditionalProperties;
/**
* Merges adjacent user messages because Google will otherwise reject the request.
*/
private static shenanigansUserMessageMerge;
/**
* Recursively replaces "type" fields that are arrays containing "null" with
* a single non-null type since Google will otherwise throw an error.
**/
private static normalizeTypeFields;
}
//# sourceMappingURL=GoogleGptClient.d.ts.map