-
Notifications
You must be signed in to change notification settings - Fork 6
/
multi-llms.ts
58 lines (49 loc) · 1.52 KB
/
multi-llms.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { codeBlock } from 'common-tags';
import {
ChatType,
createAssistant,
createMockTextMessage,
MultiChatModelSwitch,
} from '../../src';
const assistant = createAssistant({
llm: new MultiChatModelSwitch([
{
name: 'yiyan',
human_name: '文心一言',
input_type: [ChatType.Text],
call(ctx) {
console.log('[文心一言] 收到', ctx.message.text());
},
},
{
name: 'xinghuo',
human_name: '讯飞星火',
input_type: [ChatType.Text],
greeting: codeBlock`
您好,我是讯飞星火认知大模型!
能够学习和理解人类的语言,进行多轮对话。
回答问题,高效便捷地帮助人们获取信息、知识和灵感。`,
call(ctx) {
console.log('[讯飞星火] 收到', ctx.message.text());
},
},
]),
});
async function main() {
assistant.run();
console.log('查看模型\n');
await assistant.handler(createMockTextMessage('查看模型'));
console.log('\n');
await assistant.handler(createMockTextMessage('第一次对话'));
console.log('\n---------------\n');
console.log('切换星火\n');
await assistant.handler(createMockTextMessage('切换星火'));
console.log('\n');
await assistant.handler(createMockTextMessage('第二次对话'));
console.log('\n---------------\n');
console.log('查看模型\n');
await assistant.handler(createMockTextMessage('查看模型'));
console.log('\n');
await assistant.handler(createMockTextMessage('第三次对话'));
}
main();