forked from coze-dev/coze-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.ts
47 lines (40 loc) · 1.19 KB
/
bot.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
import assert from 'assert';
import { client, spaceId } from './client.js';
async function main() {
assert(spaceId, 'spaceId is required');
const bot = await client.bots.create({
space_id: spaceId,
name: 'Translation Master',
description:
'A professional translator that helps translate between English and Chinese',
prompt_info: {
prompt:
'your are a translator, translate the following text from English to Chinese',
},
});
console.log('client.bots.create', bot);
const updatedBot = await client.bots.update({
bot_id: bot.bot_id,
name: 'test2',
description: 'test2',
});
console.log('client.bots.update', updatedBot);
const publishedBot = await client.bots.publish({
bot_id: bot.bot_id,
connector_ids: ['API'],
});
console.log('client.bots.publish', publishedBot);
const list = await client.bots.list({
space_id: spaceId,
page_index: 1,
page_size: 10,
});
console.log('client.bots.list', list);
if (list.space_bots.length > 0) {
const info = await client.bots.retrieve({
bot_id: list.space_bots[0].bot_id,
});
console.log('client.bots.retrieve', info);
}
}
main().catch(console.error);