UNPKG

@gentrace/openai

Version:

Gentrace OpenAI v4 plugin for Node.JS

97 lines (96 loc) 4.62 kB
import { Configuration as GentraceConfiguration, PipelineRun, PluginStepRunContext } from "@gentrace/core"; import OpenAI from "openai"; import { RequestOptions } from "openai/core"; import { ExtractParsedContentFromParams } from "openai/lib/parser"; import { Completion, CreateEmbeddingResponse, EmbeddingCreateParams } from "openai/resources"; import { ChatCompletionParseParams, ParsedChatCompletion } from "openai/resources/beta/chat/completions"; import { ChatCompletionChunk } from "openai/resources/chat"; import { GentraceBetaChatCompletions, GentraceChatCompletion, GentraceChatCompletionCreateParams, GentraceChatCompletionCreateParamsNonStreaming, GentraceChatCompletionCreateParamsStreaming, GentraceChatCompletions, GentraceClientOptions, GentraceCompletion, GentraceCompletionCreateParamsNonStreaming, GentraceCompletionCreateParamsStreaming, GentraceCompletions, GentraceEmbeddings, GentraceStream, OpenAIPipelineHandler } from "../openai"; import { Chat } from "openai/resources/beta/chat/chat"; type OpenAIPipelineHandlerOptions = { pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }; declare class AdvancedOpenAI extends OpenAIPipelineHandler { beta: AdvancedGentraceBeta; completions: AdvancedGentraceCompletions; chat: AdvancedGentraceChat; embeddings: AdvancedGentraceEmbeddings; constructor(options: GentraceClientOptions & OpenAIPipelineHandlerOptions); } declare class AdvancedGentraceEmbeddings extends GentraceEmbeddings { constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); create(body: EmbeddingCreateParams & { pipelineSlug?: string; gentrace?: PluginStepRunContext; }, options?: RequestOptions): Promise<CreateEmbeddingResponse & { pipelineRunId?: string; }>; } export declare class AdvancedGentraceCompletions extends GentraceCompletions { constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); create(body: Omit<GentraceCompletionCreateParamsNonStreaming, "gentrace"> & { gentrace?: PluginStepRunContext; }, options?: RequestOptions): Promise<GentraceCompletion>; create(body: Omit<GentraceCompletionCreateParamsStreaming, "gentrace"> & { gentrace?: PluginStepRunContext; }, options?: RequestOptions): Promise<GentraceStream<Completion> & { pipelineRunId?: string; }>; } export declare class AdvancedGentraceBeta extends OpenAI.Beta { chat: AdvancedGentraceBetaChat; constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); } export declare class AdvancedGentraceBetaChat extends Chat { completions: AdvancedGentraceBetaChatCompletions; constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); } declare class AdvancedGentraceBetaChatCompletions extends GentraceBetaChatCompletions { constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); parse<Params extends ChatCompletionParseParams, ParsedT = ExtractParsedContentFromParams<Params>>(body: GentraceChatCompletionCreateParams, options?: RequestOptions): Promise<ParsedChatCompletion<ParsedT>>; } export declare class AdvancedGentraceChat extends OpenAI.Chat { completions: AdvancedGentraceChatCompletions; constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); } declare class AdvancedGentraceChatCompletions extends GentraceChatCompletions { constructor({ client, pipelineRun, gentraceConfig, }: { client: OpenAI; pipelineRun?: PipelineRun; gentraceConfig: GentraceConfiguration; }); create(body: Omit<GentraceChatCompletionCreateParamsNonStreaming, "gentrace"> & { gentrace?: PluginStepRunContext; }, options?: RequestOptions): Promise<GentraceChatCompletion>; create(body: Omit<GentraceChatCompletionCreateParamsStreaming, "gentrace"> & { gentrace?: PluginStepRunContext; }, options?: RequestOptions): Promise<GentraceStream<ChatCompletionChunk> & { pipelineRunId?: string; }>; } export { AdvancedOpenAI };