Add model selector command + fix Lrucache for v6-7 support

This commit is contained in:
TonyGeez
2025-10-05 23:24:33 -04:00
parent 3de89ba9f3
commit 739cbc74af
3 changed files with 15 additions and 10 deletions

View File

@@ -20,17 +20,18 @@
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@fastify/static": "^8.2.0", "@fastify/static": "^8.2.0",
"@inquirer/prompts": "^5.0.0",
"@musistudio/llms": "^1.0.35", "@musistudio/llms": "^1.0.35",
"dotenv": "^16.4.7", "dotenv": "^16.4.7",
"find-process": "^2.0.0", "find-process": "^2.0.0",
"json5": "^2.2.3", "json5": "^2.2.3",
"lru-cache": "^11.2.2",
"minimist": "^1.2.8", "minimist": "^1.2.8",
"openurl": "^1.1.1", "openurl": "^1.1.1",
"rotating-file-stream": "^3.2.7", "rotating-file-stream": "^3.2.7",
"shell-quote": "^1.8.3", "shell-quote": "^1.8.3",
"tiktoken": "^1.0.21", "tiktoken": "^1.0.21",
"uuid": "^11.1.0", "uuid": "^11.1.0"
"@inquirer/prompts": "^5.0.0"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^24.0.15", "@types/node": "^24.0.15",

11
pnpm-lock.yaml generated
View File

@@ -26,6 +26,9 @@ importers:
json5: json5:
specifier: ^2.2.3 specifier: ^2.2.3
version: 2.2.3 version: 2.2.3
lru-cache:
specifier: ^11.2.2
version: 11.2.2
minimist: minimist:
specifier: ^1.2.8 specifier: ^1.2.8
version: 1.2.8 version: 1.2.8
@@ -729,8 +732,8 @@ packages:
resolution: {integrity: sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==} resolution: {integrity: sha512-HgMmCqIJSAKqo68l0rS2AanEWfkxaZ5wNiEFb5ggm08lDs9Xl2KxBlX3PTcaD2chBM1gXAYf491/M2Rv8Jwayg==}
engines: {node: '>= 0.6.0'} engines: {node: '>= 0.6.0'}
lru-cache@11.1.0: lru-cache@11.2.2:
resolution: {integrity: sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==} resolution: {integrity: sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==}
engines: {node: 20 || >=22} engines: {node: 20 || >=22}
merge2@1.4.1: merge2@1.4.1:
@@ -1841,7 +1844,7 @@ snapshots:
loglevel@1.9.2: {} loglevel@1.9.2: {}
lru-cache@11.1.0: {} lru-cache@11.2.2: {}
merge2@1.4.1: {} merge2@1.4.1: {}
@@ -1908,7 +1911,7 @@ snapshots:
path-scurry@2.0.0: path-scurry@2.0.0:
dependencies: dependencies:
lru-cache: 11.1.0 lru-cache: 11.2.2
minipass: 7.1.2 minipass: 7.1.2
picomatch@2.3.1: {} picomatch@2.3.1: {}

View File

@@ -1,6 +1,6 @@
import {IAgent, ITool} from "./type"; import {IAgent, ITool} from "./type";
import { createHash } from 'crypto'; import { createHash } from 'crypto';
import { LRUCache } from 'lru-cache'; import * as LRU from 'lru-cache';
interface ImageCacheEntry { interface ImageCacheEntry {
source: any; source: any;
@@ -8,12 +8,13 @@ interface ImageCacheEntry {
} }
class ImageCache { class ImageCache {
private cache: LRUCache<string, ImageCacheEntry>; private cache: any;
constructor(maxSize = 100) { constructor(maxSize = 100) {
this.cache = new LRUCache({ const CacheClass: any = (LRU as any).LRUCache || (LRU as any);
this.cache = new CacheClass({
max: maxSize, max: maxSize,
ttl: 5 * 60 * 1000, ttl: 5 * 60 * 1000, // 5 minutes
}); });
} }