feat send base64 or url

This commit is contained in:
Yanyutin753
2024-03-07 23:33:32 +08:00
parent 79a863c636
commit 7fd9653e7c
6 changed files with 21 additions and 2 deletions

View File

@@ -57,6 +57,7 @@ export interface RequestBody {
apiKey?: string;
maxIterations: number;
returnIntermediateSteps: boolean;
updateTypes: boolean;
useTools: (undefined | string)[];
}

View File

@@ -28,6 +28,7 @@ export interface LLMConfig {
stream?: boolean;
presence_penalty?: number;
frequency_penalty?: number;
updateTypes?: boolean;
}
export interface LLMAgentConfig {

View File

@@ -104,7 +104,7 @@ export class ChatGPTApi implements LLMApi {
});
if (v.image_url) {
let image_url_data = "";
if (process.env.NEXT_PUBLIC_ENABLE_BASE64) {
if (options.config.updateTypes) {
var base64Data = await getImageBase64Data(v.image_url);
let mimeType: string | null;
try {
@@ -347,6 +347,7 @@ export class ChatGPTApi implements LLMApi {
baseUrl: baseUrl,
maxIterations: options.agentConfig.maxIterations,
returnIntermediateSteps: options.agentConfig.returnIntermediateSteps,
updateTypes: modelConfig.updateTypes,
useTools: options.agentConfig.useTools,
};

View File

@@ -359,6 +359,10 @@ const cn = {
Title: "频率惩罚度 (frequency_penalty)",
SubTitle: "值越大,越有可能降低重复字词",
},
UpdateType: {
Title: "上传类型",
SubTitle: "是否上传Base64格式消息",
},
Plugin: {
Enable: {
Title: "启用插件",

View File

@@ -365,6 +365,10 @@ const en: LocaleType = {
SubTitle:
"A larger value decreasing the likelihood to repeat the same line",
},
UpdateType: {
Title: "Upload type",
SubTitle: "Upload Base64 format message",
},
Plugin: {
Enable: {
Title: "Enable Plugin",

View File

@@ -56,6 +56,7 @@ export const DEFAULT_CONFIG = {
historyMessageCount: 4,
compressMessageLengthThreshold: 1000,
enableInjectSystemPrompts: true,
updateTypes: false,
template: DEFAULT_INPUT_TEMPLATE,
},
@@ -169,7 +170,14 @@ export const useAppConfig = createPersistStore(
if (version < 3.8) {
state.lastUpdate = Date.now();
}
if(process.env.NEXT_PUBLIC_ENABLE_BASE64){
state.modelConfig.updateTypes = true;
}
else{
state.modelConfig.updateTypes = false;
}
return state as any;
},
},