What's new

Help Javascript - OpenAI Reply Function.

WizKhalifaX_

Forum Expert
Elite
Joined
Apr 13, 2017
Posts
4,602
Solutions
53
Reaction
13,362
Points
2,720
Age
20

MAGANDANG UMAGA MGA KUYS​

Sa mga gising na mamaw mag code jan, baka pwede po maka hingi ng tulong about dito sa javascript code po ng OpenAI​
JavaScript:
const { Configuration, OpenAIApi } = require("openai");
const fs = require("fs")
const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8'))
const configuration = new Configuration({apiKey: apikey.openai});
const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) {
    var text = matches[1];
  console.log(matches)
  const response = await openai.createCompletion({
    model: "text-davinci-003",
    prompt: event.body,
    temperature: 0.3,
    max_tokens: 3000,

  });
  api.sendMessage(`${response.data.choices[0].text}`, event.threadID)
}
module.exports = ai;

Bali ang gusto kopo sana na mag reply yung bot sa akin, ang ginagawa nya po kasi is rektahan lng sha mag sagot;
1674918092416.png


Want ko sana na yung response nya is gaya nito;
1674918131857.png

Sa /ai lng po sha di nag rereply pero the rest sa command nagana naman, nag trial and error pala ako kanina pero bigo sabi daw invalid or unknown function :<
 

Attachments

const { Configuration, OpenAIApi } = require("openai"); const fs = require("fs"); const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8')); const configuration = new Configuration({apiKey: apikey.openai}); const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) { console.log(matches); const response = await openai.createCompletion({ model: "text-davinci-003", prompt: event.body, temperature: 0.3, max_tokens: 3000 });

const timestamp = new Date().toLocaleString(); const description = "Generated response:"; const message = ${timestamp}\n${description}\n${response.data.choices[0].text};

api.sendMessage(message, event.threadID); }

module.exports = ai;
 
const { Configuration, OpenAIApi } = require("openai"); const fs = require("fs"); const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8')); const configuration = new Configuration({apiKey: apikey.openai}); const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) { console.log(matches); const response = await openai.createCompletion({ model: "text-davinci-003", prompt: event.body, temperature: 0.3, max_tokens: 3000 });

const timestamp = new Date().toLocaleString(); const description = "Generated response:"; const message = ${timestamp}\n${description}\n${response.data.choices[0].text};

api.sendMessage(message, event.threadID); }

module.exports = ai;
Try koto kya wait;
try mo yung answer ni Oogari. Add mo nlng yung 'Definition' sa sagot nya.
OO kya trying...

Ano Telegram nyo kya?

shigawaka

Oagari yo


const { Configuration, OpenAIApi } = require("openai"); const fs = require("fs"); const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8')); const configuration = new Configuration({apiKey: apikey.openai}); const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) { console.log(matches); const response = await openai.createCompletion({ model: "text-davinci-003", prompt: event.body, temperature: 0.3, max_tokens: 3000 });

const timestamp = new Date().toLocaleString(); const description = "Generated response:"; const message = ${timestamp}\n${description}\n${response.data.choices[0].text};

api.sendMessage(message, event.threadID); }

module.exports = ai;
Ay na misunderstood ata oo tama ngato kya;
1675830429684.png

Meron yung Description tapos yung date and time, pero what I mean po sana is yang bot is mag reply jan sa command kong /ai Give me.... which is gaya ng ginawa ko sa lezzz go pro häçkerist yang may kinda gray or parang nag reply sha sa mismong msg ko xD
 

Attachments

Last edited:
const { Configuration, OpenAIApi } = require("openai"); const fs = require("fs"); const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8')); const configuration = new Configuration({apiKey: apikey.openai}); const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) { console.log(matches); const response = await openai.createCompletion({ model: "text-davinci-003", prompt: event.body, temperature: 0.3, max_tokens: 3000 });

const timestamp = new Date().toLocaleString(); const description = "Generated response:"; const message = ${timestamp}\n${description}\n${response.data.choices[0].text};

api.sendMessage(message, event.threadID); }

module.exports = ai;
palitan mo yung sa module exports ng lessgo pro häçkerist or ai Give me....
 
const { Configuration, OpenAIApi } = require("openai");
const fs = require("fs");
const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8'));
const configuration = new Configuration({apiKey: apikey.openai});
const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) {
console.log(matches);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: event.body,
temperature: 0.3,
max_tokens: 3000
});

const timestamp = new Date().toLocaleString();
const language = "Language: English";
const description = "Generated response:";
const message = Successfully Generated a Speech Synthesis\n\n${language}\n\n${timestamp}\n${description}\n${response.data.choices[0].text};

api.sendMessage(message, event.threadID);
}

module.exports = ai;
 
const { Configuration, OpenAIApi } = require("openai");
const fs = require("fs");
const apikey = JSON.parse(fs.readFileSync('./api_key.json', 'utf8'));
const configuration = new Configuration({apiKey: apikey.openai});
const openai = new OpenAIApi(configuration);

async function ai(matches, event, api) {
console.log(matches);
const response = await openai.createCompletion({
model: "text-davinci-003",
prompt: event.body,
temperature: 0.3,
max_tokens: 3000
});

const timestamp = new Date().toLocaleString();
const language = "Language: English";
const description = "Generated response:";
const message = Successfully Generated a Speech Synthesis\n\n${language}\n\n${timestamp}\n${description}\n${response.data.choices[0].text};

api.sendMessage(message, event.threadID);
}

module.exports = ai;
1676325513419.png

btw baka naman kya pa help ulit ako dito sa OpenAI Ko yung reply function sana haha
 

Attachments

Back
Top