UNPKG

@ai2070/l0

Version:

L0: The Missing Reliability Substrate for AI

28 lines 2.53 kB
import type { L0Event, L0Adapter } from "../types/l0"; import type { Stream } from "openai/streaming"; import type { ChatCompletionChunk, ChatCompletionCreateParamsStreaming, ChatCompletionTool, ChatCompletionMessageParam } from "openai/resources/chat/completions"; export interface OpenAIClient { chat: { completions: { create(params: ChatCompletionCreateParamsStreaming): Promise<Stream<ChatCompletionChunk> | AsyncIterable<ChatCompletionChunk>>; }; }; } export interface OpenAIAdapterOptions { includeUsage?: boolean; includeToolCalls?: boolean; emitFunctionCallsAsTokens?: boolean; choiceIndex?: number | "all"; } export declare function wrapOpenAIStream(stream: Stream<ChatCompletionChunk> | AsyncIterable<ChatCompletionChunk>, options?: OpenAIAdapterOptions): AsyncGenerator<L0Event>; export declare function openaiStream(client: OpenAIClient, params: Omit<ChatCompletionCreateParamsStreaming, "stream">, options?: OpenAIAdapterOptions): () => Promise<AsyncGenerator<L0Event>>; export declare function openaiText(client: OpenAIClient, model: string, prompt: string | ChatCompletionMessageParam[], options?: Omit<ChatCompletionCreateParamsStreaming, "model" | "messages" | "stream"> & OpenAIAdapterOptions): () => Promise<AsyncGenerator<L0Event>>; export declare function openaiJSON(client: OpenAIClient, model: string, prompt: string | ChatCompletionMessageParam[], options?: Omit<ChatCompletionCreateParamsStreaming, "model" | "messages" | "stream" | "response_format"> & OpenAIAdapterOptions): () => Promise<AsyncGenerator<L0Event>>; export declare function openaiWithTools(client: OpenAIClient, model: string, messages: ChatCompletionMessageParam[], tools: ChatCompletionTool[], options?: Omit<ChatCompletionCreateParamsStreaming, "model" | "messages" | "stream" | "tools"> & OpenAIAdapterOptions): () => Promise<AsyncGenerator<L0Event>>; export declare function isOpenAIChunk(obj: unknown): obj is ChatCompletionChunk; export declare function extractOpenAIText(stream: Stream<ChatCompletionChunk> | AsyncIterable<ChatCompletionChunk>): Promise<string>; export type OpenAIStream = Stream<ChatCompletionChunk> | AsyncIterable<ChatCompletionChunk>; export declare function isOpenAIStream(input: unknown): input is OpenAIStream; export declare const openaiAdapter: L0Adapter<OpenAIStream, OpenAIAdapterOptions>; export type { ChatCompletionChunk, ChatCompletionCreateParamsStreaming, ChatCompletionTool, ChatCompletionMessageParam, }; //# sourceMappingURL=openai.d.ts.map