33 行
597 B
TypeScript
33 行
597 B
TypeScript
import {Stream} from "stream";
|
|
|
|
export interface ChatOptions {
|
|
proxy?: string;
|
|
}
|
|
|
|
export interface Response {
|
|
text: string | null;
|
|
other?: any;
|
|
}
|
|
|
|
export interface ResponseStream {
|
|
text: Stream;
|
|
other?: any;
|
|
}
|
|
|
|
export interface Request {
|
|
prompt: string;
|
|
options?: any;
|
|
}
|
|
|
|
export abstract class Chat {
|
|
protected options: ChatOptions | undefined;
|
|
|
|
protected constructor(options?: ChatOptions) {
|
|
this.options = options;
|
|
}
|
|
|
|
public abstract ask(req: Request): Promise<Response>
|
|
|
|
public abstract askStream(req: Request): Promise<ResponseStream>
|
|
}
|