Remove stop word and logging

This commit is contained in:
Tobias Wasner 2023-01-16 23:52:15 +01:00
parent 71272151bb
commit e5934e28fa

View File

@ -64,7 +64,6 @@ async function getResponse(history, res) {
// history: {msg: string, ai: boolean}[] // history: {msg: string, ai: boolean}[]
const prompt = staticPrefix + '\n' + history.map(hist => hist.msg).join("\n"); const prompt = staticPrefix + '\n' + history.map(hist => hist.msg).join("\n");
console.log("prompt: " + prompt);
try { try {
const response = await openai.createCompletion({ const response = await openai.createCompletion({
@ -74,17 +73,15 @@ async function getResponse(history, res) {
max_tokens: 500, max_tokens: 500,
top_p: 1, top_p: 1,
frequency_penalty: 0.5, frequency_penalty: 0.5,
presence_penalty: 0.6, presence_penalty: 0.6
stop: ["\n"],
}); });
console.log("got from openai: " + JSON.stringify(response.data)); // console.log("got from openai: " + JSON.stringify(response.data));
history.push({ history.push({
msg: response.data.choices[0].text, msg: response.data.choices[0].text,
ai: true ai: true
}) })
res.status(200).json(history).end(); res.status(200).json(history).end();
} catch(error) { } catch(error) {
console.error(error);
console.error(error.response.status, error.response.data); console.error(error.response.status, error.response.data);
res.status(error.response.status).json(error.response.data); res.status(error.response.status).json(error.response.data);
} }