From c70286c988521e24a0c3c84e7f391f65fb2f88b8 Mon Sep 17 00:00:00 2001 From: tbxark Date: Tue, 24 Dec 2024 15:46:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=96=B0=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=9F=A5=E8=AF=A2=E5=A4=84=E7=90=86=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E9=9D=99=E6=80=81=E6=96=B9=E6=B3=95=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E9=AB=98=E5=8F=AF=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/buildinfo.json | 2 +- dist/index.js | 28 +++++++++---------- packages/lib/core/src/config/version.ts | 4 +-- .../core/src/telegram/callback_query/index.ts | 12 ++++---- .../src/telegram/callback_query/system.ts | 12 ++++---- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dist/buildinfo.json b/dist/buildinfo.json index e58b5c0d..7f1be80a 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"284e897","timestamp":1735026022} \ No newline at end of file +{"sha":"0249f60","timestamp":1735026382} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 488b2804..8f78fe2e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -194,8 +194,8 @@ class ConfigMerger { } } } -const BUILD_TIMESTAMP = 1735026022; -const BUILD_VERSION = "284e897"; +const BUILD_TIMESTAMP = 1735026382; +const BUILD_VERSION = "0249f60"; function createAgentUserConfig() { return Object.assign( {}, @@ -1883,12 +1883,12 @@ class AgentListCallbackQueryHandler { this.prefix = prefix; this.changeAgentPrefix = changeAgentPrefix; } - static NewChatAgentListCallbackQueryHandler() { + static Chat() { return new AgentListCallbackQueryHandler("al:", "ca:", () => { return CHAT_AGENTS.filter((agent) => agent.enable(ENV.USER_CONFIG)).map((agent) => agent.name); }); } - static NewImageAgentListCallbackQueryHandler() { + static Image() { return new AgentListCallbackQueryHandler("ial:", "ica:", () => { return IMAGE_AGENTS.filter((agent) => agent.enable(ENV.USER_CONFIG)).map((agent) => agent.name); }); @@ -1951,10 +1951,10 @@ class ModelListCallbackQueryHandler { this.agentLoader = agentLoader; this.changeAgentType = changeAgentType; } - static NewChatModelListCallbackQueryHandler() { + static Chat() { return new ModelListCallbackQueryHandler("ca:", "al:", "cm:", loadChatLLM, changeChatAgentType); } - static NewImageModelListCallbackQueryHandler() { + static Image() { return new ModelListCallbackQueryHandler("ica:", "ial:", "icm:", loadImageGen, changeImageAgentType); } async handle(query, data, context) { @@ -2034,10 +2034,10 @@ class ModelChangeCallbackQueryHandler { this.agentLoader = agentLoader; this.changeAgentType = changeAgentType; } - static NewChatModelChangeCallbackQueryHandler() { + static Chat() { return new ModelChangeCallbackQueryHandler("cm:", loadChatLLM, changeChatAgentType); } - static NewImageModelChangeCallbackQueryHandler() { + static Image() { return new ModelChangeCallbackQueryHandler("icm:", loadChatLLM, changeImageAgentType); } async handle(query, data, context) { @@ -2071,12 +2071,12 @@ class ModelChangeCallbackQueryHandler { } } const QUERY_HANDLERS = [ - AgentListCallbackQueryHandler.NewChatAgentListCallbackQueryHandler(), - AgentListCallbackQueryHandler.NewImageAgentListCallbackQueryHandler(), - ModelListCallbackQueryHandler.NewChatModelListCallbackQueryHandler(), - ModelListCallbackQueryHandler.NewImageModelListCallbackQueryHandler(), - ModelChangeCallbackQueryHandler.NewChatModelChangeCallbackQueryHandler(), - ModelChangeCallbackQueryHandler.NewImageModelChangeCallbackQueryHandler() + AgentListCallbackQueryHandler.Chat(), + AgentListCallbackQueryHandler.Image(), + ModelListCallbackQueryHandler.Chat(), + ModelListCallbackQueryHandler.Image(), + ModelChangeCallbackQueryHandler.Chat(), + ModelChangeCallbackQueryHandler.Image() ]; async function handleCallbackQuery(callbackQuery, context) { const sender = MessageSender.fromCallbackQuery(context.SHARE_CONTEXT.botToken, callbackQuery); diff --git a/packages/lib/core/src/config/version.ts b/packages/lib/core/src/config/version.ts index 61bfab4f..fc1e9446 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 = 1735026022; -export const BUILD_VERSION = '284e897'; +export const BUILD_TIMESTAMP = 1735026382; +export const BUILD_VERSION = '0249f60'; diff --git a/packages/lib/core/src/telegram/callback_query/index.ts b/packages/lib/core/src/telegram/callback_query/index.ts index 3f5e915f..ca0e9b53 100644 --- a/packages/lib/core/src/telegram/callback_query/index.ts +++ b/packages/lib/core/src/telegram/callback_query/index.ts @@ -5,12 +5,12 @@ import { MessageSender } from '../sender'; import { AgentListCallbackQueryHandler, ModelChangeCallbackQueryHandler, ModelListCallbackQueryHandler } from './system'; const QUERY_HANDLERS = [ - AgentListCallbackQueryHandler.NewChatAgentListCallbackQueryHandler(), - AgentListCallbackQueryHandler.NewImageAgentListCallbackQueryHandler(), - ModelListCallbackQueryHandler.NewChatModelListCallbackQueryHandler(), - ModelListCallbackQueryHandler.NewImageModelListCallbackQueryHandler(), - ModelChangeCallbackQueryHandler.NewChatModelChangeCallbackQueryHandler(), - ModelChangeCallbackQueryHandler.NewImageModelChangeCallbackQueryHandler(), + AgentListCallbackQueryHandler.Chat(), + AgentListCallbackQueryHandler.Image(), + ModelListCallbackQueryHandler.Chat(), + ModelListCallbackQueryHandler.Image(), + ModelChangeCallbackQueryHandler.Chat(), + ModelChangeCallbackQueryHandler.Image(), ]; export async function handleCallbackQuery(callbackQuery: Telegram.CallbackQuery, context: WorkerContext): Promise { diff --git a/packages/lib/core/src/telegram/callback_query/system.ts b/packages/lib/core/src/telegram/callback_query/system.ts index 8cbfbf69..e17393f3 100644 --- a/packages/lib/core/src/telegram/callback_query/system.ts +++ b/packages/lib/core/src/telegram/callback_query/system.ts @@ -20,13 +20,13 @@ export class AgentListCallbackQueryHandler implements CallbackQueryHandler { this.changeAgentPrefix = changeAgentPrefix; } - static NewChatAgentListCallbackQueryHandler(): AgentListCallbackQueryHandler { + static Chat(): AgentListCallbackQueryHandler { return new AgentListCallbackQueryHandler('al:', 'ca:', () => { return CHAT_AGENTS.filter(agent => agent.enable(ENV.USER_CONFIG)).map(agent => agent.name); }); } - static NewImageAgentListCallbackQueryHandler(): AgentListCallbackQueryHandler { + static Image(): AgentListCallbackQueryHandler { return new AgentListCallbackQueryHandler('ial:', 'ica:', () => { return IMAGE_AGENTS.filter(agent => agent.enable(ENV.USER_CONFIG)).map(agent => agent.name); }); @@ -100,11 +100,11 @@ export class ModelListCallbackQueryHandler implements CallbackQueryHandler { this.changeAgentType = changeAgentType; } - static NewChatModelListCallbackQueryHandler(): ModelListCallbackQueryHandler { + static Chat(): ModelListCallbackQueryHandler { return new ModelListCallbackQueryHandler('ca:', 'al:', 'cm:', loadChatLLM, changeChatAgentType); } - static NewImageModelListCallbackQueryHandler(): ModelListCallbackQueryHandler { + static Image(): ModelListCallbackQueryHandler { return new ModelListCallbackQueryHandler('ica:', 'ial:', 'icm:', loadImageGen, changeImageAgentType); } @@ -192,11 +192,11 @@ export class ModelChangeCallbackQueryHandler implements CallbackQueryHandler { this.changeAgentType = changeAgentType; } - static NewChatModelChangeCallbackQueryHandler(): ModelChangeCallbackQueryHandler { + static Chat(): ModelChangeCallbackQueryHandler { return new ModelChangeCallbackQueryHandler('cm:', loadChatLLM, changeChatAgentType); } - static NewImageModelChangeCallbackQueryHandler(): ModelChangeCallbackQueryHandler { + static Image(): ModelChangeCallbackQueryHandler { return new ModelChangeCallbackQueryHandler('icm:', loadChatLLM, changeImageAgentType); }