Skip to content

Commit

Permalink
perf: USER_CONFIG保存KV前裁剪
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Aug 28, 2024
1 parent 8ae55be commit 95b4545
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/timestamp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/telegram/command/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class SetEnvCommandHandler implements CommandHandler {
console.log('Update user config: ', key, context.USER_CONFIG[key]);
await ENV.DATABASE.put(
context.SHARE_CONTEXT.configStoreKey,
JSON.stringify(context.USER_CONFIG),
JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)),
);
return sender.sendPlainText('Update user config success');
} catch (e) {
Expand Down Expand Up @@ -187,7 +187,7 @@ export class SetEnvsCommandHandler implements CommandHandler {
context.USER_CONFIG.DEFINE_KEYS = Array.from(new Set(context.USER_CONFIG.DEFINE_KEYS));
await ENV.DATABASE.put(
context.SHARE_CONTEXT.configStoreKey,
JSON.stringify(context.USER_CONFIG),
JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)),
);
return sender.sendPlainText('Update user config success');
} catch (e) {
Expand All @@ -210,7 +210,7 @@ export class DelEnvCommandHandler implements CommandHandler {
context.USER_CONFIG.DEFINE_KEYS = context.USER_CONFIG.DEFINE_KEYS.filter(key => key !== subcommand);
await ENV.DATABASE.put(
context.SHARE_CONTEXT.configStoreKey,
JSON.stringify(context.USER_CONFIG),
JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)),
);
return sender.sendPlainText('Delete user config success');
} catch (e) {
Expand Down Expand Up @@ -292,7 +292,7 @@ export class SystemCommandHandler implements CommandHandler {
context.USER_CONFIG.MISTRAL_API_KEY = '******';
context.USER_CONFIG.COHERE_API_KEY = '******';
context.USER_CONFIG.ANTHROPIC_API_KEY = '******';
const config = context.USER_CONFIG;
const config = ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS);
msg = `<pre>\n${msg}`;
msg += `USER_CONFIG: ${JSON.stringify(config, null, 2)}\n`;
msg += `CHAT_CONTEXT: ${JSON.stringify(sender.context || {}, null, 2)}\n`;
Expand Down

0 comments on commit 95b4545

Please sign in to comment.