Skip to content

Commit

Permalink
Tools
Browse files Browse the repository at this point in the history
  • Loading branch information
redji committed Apr 9, 2024
1 parent 49b08cb commit 7fa8621
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ let embeddingsTensor = {};
let searchAnswer = "";
let peopleAnswer = "";
let knowledgeAnswer = "";
let toolsAnswer = "";

fetch('https://tasks.aidevs.pl/token/helloapi', {
method: 'POST',
Expand Down Expand Up @@ -682,4 +683,48 @@ fetch('https://tasks.aidevs.pl/token/knowledge', {
}
})
.catch(error => console.error('Error:', error));
});
});
fetch('https://tasks.aidevs.pl/token/tools', {

method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ apikey: APIKey })
})
.then(async (response) => {
const data = await response.json();
const token = data.token;
const taskUrl = `https://tasks.aidevs.pl/task/${token}`;
const response2 = await makeRequestWithDelay(taskUrl, {
method: 'GET',
headers: {
'Content-Type': 'application/json'
}
}, 10);
console.log(response2)
await chatCompletion({
messages: [
{
role: 'system',
content: response2.msg + response2.hint + '. You must follow the format: { "tool": "UppercaseToolName", "desc": "descriptionOfTask", "date": "optionalDateOfEvent"'
},
{
role: 'user',
content: response2.question
}],
model: 'gpt-4',
}).then(async (response) => {
console.log(response.choices[0].message.content);
toolsAnswer = response.choices[0].message.content;
const response4 = await makeRequestWithDelay(`https://tasks.aidevs.pl/answer/${token}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({answer: JSON.parse(toolsAnswer)})
}, 10);
console.log('Answer from API', response4);
});
})
.catch(error => console.error('Error:', error));

0 comments on commit 7fa8621

Please sign in to comment.