gpt4free-ts/model/index.ts

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

2023-05-05 10:57:42 +09:00
import {Chat, ChatOptions} from "./base";
import {You} from "./you";
2023-06-03 15:45:28 +09:00
import {Mcbbs} from "./mcbbs";
2023-06-13 21:54:45 +09:00
import {ChatDemo} from "./chatdemo";
2023-06-15 00:08:15 +09:00
import {Phind} from "./phind";
2023-05-04 22:32:21 +09:00
export enum Site {
2023-05-05 10:57:42 +09:00
// define new model here
You = 'you',
2023-06-15 00:08:15 +09:00
Phind = 'phind',
2023-06-03 15:45:28 +09:00
Mcbbs = 'mcbbs',
2023-06-13 21:54:45 +09:00
ChatDemo = 'chatdemo',
2023-05-04 23:01:55 +09:00
}
2023-05-05 10:57:42 +09:00
export class ChatModelFactory {
private modelMap: Map<Site, Chat>;
2023-05-05 10:57:42 +09:00
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(Site.You, new You(this.options))
2023-06-15 00:08:15 +09:00
this.modelMap.set(Site.Phind, new Phind(this.options))
this.modelMap.set(Site.Mcbbs, new Mcbbs(this.options))
2023-06-13 21:54:45 +09:00
this.modelMap.set(Site.ChatDemo, new ChatDemo(this.options))
2023-05-05 10:57:42 +09:00
}
2023-05-04 23:01:55 +09:00
get(model: Site): Chat | undefined {
2023-05-05 10:57:42 +09:00
return this.modelMap.get(model);
}
2023-05-04 22:32:21 +09:00
}