donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
54 lines • 2.44 kB
TypeScript
import { z } from 'zod/v4';
import type { OpenAiConfig } from '../models/GptConfig';
import type { AssistantMessage, GptMessage, ProposedToolCallsMessage, StructuredOutputMessage } from '../models/GptMessage';
import type { ToolOption } from './GptClient';
import { GptClient } from './GptClient';
/**
* A GPT client implemented using the OpenAI API.
* @see https://platform.openai.com/docs/api-reference/chat
*/
export declare class OpenAiGptClient extends GptClient {
private readonly openAiConfig;
private readonly apiUrl;
private static readonly DEFAULT_API_URL;
private static readonly REQUEST_TIMEOUT_MILLISECONDS;
private readonly headers;
constructor(openAiConfig: OpenAiConfig, apiUrl?: string);
ping(options?: {
signal?: AbortSignal;
}): Promise<void>;
getMessage(messages: GptMessage[], options?: {
signal?: AbortSignal;
}): Promise<AssistantMessage>;
getStructuredOutput<T>(messages: GptMessage[], zodSchema: z.ZodSchema<T>, options?: {
signal?: AbortSignal;
}): Promise<StructuredOutputMessage<T>>;
getToolCalls(messages: GptMessage[], tools: ToolOption[], options?: {
signal?: AbortSignal;
}): Promise<ProposedToolCallsMessage>;
private chatRequestMessageFromGptMessage;
private toolChoiceFromTool;
private parseAssistantMessage;
private parseStructuredOutputMessage;
private parseProposedToolCallsMessage;
private mapErrorResponseToDonobuException;
/**
* Makes an HTTP request to the OpenAI API with standard configuration.
*/
private makeRequest;
/**
* Transform a general JSON Schema into one that fits the OpenAI Structured Outputs subset.
* Key behaviors:
* - Enforce additionalProperties:false on objects and require all defined properties.
* - Remove unsupported validation keywords.
* - Convert tuple `items: [A,B]` into `items: { anyOf: [A,B] }`.
* - Preserve $ref and $defs, cleaning nested definitions recursively.
* - If the root is `anyOf`, wrap it into an object schema with a single `value` property.
*
* Notes for optional fields:
* - Since all fields must be required, emulate optionals with union types that include "null".
* e.g., `type: ["string", "null"]` while keeping the field in `required`.
*/
private static createOpenAiCompatibleJsonSchema;
}
//# sourceMappingURL=OpenAiGptClient.d.ts.map