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; apiKey?: string;
maxIterations: number; maxIterations: number;
returnIntermediateSteps: boolean; returnIntermediateSteps: boolean;
updateTypes: boolean;
useTools: (undefined | string)[]; useTools: (undefined | string)[];
} }

View File

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

View File

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

View File

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

View File

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

View File

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