limit resp

pull/7/head
Kar 2024-11-18 19:14:04 +05:30 committed by Kar l5
parent 87afa13a42
commit f68b1e78e0
1 changed files with 9 additions and 7 deletions

View File

@ -1,7 +1,7 @@
const aiFollowupQuestion = async (req, res) => { const aiFollowupQuestion = async (req, res) => {
const { MongoClient } = require('mongodb'); const { MongoClient } = require('mongodb');
const fetch = require('node-fetch'); // const fetch = require('node-fetch');
const { v4: uuidv4 } = require('uuid'); const { v4: uuidv4 } = require('uuid');
const url = process.env.MONGODB_URL; const url = process.env.MONGODB_URL;
const dbName = process.env.MONGO_DB_NAME; const dbName = process.env.MONGO_DB_NAME;
@ -20,16 +20,18 @@ const aiFollowupQuestion = async (req, res) => {
}, },
body: JSON.stringify({ body: JSON.stringify({
model: model, model: model,
// messages: messages, messages: messages,
messages: [ // messages: [
{ role: "system", content: "reply must not exceed 20 words" }, // { role: "system", content: "reply must not exceed 20 words" },
{ role: "user", content: messages } // { role: "user", content: messages }
], // ],
max_tokens: max_tokens, max_tokens: max_tokens,
}), }),
}); });
const data = await response.json(); const data = await response.json();
console.log(process.env.OPENAI_KEY)
console.log(data)
return data; return data;
} }
@ -50,7 +52,7 @@ const aiFollowupQuestion = async (req, res) => {
conversation = { conversation = {
sessionId: newSessionId, sessionId: newSessionId,
conversationHistory: [ conversationHistory: [
{ role: 'system', content: 'answer within 50 words' }, { role: 'system', content: 'answer within 10 words' },
{ role: 'user', content: prompt }, { role: 'user', content: prompt },
], ],
}; };