gpt4free-ts/model/index.ts

46 行
1.3 KiB
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-06-17 20:38:29 +09:00
import {Vita} from "./vita";
2023-06-29 12:33:37 +09:00
import {FakeOpen} from "./fakeopen";
2023-06-29 18:24:08 +09:00
import {Better} from "./better";
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-06-17 20:38:29 +09:00
Vita = 'vita',
2023-06-29 12:33:37 +09:00
FakeOpen = 'fakeopen',
2023-06-29 18:24:08 +09:00
Better = 'better',
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-06-17 20:38:29 +09:00
this.modelMap.set(Site.Vita, new Vita(this.options))
2023-06-29 12:33:37 +09:00
this.modelMap.set(Site.FakeOpen, new FakeOpen(this.options))
2023-06-29 18:24:08 +09:00
this.modelMap.set(Site.Better, new Better(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
}