#My bot doesn't follow the prompt

5 messages ยท Page 1 of 1 (latest)

plush plover
#

It is very difficult to debug unformatted code.

royal gorge
plush plover
royal gorge
#

So the full code: (The bot only wants to play rock papper scissors)
`
import express from 'express'
import * as dotenv from 'dotenv'
import cors from 'cors'
import { Configuration, OpenAIApi } from 'openai'

dotenv.config()

const configuration = new Configuration({
organization: "org-1qRKkImcSydGgPawExBmm6vR",
apiKey: process.env.OPENAI_API_KEY,
});

const openai = new OpenAIApi(configuration);

const app = express()
app.use(cors())
app.use(express.json())

app.get('/', async (req, res) => {
res.status(200).send({
message: 'Hello from Clonaz!1'

})
})

let previousResponses = [];
previousResponses.join("I want you to act as if you are a classic text adventure game and we are playing. If I want to give you instructions outside the context of the game, I will use curly brackets {like this} but otherwise you are to stick to being the text adventure program. In this game, the setting is a fantasy adventure world inspired by Brandon Sanderson's Roshar. Each encounter should have at least 3 sentence descriptions. Start by a short description of the word, and then i will create my character.")

app.post('/', async (req, res) => {
try {
const prompt = req.body.prompt;
previousResponses.join("REMEMBER : Speak only in english.");
previousResponses.join("I want you to act as if you are a classic text adventure game and we are playing. If I want to give you instructions outside the context of the game, I will use curly brackets {like this} but otherwise you are to stick to being the text adventure program. In this game, the setting is a fantasy adventure world inspired by Brandon Sanderson's Roshar. Each encounter should have at least 3 sentence descriptions. Start by a short description of the word, and then i will create my character.")

// Add previous responses to the prompt for context
let context = previousResponses.join(" ");
let updatedPrompt = `${context} ${prompt}`;
console.log(updatedPrompt); 

const response = await openai.createCompletion({
  model: "text-davinci-003",
  prompt: updatedPrompt,
  temperature: 0.5,
  max_tokens: 1000,
  frequency_penalty: 0,
  presence_penalty: 0,
});
    // Add the response to the list of previous responses
previousResponses.push(response.data.choices[0].text);
res.status(200).send({
bot: response.data.choices[0].text
});
console.log(updatedPrompt); 

} catch (error) {
console.error(error+"a a"+updatedPrompt+" ")
console.log(updatedPrompt);
res.status(500).send(error || 'Something went wrong'+updatedPrompt);
}
console.log(updatedPrompt);

})

app.listen(5000, () => console.log('AI server started on http://localhost:5000'))
`