Skip to content

Commit e758c2c

Browse files
authored
revert: "fix: migrate JSON catalogs to Typesript (#3475)" (#3477)
This reverts commit fe2803e. Signed-off-by: Simon Rey <[email protected]>
1 parent fe2803e commit e758c2c

File tree

11 files changed

+768
-807
lines changed

11 files changed

+768
-807
lines changed

eslint.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ export default [
164164
*/
165165
'comma-dangle': ['warn', 'always-multiline'],
166166
/**
167-
* Let prettier handle the quotes cause I had conflicts
167+
* Just for beauty
168168
*/
169-
quotes: "off",
169+
quotes: ['error', 'single', { allowTemplateLiterals: true }],
170170

171171
// disabled import/namespace rule as the plug-in is not fully compatible using the compat mode
172172
'import/namespace': 'off',

packages/backend/src/assets/ai.json

Lines changed: 590 additions & 0 deletions
Large diffs are not rendered by default.

packages/backend/src/assets/ai.ts

Lines changed: 0 additions & 633 deletions
This file was deleted.

packages/backend/src/managers/catalogManager.spec.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,27 @@
1919
/* eslint-disable @typescript-eslint/no-explicit-any */
2020

2121
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
22+
import content from '../tests/ai-test.json';
23+
import userContent from '../tests/ai-user-test.json';
2224
import { EventEmitter, window } from '@podman-desktop/api';
2325
import { CatalogManager } from './catalogManager';
2426

2527
import type { Stats } from 'node:fs';
2628
import { promises, existsSync } from 'node:fs';
2729
import type { ApplicationCatalog } from '@shared/models/IApplicationCatalog';
2830
import path from 'node:path';
31+
import { version } from '../assets/ai.json';
2932
import * as catalogUtils from '../utils/catalogUtils';
3033
import type { RpcExtension } from '@shared/messages/MessageProxy';
31-
import { testCatalog } from '../tests/ai-test';
32-
import { defaultCatalog } from '../assets/ai';
33-
import { userTestCatalog } from '../tests/ai-user-test';
3434

35-
const content = testCatalog;
36-
const userContent = userTestCatalog;
35+
vi.mock('../assets/ai.json', async importOriginal => {
36+
// eslint-disable-next-line @typescript-eslint/consistent-type-imports
37+
const { version } = await importOriginal<typeof import('../assets/ai.json')>();
38+
return {
39+
default: { ...content, version: version },
40+
version: version,
41+
};
42+
});
3743

3844
vi.mock('node:fs');
3945
vi.mock('node:fs/promises');
@@ -84,7 +90,6 @@ beforeEach(async () => {
8490
fire: vi.fn().mockResolvedValue(true),
8591
} as unknown as RpcExtension,
8692
appUserDirectory,
87-
testCatalog,
8893
);
8994
});
9095

@@ -249,7 +254,7 @@ test('catalog should use user items in favour of default', async () => {
249254
});
250255

251256
test('default catalog should have latest version', () => {
252-
expect(defaultCatalog.version).toBe(catalogUtils.CatalogFormat.CURRENT);
257+
expect(version).toBe(catalogUtils.CatalogFormat.CURRENT);
253258
});
254259

255260
test('wrong catalog version should create a notification', () => {

packages/backend/src/managers/catalogManager.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { ApplicationCatalog } from '@shared/models/IApplicationCatalog';
2020
import fs, { promises } from 'node:fs';
2121
import path from 'node:path';
2222
import crypto from 'node:crypto';
23+
import defaultCatalog from '../assets/ai.json';
2324
import type { Recipe } from '@shared/models/IRecipe';
2425
import type { ModelInfo } from '@shared/models/IModelInfo';
2526
import { MSG_NEW_CATALOG_STATE } from '@shared/Messages';
@@ -39,14 +40,12 @@ export class CatalogManager extends Publisher<ApplicationCatalog> implements Dis
3940
readonly onUpdate: Event<ApplicationCatalog> = this._onUpdate.event;
4041

4142
private catalog: ApplicationCatalog;
42-
private defaultCatalog: ApplicationCatalog;
4343
#jsonWatcher: JsonWatcher<ApplicationCatalog> | undefined;
4444
#notification: Disposable | undefined;
4545

4646
constructor(
4747
rpcExtension: RpcExtension,
4848
private appUserDirectory: string,
49-
defaultCatalog: ApplicationCatalog,
5049
) {
5150
super(rpcExtension, MSG_NEW_CATALOG_STATE, () => this.getCatalog());
5251
// We start with an empty catalog, for the methods to work before the catalog is loaded
@@ -56,7 +55,6 @@ export class CatalogManager extends Publisher<ApplicationCatalog> implements Dis
5655
models: [],
5756
recipes: [],
5857
};
59-
this.defaultCatalog = defaultCatalog;
6058
}
6159

6260
/**
@@ -80,7 +78,7 @@ export class CatalogManager extends Publisher<ApplicationCatalog> implements Dis
8078
}
8179

8280
private loadDefaultCatalog(): void {
83-
this.catalog = this.defaultCatalog;
81+
this.catalog = defaultCatalog as ApplicationCatalog;
8482
this.notify();
8583
}
8684

@@ -130,7 +128,7 @@ export class CatalogManager extends Publisher<ApplicationCatalog> implements Dis
130128

131129
// merging default catalog with user catalog
132130
try {
133-
this.catalog = merge(sanitize(this.defaultCatalog), sanitize({ ...content, version: userCatalogFormat }));
131+
this.catalog = merge(sanitize(defaultCatalog), sanitize({ ...content, version: userCatalogFormat }));
134132

135133
// reset notification if everything went smoothly
136134
this.#notification?.dispose();

packages/backend/src/studio-api-impl.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
/* eslint-disable @typescript-eslint/no-explicit-any */
2020

2121
import { beforeEach, expect, test, vi, describe } from 'vitest';
22+
import content from './tests/ai-test.json';
2223
import type { ApplicationManager } from './managers/application/applicationManager';
2324
import { StudioApiImpl } from './studio-api-impl';
2425
import type { InferenceManager } from './managers/inference/inferenceManager';
@@ -42,7 +43,12 @@ import type { RecipeManager } from './managers/recipes/RecipeManager';
4243
import type { PodmanConnection } from './managers/podmanConnection';
4344
import type { NavigationRegistry } from './registries/NavigationRegistry';
4445
import type { RpcExtension } from '@shared/messages/MessageProxy';
45-
import { testCatalog } from './tests/ai-test';
46+
47+
vi.mock('./ai.json', () => {
48+
return {
49+
default: content,
50+
};
51+
});
4652

4753
vi.mock('node:fs', () => {
4854
return {
@@ -113,7 +119,6 @@ beforeEach(async () => {
113119
fire: vi.fn().mockResolvedValue(true),
114120
} as unknown as RpcExtension,
115121
appUserDirectory,
116-
testCatalog,
117122
);
118123

119124
applicationManager = {

packages/backend/src/studio.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import { LlamaStackManager } from './managers/llama-stack/llamaStackManager';
6565
import { OpenVINO } from './workers/provider/OpenVINO';
6666
import { McpServerManager } from './managers/playground/McpServerManager';
6767
import os from 'node:os';
68-
import { defaultCatalog } from './assets/ai';
6968

7069
export class Studio {
7170
readonly #extensionContext: ExtensionContext;
@@ -212,7 +211,7 @@ export class Studio {
212211
/**
213212
* Create catalog manager, responsible for loading the catalog files and watching for changes
214213
*/
215-
this.#catalogManager = new CatalogManager(this.#rpcExtension, appUserDirectory, defaultCatalog);
214+
this.#catalogManager = new CatalogManager(this.#rpcExtension, appUserDirectory);
216215
await this.#catalogManager.init();
217216

218217
/**
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"version": "1.0",
3+
"recipes": [
4+
{
5+
"id": "chatbot",
6+
"description": "Chat bot application",
7+
"name": "ChatBot",
8+
"repository": "https://github.com/axel7083/locallm",
9+
"icon": "natural-language-processing",
10+
"categories": ["natural-language-processing"],
11+
"basedir": "chatbot",
12+
"readme": "# Locallm\n\nThis repo contains artifacts that can be used to build and run LLM (Large Language Model) services locally on your Mac using podman. These containerized LLM services can be used to help developers quickly prototype new LLM based applications, without the need for relying on any other externally hosted services. Since they are already containerized, it also helps developers move from their prototype to production quicker. \n\n## Current Locallm Services: \n\n* [Chatbot](#chatbot)\n* [Text Summarization](#text-summarization)\n* [Fine-tuning](#fine-tuning)\n\n### Chatbot\n\nA simple chatbot using the gradio UI. Learn how to build and run this model service here: [Chatbot](/chatbot/).\n\n### Text Summarization\n\nAn LLM app that can summarize arbitrarily long text inputs. Learn how to build and run this model service here: [Text Summarization](/summarizer/).\n\n### Fine Tuning \n\nThis application allows a user to select a model and a data set they'd like to fine-tune that model on. Once the application finishes, it outputs a new fine-tuned model for the user to apply to other LLM services. Learn how to build and run this model training job here: [Fine-tuning](/finetune/).\n\n## Architecture\n![](https://raw.githubusercontent.com/MichaelClifford/locallm/main/assets/arch.jpg)\n\nThe diagram above indicates the general architecture for each of the individual model services contained in this repo. The core code available here is the \"LLM Task Service\" and the \"API Server\", bundled together under `model_services`. With an appropriately chosen model downloaded onto your host, `model_services/builds` contains the Containerfiles required to build an ARM or an x86 (with CUDA) image depending on your need. These model services are intended to be light-weight and run with smaller hardware footprints (given the Locallm name), but they can be run on any hardware that supports containers and scaled up if needed.\n\nWe also provide demo \"AI Applications\" under `ai_applications` for each model service to provide an example of how a developers could interact with the model service for their own needs. ",
13+
"recommended": ["llama-2-7b-chat.Q5_K_S", "albedobase-xl-1.3", "sdxl-turbo"]
14+
},
15+
{
16+
"id": "recipe0",
17+
"name": "Recipe 1",
18+
"categories": [],
19+
"description": "",
20+
"repository": "",
21+
"readme": ""
22+
},
23+
{
24+
"id": "recipe1",
25+
"name": "Recipe 1",
26+
"categories": [],
27+
"description": "",
28+
"repository": "",
29+
"readme": "",
30+
"backend": "tool1",
31+
"languages": ["lang1", "lang10"],
32+
"frameworks": ["fw1", "fw10"]
33+
},
34+
{
35+
"id": "recipe2",
36+
"name": "Recipe 2",
37+
"categories": [],
38+
"description": "",
39+
"repository": "",
40+
"readme": "",
41+
"backend": "tool2",
42+
"languages": ["lang2", "lang10"],
43+
"frameworks": ["fw2", "fw10"]
44+
},
45+
{
46+
"id": "recipe3",
47+
"name": "Recipe 3",
48+
"categories": [],
49+
"description": "",
50+
"repository": "",
51+
"readme": "",
52+
"backend": "tool3",
53+
"languages": ["lang3", "lang11"],
54+
"frameworks": ["fw2", "fw10", "fw11"]
55+
}
56+
],
57+
"models": [
58+
{
59+
"id": "llama-2-7b-chat.Q5_K_S",
60+
"name": "Llama-2-7B-Chat-GGUF",
61+
"description": "Llama 2 is a family of state-of-the-art open-access large language models released by Meta today, and we’re excited to fully support the launch with comprehensive integration in Hugging Face. Llama 2 is being released with a very permissive community license and is available for commercial use. The code, pretrained models, and fine-tuned models are all being released today 🔥",
62+
"registry": "Hugging Face",
63+
"license": "?",
64+
"url": "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q5_K_S.gguf"
65+
},
66+
{
67+
"id": "albedobase-xl-1.3",
68+
"name": "AlbedoBase XL 1.3",
69+
"description": "Stable Diffusion XL has 6.6 billion parameters, which is about 6.6 times more than the SD v1.5 version. I believe that this is not just a number, but a number that can lead to a significant improvement in performance. It has been a while since we realized that the overall performance of SD v1.5 has improved beyond imagination thanks to the explosive contributions of our community. Therefore, I am working on completing this AlbedoBase XL model in order to optimally reproduce the performance improvement that occurred in v1.5 in this XL version as well. My goal is to directly test the performance of all Checkpoints and LoRAs that are publicly uploaded to Civitai, and merge only the resources that are judged to be optimal after passing through several filters. This will surpass the performance of image-generating AI of companies such as Midjourney. As of now, AlbedoBase XL v0.4 has merged exactly 55 selected checkpoints and 138 LoRAs.",
70+
"registry": "Civital",
71+
"license": "openrail++",
72+
"url": ""
73+
},
74+
{
75+
"id": "sdxl-turbo",
76+
"name": "SDXL Turbo",
77+
"description": "SDXL Turbo achieves state-of-the-art performance with a new distillation technology, enabling single-step image generation with unprecedented quality, reducing the required step count from 50 to just one.",
78+
"registry": "Hugging Face",
79+
"license": "sai-c-community",
80+
"url": ""
81+
}
82+
],
83+
"categories": [
84+
{
85+
"id": "natural-language-processing",
86+
"name": "Natural Language Processing",
87+
"description": "Models that work with text: classify, summarize, translate, or generate text."
88+
},
89+
{
90+
"id": "computer-vision",
91+
"description": "Process images, from classification to object detection and segmentation.",
92+
"name": "Computer Vision"
93+
},
94+
{
95+
"id": "audio",
96+
"description": "Recognize speech or classify audio with audio models.",
97+
"name": "Audio"
98+
},
99+
{
100+
"id": "multimodal",
101+
"description": "Stuff about multimodal models goes here omg yes amazing.",
102+
"name": "Multimodal"
103+
}
104+
]
105+
}

packages/backend/src/tests/ai-test.ts

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)