From e540f5d3da882feb3ba787acd2715d2761454d14 Mon Sep 17 00:00:00 2001 From: weaigc <879821485@qq.com> Date: Sun, 3 Dec 2023 21:39:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dapi=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=E5=86=85=E5=AE=B9=E9=87=8D=E5=A4=8D=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/bots/bing/index.ts | 81 +++++++----------------- src/pages/api/openai/chat/completions.ts | 7 +- 2 files changed, 27 insertions(+), 61 deletions(-) diff --git a/src/lib/bots/bing/index.ts b/src/lib/bots/bing/index.ts index 278db711..772eb373 100644 --- a/src/lib/bots/bing/index.ts +++ b/src/lib/bots/bing/index.ts @@ -30,29 +30,16 @@ const getOptionSets = (conversationStyle: BingConversationStyle, allowSeach = tr 'responsible_ai_policy_235', 'enablemm', 'dv3sugg', - 'machine_affinity', 'autosave', 'iyxapbing', 'iycapbing', 'h3imaginative', - 'uquopt', - 'gcccomp', - 'utildv3tosah', - 'cpcandi', - 'cpcatral3', - 'cpcatro50', - 'cpcfmql', - 'cpcgnddi', - 'cpcmattr2', - 'cpcmcit1', - 'e2ecacheread', - 'nocitpass', - 'iypapyrus', - 'hlthcndans', - 'dv3suggtrim', + 'gptvprvc', + 'fluxpcalc', 'eredirecturl', 'clgalileo', - 'gencontentv3' + 'gencontentv3', + 'fluxv14l' ], [BingConversationStyle.Balanced]: [ 'nlu_direct_response_filter', @@ -61,28 +48,14 @@ const getOptionSets = (conversationStyle: BingConversationStyle, allowSeach = tr 'responsible_ai_policy_235', 'enablemm', 'dv3sugg', - 'machine_affinity', 'autosave', 'iyxapbing', 'iycapbing', 'galileo', - 'saharagenconv5', - 'uquopt', - 'gcccomp', - 'utildv3tosah', - 'cpcandi', - 'cpcatral3', - 'cpcatro50', - 'cpcfmql', - 'cpcgnddi', - 'cpcmattr2', - 'cpcmcit1', - 'e2ecacheread', - 'nocitpass', - 'iypapyrus', - 'hlthcndans', - 'dv3suggtrim', - 'eredirecturl' + 'gptvprvc', + 'fluxpcalc', + 'eredirecturl', + 'saharagenconv5' ], [BingConversationStyle.Precise]: [ 'nlu_direct_response_filter', @@ -91,41 +64,33 @@ const getOptionSets = (conversationStyle: BingConversationStyle, allowSeach = tr 'responsible_ai_policy_235', 'enablemm', 'dv3sugg', - 'machine_affinity', 'autosave', 'iyxapbing', 'iycapbing', 'h3precise', + 'gptvprvc', + 'fluxpcalc', + 'eredirecturl', 'clgalileo', 'gencontentv3', - 'uquopt', - 'gcccomp', - 'utildv3tosah', - 'cpcandi', - 'cpcatral3', - 'cpcatro50', - 'cpcfmql', - 'cpcgnddi', - 'cpcmattr2', - 'cpcmcit1', - 'e2ecacheread', - 'nocitpass', - 'iypapyrus', - 'hlthcndans', - 'dv3suggtrim', - 'eredirecturl' + 'fluxv14l' ], [BingConversationStyle.Base]: [ - 'saharasugg', - 'enablenewsfc', - 'gencontentv3', 'deepleo', 'disable_emoji_spoken_text', + 'responsible_ai_policy_235', 'enablemm', - 'h3precisedtappid', - 'cricinfo', - 'cricinfov2', 'dv3sugg', + 'autosave', + 'iyxapbing', + 'iycapbing', + 'h3imaginative', + 'gptvprvc', + 'fluxpcalc', + 'eredirecturl', + 'clgalileo', + 'gencontentv3', + 'fluxv14l', 'nojbfedge', ] }[conversationStyle] diff --git a/src/pages/api/openai/chat/completions.ts b/src/pages/api/openai/chat/completions.ts index 27eacba2..1d2ed908 100644 --- a/src/pages/api/openai/chat/completions.ts +++ b/src/pages/api/openai/chat/completions.ts @@ -33,8 +33,8 @@ function parseOpenAIMessage(request: APIRequest) { prompt, context, stream: request.stream, - allowSearch: /gpt-?4/i.test(request.model), - model: /Creative|gpt-?4/i.test(request.model) ? 'Creative' : 'Balanced', + allowSearch: !/Creative|Balanced|Precise/i.test(request.model), + model: /Creative|gpt-?4/i.test(request.model) ? 'Creative' : request.model, }; } @@ -72,7 +72,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) req.socket.once('close', () => { abortController.abort() }) - const { prompt, stream, model, context } = parseOpenAIMessage(req.body); + const { prompt, stream, model, allowSearch, context } = parseOpenAIMessage(req.body); let lastLength = 0 let lastText = '' try { @@ -92,6 +92,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) prompt, context, options: { + allowSearch, bingConversationStyle: Object.values(BingConversationStyle) .includes(toneType) ? toneType : BingConversationStyle.Creative, },