From 8303f74f5821f81a688e5803ebc373470d6f4c2e Mon Sep 17 00:00:00 2001 From: NamH Date: Fri, 22 Mar 2024 13:46:12 +0700 Subject: [PATCH] fix: only allow 4 stop words for openai (#2457) Signed-off-by: James Co-authored-by: James --- core/src/node/api/restful/helper/builder.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/node/api/restful/helper/builder.ts b/core/src/node/api/restful/helper/builder.ts index 1ef8d34a4..e34fb606b 100644 --- a/core/src/node/api/restful/helper/builder.ts +++ b/core/src/node/api/restful/helper/builder.ts @@ -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',