Skip to content
This repository has been archived by the owner on Oct 27, 2023. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyDJim authored Mar 3, 2023
1 parent 6765095 commit 99b13e1
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ const sendMessageToChatGPT = async (message) => {

try {
const response = await axios.post(
"https://api.openai.com/v1/engines/text-davinci-003/completions",
"https://api.openai.com/v1/chat/completions",
{
prompt: message,
model: "gpt-3.5-turbo",
messages: [{"role":"user", "content": message}],
temperature: 0.5,
max_tokens: 2048,
frequency_penalty: 0,
Expand All @@ -22,7 +23,7 @@ const sendMessageToChatGPT = async (message) => {
);

if (response && response.data && response.data.choices.length > 0) {
const chatGptResponse = response.data.choices[0].text.trim();
const chatGptResponse = response.data.choices[0].message.content.trim();
return chatGptResponse;
} else {
console.error("La réponse de l'API n'est pas disponible ou incorrecte");
Expand All @@ -39,14 +40,14 @@ const sendMessageToChatGPT = async (message) => {

const main = async () => {
const inquirer = require("inquirer");
console.log("Que puis-je pour vous ?");
console.log("Que puis-je faire pour vous ?");

while (true) {
const { message } = await inquirer.prompt([
{
type: "input",
name: "message",
message: "Vous: ",
message: "Vous : ",
},
]);

Expand All @@ -55,8 +56,8 @@ const main = async () => {
}

const chatGptResponse = await sendMessageToChatGPT(message);
console.log("ChatGPT:", chatGptResponse);
console.log("ChatGPT :", chatGptResponse);
}
};

main();
main();

0 comments on commit 99b13e1

Please sign in to comment.