fix: only allow 4 stop words for openai (#2457)

Signed-off-by: James <james@jan.ai>
Co-authored-by: James <james@jan.ai>
This commit is contained in:
NamH 2024-03-22 13:46:12 +07:00 committed by GitHub
parent 7282728c93
commit 8303f74f58
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -335,7 +335,12 @@ export const chatCompletions = async (request: any, reply: any) => {
headers['api-key'] = apiKey
}
console.debug(apiUrl)
console.debug(JSON.stringify(headers))
if (requestedModel.engine === 'openai' && request.body.stop) {
// openai only allows max 4 stop words
request.body.stop = request.body.stop.slice(0, 4)
}
const fetch = require('node-fetch')
const response = await fetch(apiUrl, {
method: 'POST',