From 0b5c765da2c1170c703c77c521cf671a1d35b661 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Wed, 14 Jun 2023 13:31:41 +0900 Subject: [PATCH] [feat] better proxy resolve --- src/ts/process/request.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ts/process/request.ts b/src/ts/process/request.ts index 3dbe86c2..73220b0c 100644 --- a/src/ts/process/request.ts +++ b/src/ts/process/request.ts @@ -88,9 +88,17 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model' if(replacerURL.endsWith('v1')){ replacerURL += '/chat/completions' } - if(replacerURL.endsWith('v1/')){ + else if(replacerURL.endsWith('v1/')){ replacerURL += 'chat/completions' } + else if(!(replacerURL.endsWith('completions') || replacerURL.endsWith('completions/'))){ + if(replacerURL.endsWith('/')){ + replacerURL += 'v1/chat/completions' + } + else{ + replacerURL += '/v1/chat/completions' + } + } if(db.useStreaming && arg.useStreaming){ body.stream = true @@ -127,6 +135,8 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model' control.enqueue(readed) return } + + console.log(rawChunk) const chunk = JSON.parse(rawChunk).choices[0].delta.content if(chunk){ readed += chunk