gpt4free-ts/model/index.ts

37 行
999 B
TypeScript
Raw 通常表示 履歴

2023-05-05 10:57:42 +09:00
import {Chat, ChatOptions} from "./base";
import {You} from "./you";
2023-05-11 11:39:59 +09:00
import {AiDream} from "./aidream";
2023-05-12 18:16:25 +09:00
import {Forefrontnew} from "./forefront";
2023-06-03 15:45:28 +09:00
import {Mcbbs} from "./mcbbs";
2023-05-04 22:32:21 +09:00
2023-05-05 10:57:42 +09:00
export enum Model {
// define new model here
You = 'you',
2023-05-05 19:36:27 +09:00
Forefront = 'forefront',
2023-05-11 11:39:59 +09:00
AiDream = 'aidream',
2023-06-03 15:45:28 +09:00
Mcbbs = 'mcbbs',
2023-05-04 23:01:55 +09:00
}
2023-05-05 10:57:42 +09:00
export class ChatModelFactory {
private modelMap: Map<Model, Chat>;
private readonly options: ChatOptions | undefined;
2023-05-04 23:01:55 +09:00
constructor(options?: ChatOptions) {
2023-05-05 10:57:42 +09:00
this.modelMap = new Map();
this.options = options;
this.init();
2023-05-04 23:01:55 +09:00
}
2023-05-05 10:57:42 +09:00
init() {
// register new model here
this.modelMap.set(Model.You, new You(this.options))
2023-05-12 18:16:25 +09:00
this.modelMap.set(Model.Forefront, new Forefrontnew(this.options))
2023-05-11 11:39:59 +09:00
this.modelMap.set(Model.AiDream, new AiDream(this.options))
2023-06-03 15:45:28 +09:00
this.modelMap.set(Model.Mcbbs, new Mcbbs(this.options))
2023-05-05 10:57:42 +09:00
}
2023-05-04 23:01:55 +09:00
2023-05-05 10:57:42 +09:00
get(model: Model): Chat | undefined {
return this.modelMap.get(model);
}
2023-05-04 22:32:21 +09:00
}