#Dont have discord nitro so here is a txt

7 messages · Page 1 of 1 (latest)

sturdy swallow
#

What are you trying to do?

#

It's hard to tell what your issue is when you just toss a bunch of code in the chat and tell everyone to fix it for you

bold fable
#

I'm trying to create a reactjs front end that communicates a prompt to the server.js and make the response of server.js appear in the front end

#

using the openai api

#

sorry didnt mean to just toss a bunch of code in the chat and tell everyone to fix it for you

sturdy swallow
#

here is the code I wrote that does that for reference but my front end is all javascript:

//This function will take the GPT-3 prompt, add it to the api call, then return the result to client
app.post('/request_answer', async (req, res) => {
      const prompt = req.body.prompt;
      const temperature = Number(req.body.temperature);
      console.log(temperature);
      const endpoint = 'https://api.openai.com/v1/completions';
      const response = await axios.post(endpoint, {
          model: 'text-davinci-003',
          prompt: prompt,
          temperature: temperature,
          max_tokens: 250,
        }, {
          headers: {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer ' + apiKeys,
          }
      });
        res.send(response.data.choices[0].text);
    });