From 6a18b6305d736a4c512d60868fc07783d3c1d501 Mon Sep 17 00:00:00 2001 From: fegloff Date: Wed, 2 Oct 2024 13:22:13 -0500 Subject: [PATCH] remove unused methods and types --- src/modules/llms/utils/llmModelsManager.ts | 55 +--------------------- src/modules/llms/utils/types.ts | 15 ------ 2 files changed, 1 insertion(+), 69 deletions(-) diff --git a/src/modules/llms/utils/llmModelsManager.ts b/src/modules/llms/utils/llmModelsManager.ts index 3a27b8a1..f1cddf84 100644 --- a/src/modules/llms/utils/llmModelsManager.ts +++ b/src/modules/llms/utils/llmModelsManager.ts @@ -3,24 +3,18 @@ import { type Provider, type LLMData, type LLMModel, - type ImageModel, - type ModelCommandMap, - type ModelPrefixMap + type ImageModel } from './types' export class LLMModelsManager { private readonly models = new Map() private readonly modelsEnum: Record private readonly commandsEnum: Record - private readonly commandMap: ModelCommandMap - private readonly prefixMap: ModelPrefixMap constructor (llmData: LLMData) { this.loadModels(llmData) this.modelsEnum = this.createModelsEnum() this.commandsEnum = this.createCommandsEnum() - this.commandMap = this.buildCommandMap() - this.prefixMap = this.buildPrefixMap() } private loadModels (data: LLMData): void { @@ -28,43 +22,6 @@ export class LLMModelsManager { Object.values(data.imageModels).forEach(model => { this.addModel(model) }) } - private buildCommandMap (): ModelCommandMap { - const commandMap: ModelCommandMap = {} - this.models.forEach((model, version) => { - model.commands.forEach(command => { - commandMap[command] = { - model: version, - useTools: command === 'ctool' || command === 'stool', - stream: 'stream' in model ? model.stream : true - } - }) - }) - return commandMap - } - - private buildPrefixMap (): ModelPrefixMap { - const prefixMap: ModelPrefixMap = {} - this.models.forEach((model, version) => { - if (model.prefix) { - model.prefix.forEach(prefix => { - prefixMap[prefix] = { - model: version, - stream: 'stream' in model ? model.stream : true - } - }) - } - }) - return prefixMap - } - - getCommandMap (): ModelCommandMap { - return this.commandMap - } - - getPrefixMap (): ModelPrefixMap { - return this.prefixMap - } - addModel (model: LLMModel): void { this.models.set(model.version, model) } @@ -89,16 +46,6 @@ export class LLMModelsManager { return commandsEnum } - getModelByCommand (command: string): LLMModel | undefined { - const modelInfo = this.commandMap[command] - return modelInfo ? this.getModel(modelInfo.model) : undefined - } - - getModelByPrefix (prefix: string): LLMModel | undefined { - const modelInfo = this.prefixMap[prefix] - return modelInfo ? this.getModel(modelInfo.model) : undefined - } - getModel (version: string): LLMModel | undefined { return this.models.get(version) } diff --git a/src/modules/llms/utils/types.ts b/src/modules/llms/utils/types.ts index 81e31d08..58561d56 100644 --- a/src/modules/llms/utils/types.ts +++ b/src/modules/llms/utils/types.ts @@ -34,18 +34,3 @@ export interface LLMData { chatModels: Record imageModels: Record } - -interface ModelCommandConfig { - model: string - useTools: boolean - stream: boolean -} - -export interface ModelCommandMap extends Record {} - -interface ModelPrefixConfig { - model: string - stream: boolean -} - -export interface ModelPrefixMap extends Record {}