From 9c34f081b42470d0835ec6f0dd5c75bdf7a8f987 Mon Sep 17 00:00:00 2001 From: Jackson Chen <541898146chen@gmail.com> Date: Sun, 15 Dec 2024 14:15:57 -0600 Subject: [PATCH] refactor: rename ConfigLoader and ModelLoader files, update imports, and adjust ChatsConfig structure --- backend/src/config/{ConfigLoader.ts => config-loader.ts} | 6 ++---- backend/src/main.ts | 2 +- backend/src/model/__tests__/loadAllChatsModels.spec.ts | 6 +++--- .../src/model/{ModelDownloader.ts => model-downloader.ts} | 0 backend/src/model/{ModelLoader.ts => utils.ts} | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) rename backend/src/config/{ConfigLoader.ts => config-loader.ts} (91%) rename backend/src/model/{ModelDownloader.ts => model-downloader.ts} (100%) rename backend/src/model/{ModelLoader.ts => utils.ts} (84%) diff --git a/backend/src/config/ConfigLoader.ts b/backend/src/config/config-loader.ts similarity index 91% rename from backend/src/config/ConfigLoader.ts rename to backend/src/config/config-loader.ts index 82c9ac2..d9cd9c2 100644 --- a/backend/src/config/ConfigLoader.ts +++ b/backend/src/config/config-loader.ts @@ -1,9 +1,6 @@ import * as fs from 'fs'; import * as path from 'path'; import _ from 'lodash'; -export interface ChatsConfig { - chats: ChatConfig[]; -} export interface ChatConfig { model: string; endpoint?: string; @@ -11,8 +8,9 @@ export interface ChatConfig { default?: boolean; task?: string; } + export class ConfigLoader { - private chatsConfig: ChatsConfig; + private chatsConfig: ChatConfig[]; private readonly configPath: string; diff --git a/backend/src/main.ts b/backend/src/main.ts index dc5d4ca..ea049c9 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -1,7 +1,7 @@ import { NestFactory } from '@nestjs/core'; import { AppModule } from './app.module'; import 'reflect-metadata'; -import { downloadAllModels } from './model/ModelLoader'; +import { downloadAllModels } from './model/utils'; async function bootstrap() { const app = await NestFactory.create(AppModule); diff --git a/backend/src/model/__tests__/loadAllChatsModels.spec.ts b/backend/src/model/__tests__/loadAllChatsModels.spec.ts index a1dc73c..3968a2f 100644 --- a/backend/src/model/__tests__/loadAllChatsModels.spec.ts +++ b/backend/src/model/__tests__/loadAllChatsModels.spec.ts @@ -1,6 +1,6 @@ -import { ConfigLoader } from '../../config/ConfigLoader'; -import { ModelDownloader } from '../ModelDownloader'; -import { downloadAllModels } from '../ModelLoader'; +import { ConfigLoader } from '../../config/config-loader'; +import { ModelDownloader } from '../model-downloader'; +import { downloadAllModels } from '../utils'; const originalIsArray = Array.isArray; diff --git a/backend/src/model/ModelDownloader.ts b/backend/src/model/model-downloader.ts similarity index 100% rename from backend/src/model/ModelDownloader.ts rename to backend/src/model/model-downloader.ts diff --git a/backend/src/model/ModelLoader.ts b/backend/src/model/utils.ts similarity index 84% rename from backend/src/model/ModelLoader.ts rename to backend/src/model/utils.ts index e09c7b7..5635a86 100644 --- a/backend/src/model/ModelLoader.ts +++ b/backend/src/model/utils.ts @@ -1,5 +1,5 @@ -import { ChatConfig, ConfigLoader } from 'src/config/ConfigLoader'; -import { ModelDownloader } from './ModelDownloader'; +import { ChatConfig, ConfigLoader } from 'src/config/config-loader'; +import { ModelDownloader } from './model-downloader'; export async function downloadAllModels(): Promise { const configLoader = new ConfigLoader();