From 7f92d448fb497f359ec7f04dad28167d40bd484b Mon Sep 17 00:00:00 2001 From: adolphzhang Date: Sun, 24 Nov 2024 20:40:25 +0800 Subject: [PATCH] fix: fix missing dependencies caused by vite compilation. chore: update docker dependencies. --- scripts/plugins/docker/index.ts | 18 +++++++++--------- src/telegram/handler/chat.ts | 5 ++++- vite.config.ts | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/plugins/docker/index.ts b/scripts/plugins/docker/index.ts index 7278d1bed..ad055fb0b 100644 --- a/scripts/plugins/docker/index.ts +++ b/scripts/plugins/docker/index.ts @@ -25,15 +25,15 @@ const packageJson = ` "start": "node index.js" }, "dependencies": { - "@ai-sdk/anthropic": "^1.0.1", - "@ai-sdk/azure": "^1.0.3", - "@ai-sdk/cohere": "^1.0.1", - "@ai-sdk/google": "^1.0.1", - "@ai-sdk/google-vertex": "^1.0.1", - "@ai-sdk/mistral": "^1.0.2", - "@ai-sdk/openai": "^1.0.2", - "@ai-sdk/xai": "^1.0.2", - "ai": "^4.0.2", + "@ai-sdk/anthropic": "^1.0.2", + "@ai-sdk/azure": "^1.0.5", + "@ai-sdk/cohere": "^1.0.3", + "@ai-sdk/google": "^1.0.3", + "@ai-sdk/google-vertex": "^1.0.3", + "@ai-sdk/mistral": "^1.0.3", + "@ai-sdk/openai": "^1.0.4", + "@ai-sdk/xai": "^1.0.3", + "ai": "^4.0.3", "cloudflare-worker-adapter": "^1.3.4", "node-cron": "^3.0.3", "ws": "^8.18.0" diff --git a/src/telegram/handler/chat.ts b/src/telegram/handler/chat.ts index 22bb00bf7..02b00c2d7 100644 --- a/src/telegram/handler/chat.ts +++ b/src/telegram/handler/chat.ts @@ -129,10 +129,13 @@ export class ChatHandler implements MessageHandler { }); } if (type === 'image' || type === 'photo') { + const isUrl = ENV.TELEGRAM_IMAGE_TRANSFER_MODE === 'url'; for (const url of urls) { + const { data, format } = isUrl ? { data: url, format: 'image/jpeg' } : await imageToBase64String(url); params.content.push({ type: 'image', - image: ENV.TELEGRAM_IMAGE_TRANSFER_MODE === 'url' ? url : renderBase64DataURI(await imageToBase64String(url)), + image: data, + mimeType: format, }); } } else if (type === 'audio' || type === 'voice') { diff --git a/vite.config.ts b/vite.config.ts index a345aef38..7f084f3a5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -62,7 +62,7 @@ export default defineConfig({ build: { target: 'es2022', rollupOptions: { - external: ['ws', '@ai-sdk/google-vertex'], + external: ['ws', '@ai-sdk/google-vertex', 'node:buffer'], }, lib: { entry: path.resolve(__dirname, entry),