-
Notifications
You must be signed in to change notification settings - Fork 3
/
misc
45 lines (38 loc) · 1.3 KB
/
misc
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
const openai = new OpenAI({
apiKey: PUBLIC_OPENAI_KEY,
dangerouslyAllowBrowser: true
});
// // Create assistant
// openai.beta.assistants.create({
// name: 'Netsepio Website Summary author',
// instructions: 'You are to summarize what a website does',
// model: 'gpt-3.5-turbo-1106',
// tools: [
// {
// type: 'retrieval'
// }
// ]
// });
const getWebSummary = async () => {
// Retrieve Assistant
const assistant = await openai.beta.assistants.retrieve('asst_ql9zGVcypf5zKHeRwbd8TsCM');
const thread = await openai.beta.threads.create();
//Create Message
const createMessage = await openai.beta.threads.messages.create(thread?.id, {
role: 'user',
content: 'Summarize this website "google.com"'
});
// Run Assistant
const run = await openai.beta.threads.runs.create(thread?.id, {
assistant_id: assistant?.id,
instructions:
'Reply as if the user is just finding out about the website for the first time and the summary must be between 350 - 500 words, nothing more, nothing less.'
});
const retrieveStatus = await openai.beta.threads.runs.retrieve(thread?.id, run?.id);
console.log(retrieveStatus);
const messages = await openai.beta.threads.messages.list(thread?.id);
messages?.body?.data.forEach((message) => {
console.log(message?.content);
});
};
// onMount(() => getWebSummary());