[refactor] reverse proxy
This commit is contained in:
@@ -88,7 +88,6 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
let bias = arg.bias
|
let bias = arg.bias
|
||||||
let currentChar = arg.currentChar
|
let currentChar = arg.currentChar
|
||||||
const aiModel = model === 'model' ? db.aiModel : db.subModel
|
const aiModel = model === 'model' ? db.aiModel : db.subModel
|
||||||
const replacer = aiModel === 'reverse_proxy' ? db.forceReplaceUrl : ''
|
|
||||||
switch(aiModel){
|
switch(aiModel){
|
||||||
case 'gpt35':
|
case 'gpt35':
|
||||||
case 'gpt35_0613':
|
case 'gpt35_0613':
|
||||||
@@ -161,7 +160,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
stream: false
|
stream: false
|
||||||
})
|
})
|
||||||
|
|
||||||
let replacerURL = replacer === '' ? 'https://api.openai.com/v1/chat/completions' : replacer
|
let replacerURL = (aiModel === 'reverse_proxy') ? (db.forceReplaceUrl) : ('https://api.openai.com/v1/chat/completions')
|
||||||
|
|
||||||
if(replacerURL.endsWith('v1')){
|
if(replacerURL.endsWith('v1')){
|
||||||
replacerURL += '/chat/completions'
|
replacerURL += '/chat/completions'
|
||||||
@@ -198,7 +197,7 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": "Bearer " + (aiModel === 'reverse_proxy' ? db.proxyKey : db.openAIKey),
|
"Authorization": "Bearer " + ((aiModel === 'reverse_proxy') ? db.proxyKey : db.openAIKey),
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
signal: abortSignal
|
signal: abortSignal
|
||||||
@@ -259,7 +258,8 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
|
|||||||
const res = await globalFetch(replacerURL, {
|
const res = await globalFetch(replacerURL, {
|
||||||
body: body,
|
body: body,
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": "Bearer " + (aiModel === 'reverse_proxy' ? db.proxyKey : db.openAIKey),
|
"Authorization": "Bearer " + ((aiModel === 'reverse_proxy') ? db.proxyKey : db.openAIKey),
|
||||||
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
abortSignal
|
abortSignal
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user