Skip to content

Commit 7060d00

Browse files
committed
fix: 修复openai base64图片格式错误, 更新 Telegram 图片传输模式为 base64
1 parent 84e3212 commit 7060d00

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

dist/buildinfo.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 8 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/lib/core/src/agent/openai.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
LLMChatParams,
99
} from './types';
1010
import { ENV } from '#/config';
11-
import { imageToBase64String } from '#/utils/image';
11+
import { imageToBase64String, renderBase64DataURI } from '#/utils/image';
1212
import { requestChatCompletions } from './request';
1313
import { convertStringToResponseMessages, extractImageContent, loadModelsList } from './utils';
1414

@@ -29,8 +29,8 @@ async function renderOpenAIMessage(item: HistoryItem, supportImage?: boolean): P
2929
const data = extractImageContent(content.image);
3030
if (data.url) {
3131
if (ENV.TELEGRAM_IMAGE_TRANSFER_MODE === 'base64') {
32-
contents.push(await imageToBase64String(data.url).then(({ data }) => {
33-
return { type: 'image_url', image_url: { url: data } };
32+
contents.push(await imageToBase64String(data.url).then((data) => {
33+
return { type: 'image_url', image_url: { url: renderBase64DataURI(data) } };
3434
}));
3535
} else {
3636
contents.push({ type: 'image_url', image_url: { url: data.url } });

packages/lib/core/src/config/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export class EnvironmentConfig {
2121
// 默认选择次低质量的图片
2222
TELEGRAM_PHOTO_SIZE_OFFSET = 1;
2323
// 向LLM优先传递图片方式:url, base64
24-
TELEGRAM_IMAGE_TRANSFER_MODE = 'url';
24+
TELEGRAM_IMAGE_TRANSFER_MODE = 'base64';
2525
// 模型列表列数
2626
MODEL_LIST_COLUMNS = 1;
2727

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export const BUILD_TIMESTAMP = 1732966958;
2-
export const BUILD_VERSION = '239539c';
1+
export const BUILD_TIMESTAMP = 1733984023;
2+
export const BUILD_VERSION = '84e3212';

packages/lib/core/src/utils/image/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ function getImageFormatFromBase64(base64String: string): string {
3737
return 'jpeg';
3838
case 'i':
3939
return 'png';
40-
case 'R':
41-
return 'gif';
4240
case 'U':
4341
return 'webp';
4442
default:

0 commit comments

Comments
 (0)