gpt-simple-api-ts
Version:
A simple client GPT API written in TypeScript
28 lines (27 loc) • 1.51 kB
TypeScript
import { Configuration, OpenAIApi, CreateCompletionRequest, CreateChatCompletionRequest } from "openai-old";
import AbortController from "abort-controller";
export default class SimpleGPT {
protected _key: string;
protected _configuration: Configuration | null;
protected _openai: OpenAIApi | null;
protected req: any;
protected abortController: AbortController;
protected reader: any;
get chatModels(): string[];
get defaultOptsGPT(): Partial<CreateCompletionRequest>;
constructor({ key }: {
key: string;
});
transcribe(formData: FormData): Promise<any>;
getStream(prompt: string, fData: (raw: any, json: {
[key: string]: any;
}, delta: string) => any, fEnd: any, opts?: Partial<CreateCompletionRequest & CreateChatCompletionRequest>): Promise<void>;
abortStream(): void;
get(prompt: string, opts?: Partial<CreateCompletionRequest & CreateChatCompletionRequest>): Promise<null | string[]>;
getFirst(prompt: string, opts?: Partial<CreateCompletionRequest & CreateChatCompletionRequest>): Promise<string | undefined>;
getCode(prompt: string, opts?: Partial<CreateCompletionRequest>): Promise<null | string[]>;
getCodeFirst(prompt: string, opts?: Partial<CreateCompletionRequest>): Promise<string | undefined>;
getImages(prompt: string, n?: number, size?: (256 | 512 | 1024)): Promise<string[]>;
getImage(prompt: string, size?: (256 | 512 | 1024)): Promise<string | undefined>;
setApiKey(key: string): void;
}