Add support for JSON values in additionalParams

This commit is contained in:
kwaroran
2024-03-20 21:06:30 +09:00
parent 5bede2b90a
commit 895543355f
2 changed files with 7 additions and 4 deletions

View File

@@ -117,7 +117,7 @@ export const languageEnglish = {
requestretrys: "This option is used to set the number of request retrys when request fails.",
emotionPrompt: "This option is used to set the prompt that is used to detect emotion. if it is blank, it will use the default prompt.",
removePunctuationHypa: "If enabled, it will remove punctuation before executing HypaMemory.",
additionalParams: "Additional parameters that would be added to the request body. if you want to exclude some parameters, you can put `{{none}}` to the value. if you want to add a header instead of body, you can put `header::` in front of the key like `header::Authorization`.",
additionalParams: "Additional parameters that would be added to the request body. if you want to exclude some parameters, you can put `{{none}}` to the value. if you want to add a header instead of body, you can put `header::` in front of the key like `header::Authorization`. if you want value as json, you can put `json::` in front of the value like `json::{\"key\":\"value\"}`. otherwise, type of the value would be determined automatically.",
},
setup: {
chooseProvider: "Choose AI Provider",

View File

@@ -631,10 +631,13 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model'
key = key.replace('header::', '')
headers[key] = value
}
else if(value.startsWith('json::')){
value = value.replace('json::', '')
try {
body[key] = JSON.parse(value)
} catch (error) {}
}
else if(isNaN(parseFloat(value))){
if(value.startsWith('"') && value.endsWith('"')){
value = value.slice(1, -1)
}
body[key] = value
}
else{