diff --git a/dist/buildinfo.json b/dist/buildinfo.json index 21f0657b0..3f22fd61c 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"239539c","timestamp":1732966958} \ No newline at end of file +{"sha":"84e3212","timestamp":1733984023} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 68b75217e..4a9e6e2e9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7,7 +7,7 @@ class EnvironmentConfig { DEFAULT_PARSE_MODE = "Markdown"; TELEGRAM_MIN_STREAM_INTERVAL = 0; TELEGRAM_PHOTO_SIZE_OFFSET = 1; - TELEGRAM_IMAGE_TRANSFER_MODE = "url"; + TELEGRAM_IMAGE_TRANSFER_MODE = "base64"; MODEL_LIST_COLUMNS = 1; I_AM_A_GENEROUS_PERSON = false; CHAT_WHITE_LIST = []; @@ -192,8 +192,8 @@ class ConfigMerger { } } } -const BUILD_TIMESTAMP = 1732966958; -const BUILD_VERSION = "239539c"; +const BUILD_TIMESTAMP = 1733984023; +const BUILD_VERSION = "84e3212"; function createAgentUserConfig() { return Object.assign( {}, @@ -880,8 +880,6 @@ function getImageFormatFromBase64(base64String) { return "jpeg"; case "i": return "png"; - case "R": - return "gif"; case "U": return "webp"; default: @@ -896,6 +894,9 @@ async function imageToBase64String(url) { format: `image/${format}` }; } +function renderBase64DataURI(params) { + return `data:${params.format};base64,${params.data}`; +} class Stream { response; controller; @@ -1366,8 +1367,8 @@ async function renderOpenAIMessage(item, supportImage) { const data = extractImageContent(content.image); if (data.url) { if (ENV.TELEGRAM_IMAGE_TRANSFER_MODE === "base64") { - contents.push(await imageToBase64String(data.url).then(({ data: data2 }) => { - return { type: "image_url", image_url: { url: data2 } }; + contents.push(await imageToBase64String(data.url).then((data2) => { + return { type: "image_url", image_url: { url: renderBase64DataURI(data2) } }; })); } else { contents.push({ type: "image_url", image_url: { url: data.url } }); diff --git a/packages/lib/core/src/agent/openai.ts b/packages/lib/core/src/agent/openai.ts index 8cddcde35..cfa00daf7 100644 --- a/packages/lib/core/src/agent/openai.ts +++ b/packages/lib/core/src/agent/openai.ts @@ -8,7 +8,7 @@ import type { LLMChatParams, } from './types'; import { ENV } from '#/config'; -import { imageToBase64String } from '#/utils/image'; +import { imageToBase64String, renderBase64DataURI } from '#/utils/image'; import { requestChatCompletions } from './request'; import { convertStringToResponseMessages, extractImageContent, loadModelsList } from './utils'; @@ -29,8 +29,8 @@ async function renderOpenAIMessage(item: HistoryItem, supportImage?: boolean): P const data = extractImageContent(content.image); if (data.url) { if (ENV.TELEGRAM_IMAGE_TRANSFER_MODE === 'base64') { - contents.push(await imageToBase64String(data.url).then(({ data }) => { - return { type: 'image_url', image_url: { url: data } }; + contents.push(await imageToBase64String(data.url).then((data) => { + return { type: 'image_url', image_url: { url: renderBase64DataURI(data) } }; })); } else { contents.push({ type: 'image_url', image_url: { url: data.url } }); diff --git a/packages/lib/core/src/config/config.ts b/packages/lib/core/src/config/config.ts index 3adfc4ef6..42085031c 100644 --- a/packages/lib/core/src/config/config.ts +++ b/packages/lib/core/src/config/config.ts @@ -21,7 +21,7 @@ export class EnvironmentConfig { // 默认选择次低质量的图片 TELEGRAM_PHOTO_SIZE_OFFSET = 1; // 向LLM优先传递图片方式:url, base64 - TELEGRAM_IMAGE_TRANSFER_MODE = 'url'; + TELEGRAM_IMAGE_TRANSFER_MODE = 'base64'; // 模型列表列数 MODEL_LIST_COLUMNS = 1; diff --git a/packages/lib/core/src/config/version.ts b/packages/lib/core/src/config/version.ts index 6151c9472..f946bd927 100644 --- a/packages/lib/core/src/config/version.ts +++ b/packages/lib/core/src/config/version.ts @@ -1,2 +1,2 @@ -export const BUILD_TIMESTAMP = 1732966958; -export const BUILD_VERSION = '239539c'; +export const BUILD_TIMESTAMP = 1733984023; +export const BUILD_VERSION = '84e3212'; diff --git a/packages/lib/core/src/utils/image/index.ts b/packages/lib/core/src/utils/image/index.ts index 021abdb6a..2334cc99c 100644 --- a/packages/lib/core/src/utils/image/index.ts +++ b/packages/lib/core/src/utils/image/index.ts @@ -37,8 +37,6 @@ function getImageFormatFromBase64(base64String: string): string { return 'jpeg'; case 'i': return 'png'; - case 'R': - return 'gif'; case 'U': return 'webp'; default: