Skip to content

Commit

Permalink
Update custom.js
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovannaNaves committed Oct 14, 2024
1 parent 96ac987 commit fee3f57
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/pages/js/custom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const form = document.getElementById('topicForm');
const { OpenAI } = require('openai');

const api = new OpenAI({
baseURL: 'https://api.aimlapi.com',
//apiKey:
});

if (form) {

form.addEventListener("submit", async (e) => {

e.preventDefault();

const result = await api.chat.completions.create({
model: 'meta-llama/Meta-Llama-3-70B-Instruct-Lite',
messages: [
{
role: 'system',
content: 'Você deve responder com um passo a passo em tópicos.',
},
{
role: 'user',
content: 'Como salvo um contato no celular?'
}
],
});

const message = result.choices[0].message.content;
console.log(`Assistant: ${message}`);
});
}

0 comments on commit fee3f57

Please sign in to comment.