@gentrace/openai
Version:
Gentrace OpenAI v4 plugin for Node.JS
95 lines (94 loc) • 4.56 kB
TypeScript
import { Configuration as GentraceConfiguration, PipelineRun, PluginContext, SimpleHandler } from "@gentrace/core";
import OpenAI from "openai";
import { ChatCompletionParseParams, ParsedChatCompletion } from "openai/resources/beta/chat/completions";
import { RequestOptions } from "openai/core";
import { Completion, CreateEmbeddingResponse, EmbeddingCreateParams } from "openai/resources";
import { ChatCompletionChunk } from "openai/resources/chat";
import { GentraceBetaChatCompletions, GentraceChatCompletion, GentraceChatCompletionCreateParams, GentraceChatCompletionCreateParamsNonStreaming, GentraceChatCompletionCreateParamsStreaming, GentraceChatCompletions, GentraceClientOptions, GentraceCompletion, GentraceCompletionCreateParamsNonStreaming, GentraceCompletionCreateParamsStreaming, GentraceCompletions, GentraceEmbeddings, GentraceStream, OpenAIPipelineHandler } from "../openai";
import { ExtractParsedContentFromParams } from "openai/lib/parser";
import { Chat } from "openai/resources/beta/chat/chat";
declare class SimpleOpenAI extends OpenAIPipelineHandler implements SimpleHandler<GentraceClientOptions> {
beta: SimpleGentraceBeta;
completions: SimpleGentraceCompletions;
chat: SimpleGentraceChat;
embeddings: SimpleGentraceEmbeddings;
constructor(options: GentraceClientOptions);
getConfig(): GentraceClientOptions;
setPipelineRun(pipelineRun: PipelineRun): void;
}
declare class SimpleGentraceEmbeddings extends GentraceEmbeddings {
constructor({ client, pipelineRun, gentraceConfig, }: {
client: OpenAI;
pipelineRun?: PipelineRun;
gentraceConfig: GentraceConfiguration;
});
create(body: EmbeddingCreateParams & {
pipelineSlug?: string;
gentrace?: PluginContext;
}, options?: RequestOptions): Promise<CreateEmbeddingResponse & {
pipelineRunId?: string;
}>;
}
export declare class SimpleGentraceCompletions extends GentraceCompletions {
constructor({ client, pipelineRun, gentraceConfig, }: {
client: OpenAI;
pipelineRun?: PipelineRun;
gentraceConfig: GentraceConfiguration;
});
create(body: Omit<GentraceCompletionCreateParamsNonStreaming, "gentrace"> & {
gentrace?: PluginContext;
}, options?: RequestOptions): Promise<GentraceCompletion>;
create(body: Omit<GentraceCompletionCreateParamsStreaming, "gentrace"> & {
gentrace?: PluginContext;
}, options?: RequestOptions): Promise<GentraceStream<Completion> & {
pipelineRunId?: string;
}>;
}
export declare class SimpleGentraceBeta extends OpenAI.Beta {
chat: SimpleGentraceBetaChat;
constructor({ client, pipelineRun, gentraceConfig, }: {
client: OpenAI;
pipelineRun?: PipelineRun;
gentraceConfig: GentraceConfiguration;
});
}
export declare class SimpleGentraceBetaChat extends Chat {
completions: SimpleGentraceBetaChatCompletions;
constructor({ client, pipelineRun, gentraceConfig, }: {
client: OpenAI;
pipelineRun?: PipelineRun;
gentraceConfig: GentraceConfiguration;
});
}
declare class SimpleGentraceBetaChatCompletions 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 SimpleGentraceChat extends OpenAI.Chat {
completions: SimpleGentraceChatCompletions;
constructor({ client, pipelineRun, gentraceConfig, }: {
client: OpenAI;
pipelineRun?: PipelineRun;
gentraceConfig: GentraceConfiguration;
});
}
declare class SimpleGentraceChatCompletions extends GentraceChatCompletions {
constructor({ client, pipelineRun, gentraceConfig, }: {
client: OpenAI;
pipelineRun?: PipelineRun;
gentraceConfig: GentraceConfiguration;
});
create(body: Omit<GentraceChatCompletionCreateParamsNonStreaming, "gentrace"> & {
gentrace?: PluginContext;
}, options?: RequestOptions): Promise<GentraceChatCompletion>;
create(body: Omit<GentraceChatCompletionCreateParamsStreaming, "gentrace"> & {
gentrace?: PluginContext;
}, options?: RequestOptions): Promise<GentraceStream<ChatCompletionChunk> & {
pipelineRunId?: string;
}>;
}
export { SimpleOpenAI };