From f419bf6c8207beac81640d938c7a15ca01ce1252 Mon Sep 17 00:00:00 2001 From: tbxark Date: Thu, 14 Nov 2024 18:56:31 +0800 Subject: [PATCH] =?UTF-8?q?build:=201.10.3=20=E5=AE=8C=E5=96=84gemini?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/buildinfo.json | 2 +- dist/index.js | 21 +++++++++++++++------ package.json | 4 ++-- packages/apps/interpolate/package.json | 2 +- packages/apps/local/package.docker.json | 2 +- packages/apps/local/package.json | 2 +- packages/apps/local/src/index.ts | 2 +- packages/apps/vercel/package.json | 2 +- packages/apps/workers-next/package.json | 2 +- packages/apps/workers/package.json | 2 +- packages/lib/core/package.json | 2 +- packages/lib/core/src/config/version.ts | 4 ++-- packages/lib/next/package.json | 2 +- packages/lib/plugins/package.json | 2 +- 14 files changed, 30 insertions(+), 21 deletions(-) diff --git a/dist/buildinfo.json b/dist/buildinfo.json index 93cd0894..0ff6f3b0 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"be75d39","timestamp":1731510288} \ No newline at end of file +{"sha":"54bfa9a","timestamp":1731581746} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 369666b7..7266291a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -98,7 +98,7 @@ class GeminiConfig { GOOGLE_API_KEY = null; GOOGLE_API_BASE = "https://generativelanguage.googleapis.com/v1beta"; GOOGLE_COMPLETIONS_MODEL = "gemini-1.5-flash"; - GOOGLE_CHAT_MODELS_LIST = `["gemini-1.5-flash"]`; + GOOGLE_CHAT_MODELS_LIST = ""; } class MistralConfig { MISTRAL_API_KEY = null; @@ -192,8 +192,8 @@ class ConfigMerger { } } } -const BUILD_TIMESTAMP = 1731510288; -const BUILD_VERSION = "be75d39"; +const BUILD_TIMESTAMP = 1731581746; +const BUILD_VERSION = "54bfa9a"; function createAgentUserConfig() { return Object.assign( {}, @@ -422,7 +422,7 @@ function evaluateExpression(expr, localData) { return void 0; } } -function interpolate(template, data, formatter = null) { +function interpolate(template, data, formatter) { const processConditional = (condition, trueBlock, falseBlock, localData) => { const result = evaluateExpression(condition, localData); return result ? trueBlock : falseBlock || ""; @@ -1588,7 +1588,7 @@ class Gemini { }; request = async (params, context, onStream) => { const { prompt, messages } = params; - const url = `${context.GOOGLE_API_BASE}/chat`; + const url = `${context.GOOGLE_API_BASE}/openai/chat/completions`; const header = { "Authorization": `Bearer ${context.GOOGLE_API_KEY}`, "Content-Type": "application/json", @@ -1602,7 +1602,13 @@ class Gemini { return convertStringToResponseMessages(requestChatCompletions(url, header, body, onStream)); }; modelList = async (context) => { - return loadModelsList(context.GOOGLE_CHAT_MODELS_LIST); + if (context.GOOGLE_CHAT_MODELS_LIST === "") { + context.GOOGLE_CHAT_MODELS_LIST = `${context.GOOGLE_API_BASE}/models`; + } + return loadModelsList(context.GOOGLE_CHAT_MODELS_LIST, async (url) => { + const data = await fetch(`${url}?key=${context.GOOGLE_API_KEY}`).then((r) => r.json()); + return data?.models?.filter((model) => model.supportedGenerationMethods?.includes("generateContent")).map((model) => model.name.split("/").pop()) ?? []; + }); }; } class Mistral { @@ -2743,6 +2749,7 @@ class ModelChangeCallbackQueryHandler { AI_PROVIDER: agent, [chatAgent.modelKey]: model }, context); + console.log("Change model:", agent, model); const message = { chat_id: query.message.chat.id, message_id: query.message.message_id, @@ -2791,6 +2798,7 @@ async function handleCallbackQuery(callbackQuery, context) { } } } catch (e) { + console.error("handleCallbackQuery", e); return answerCallbackQuery(`ERROR: ${e.message}`); } return null; @@ -3226,3 +3234,4 @@ const Workers = { }; export { Workers as default }; +//# sourceMappingURL=index.js.map diff --git a/package.json b/package.json index aa6dff40..aadf1921 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "chatgpt-telegram-workers", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "description": "The easiest and quickest way to deploy your own ChatGPT Telegram bot is to use a single file and simply copy and paste it. There is no need for any dependencies, local development environment configuration, domain names, or servers.", "author": "tbxark ", "license": "MIT", @@ -38,7 +38,7 @@ "deploy:workers": "pnpm run build:workers && TOML_PATH=$INIT_CWD/wrangler.toml pnpm --filter @chatgpt-telegram-workers/workers deploy", "deploy:workersnext": "pnpm run build:workersnext && TOML_PATH=$INIT_CWD/wrangler.toml pnpm --filter @chatgpt-telegram-workers/workers-next deploy", "deploy:vercel": "pnpm run build:vercel && vercel --prod", - "start:local": "pnpm run build && CONFIG_PATH=$INIT_CWD/config.json TOML_PATH=$INIT_CWD/wrangler.toml pnpm --filter @chatgpt-telegram-workers/local start", + "start:local": "pnpm run build:local && CONFIG_PATH=$INIT_CWD/config.json TOML_PATH=$INIT_CWD/wrangler.toml pnpm --filter @chatgpt-telegram-workers/local start", "clean": "pnpm -r run clean", "wrangler": "wrangler" }, diff --git a/packages/apps/interpolate/package.json b/packages/apps/interpolate/package.json index eef56a4e..7a4a2631 100644 --- a/packages/apps/interpolate/package.json +++ b/packages/apps/interpolate/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/interpolate", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/apps/local/package.docker.json b/packages/apps/local/package.docker.json index afe60706..ba34065d 100644 --- a/packages/apps/local/package.docker.json +++ b/packages/apps/local/package.docker.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/local", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "scripts": { "start": "node index.js" }, diff --git a/packages/apps/local/package.json b/packages/apps/local/package.json index 02a11dd3..36df7eb4 100644 --- a/packages/apps/local/package.json +++ b/packages/apps/local/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/local", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/apps/local/src/index.ts b/packages/apps/local/src/index.ts index 134fbd95..ed75c38a 100644 --- a/packages/apps/local/src/index.ts +++ b/packages/apps/local/src/index.ts @@ -85,7 +85,7 @@ async function runPolling() { } } -if (NEXT_ENABLE) { +if (NEXT_ENABLE !== '0') { injectNextChatAgent(CHAT_AGENTS); } diff --git a/packages/apps/vercel/package.json b/packages/apps/vercel/package.json index 021a2fe4..1b6c97d3 100644 --- a/packages/apps/vercel/package.json +++ b/packages/apps/vercel/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/vercel", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/apps/workers-next/package.json b/packages/apps/workers-next/package.json index 4bd94a2b..36f4407e 100644 --- a/packages/apps/workers-next/package.json +++ b/packages/apps/workers-next/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/workers-next", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/apps/workers/package.json b/packages/apps/workers/package.json index 8186c0d7..05b55a3d 100644 --- a/packages/apps/workers/package.json +++ b/packages/apps/workers/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/workers", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/lib/core/package.json b/packages/lib/core/package.json index 3f13a6b9..cfb1cfba 100644 --- a/packages/lib/core/package.json +++ b/packages/lib/core/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/core", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/lib/core/src/config/version.ts b/packages/lib/core/src/config/version.ts index 88382771..ff219de1 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 = 1731510288; -export const BUILD_VERSION = 'be75d39'; +export const BUILD_TIMESTAMP = 1731581746; +export const BUILD_VERSION = '54bfa9a'; diff --git a/packages/lib/next/package.json b/packages/lib/next/package.json index 404cdcce..88444618 100644 --- a/packages/lib/next/package.json +++ b/packages/lib/next/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/next", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": { diff --git a/packages/lib/plugins/package.json b/packages/lib/plugins/package.json index d97e2251..63463556 100644 --- a/packages/lib/plugins/package.json +++ b/packages/lib/plugins/package.json @@ -1,7 +1,7 @@ { "name": "@chatgpt-telegram-workers/plugins", "type": "module", - "version": "1.10.2", + "version": "1.10.3", "main": "./dist/index.js", "types": "./dist/index.d.ts", "scripts": {