Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit 147a869

Browse files
committed
feat: faster code compile
1 parent d627265 commit 147a869

File tree

7 files changed

+20
-16
lines changed

7 files changed

+20
-16
lines changed

cortex-js/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
},
1111
"scripts": {
1212
"dev": "nest dev",
13-
"build": "yarn build:extensions && nest build && cpx \"cpuinfo/bin/**\" dist/bin",
14-
"build:binary": "run-script-os",
15-
"build:binary:windows": "bun build --compile --target=bun-windows-x64 ./dist/src/command.js --outfile cortex.exe --external @nestjs/microservices --external @nestjs/websockets/socket-module --external class-transformer/storage",
16-
"build:binary:linux": "bun build --compile --target=bun-linux-x64 ./dist/src/command.js --outfile cortex --external @nestjs/microservices --external @nestjs/websockets/socket-module --external class-transformer/storage",
17-
"build:binary:macos": "bun build --compile --target=bun-darwin-arm64 ./dist/src/command.js --outfile cortex --external @nestjs/microservices --external @nestjs/websockets/socket-module --external class-transformer/storage",
13+
"build": "nest build && cpx \"cpuinfo/bin/**\" dist/bin",
14+
"build:binary": "run-script-os && cpx \"cpuinfo/bin/**\" dist/bin",
15+
"build:binary:windows": "bun build --compile --target=bun-windows-x64 ./src/command.ts --outfile cortex.exe --external @nestjs/microservices --external @nestjs/websockets/socket-module --external class-transformer/storage",
16+
"build:binary:linux": "bun build --compile --target=bun-linux-x64 ./src/command.ts --outfile cortex --external @nestjs/microservices --external @nestjs/websockets/socket-module --external class-transformer/storage",
17+
"build:binary:macos": "bun build --compile --target=bun-darwin-arm64 ./src/command.ts --outfile cortex --external @nestjs/microservices --external @nestjs/websockets/socket-module --external class-transformer/storage",
1818
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
1919
"build:extensions": "run-script-os",
2020
"build:extensions:windows": "powershell -command \"$jobs = Get-ChildItem -Path './src/extensions' -Directory | ForEach-Object { Start-Job -Name ($_.Name) -ScriptBlock { param($_dir); try { Set-Location $_dir; yarn; yarn build; Write-Output 'Build successful in ' + $_dir } catch { Write-Error 'Error in ' + $_dir; throw } } -ArgumentList $_.FullName }; $jobs | Wait-Job; $jobs | ForEach-Object { Receive-Job -Job $_ -Keep } | ForEach-Object { Write-Host $_ }; $failed = $jobs | Where-Object { $_.State -ne 'Completed' -or $_.ChildJobs[0].JobStateInfo.State -ne 'Completed' }; if ($failed) { Exit 1 }\"",

cortex-js/src/infrastructure/entities/assistant.entity.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {
2-
Assistant,
3-
AssistantResponseFormatOption,
1+
import { Assistant } from '@/domain/models/assistant.interface';
2+
import type {
43
AssistantToolResources,
4+
AssistantResponseFormatOption,
55
} from '@/domain/models/assistant.interface';
66
import { Column, Entity, PrimaryColumn } from 'typeorm';
77

cortex-js/src/infrastructure/entities/message.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {
1+
import type {
22
Message,
33
MessageContent,
44
MessageIncompleteDetails,

cortex-js/src/infrastructure/entities/thread.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Thread, ThreadToolResources } from '@/domain/models/thread.interface';
1+
import type { Thread, ThreadToolResources } from '@/domain/models/thread.interface';
22
import { Entity, PrimaryColumn, Column } from 'typeorm';
33
import { AssistantEntity } from './assistant.entity';
44

cortex-js/src/infrastructure/repositories/extensions/extension.repository.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,16 @@ import { existsSync } from 'fs';
1111
@Injectable()
1212
export class ExtensionRepositoryImpl implements ExtensionRepository {
1313
// Initialize the Extensions Map with the key-value pairs of the core providers.
14-
extensions = new Map<string, Extension>([
15-
['cortex.llamacpp', this.cortexProvider],
16-
['cortex.onnx', this.cortexProvider],
17-
['cortex.tensorrt-llm', this.cortexProvider],
18-
]);
14+
extensions = new Map<string, Extension>();
1915

2016
constructor(
2117
@Inject('CORTEX_PROVIDER')
2218
private readonly cortexProvider: EngineExtension,
2319
private readonly fileService: FileManagerService,
2420
) {
21+
this.extensions.set('cortex.llamacpp', this.cortexProvider);
22+
this.extensions.set('cortex.onnx', this.cortexProvider);
23+
this.extensions.set('cortex.tensorrt-llm', this.cortexProvider);
2524
this.loadCoreExtensions();
2625
this.loadExternalExtensions();
2726
}

cortex-js/src/infrastructure/services/file-manager/file-manager.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ export class FileManagerService {
5252
try {
5353
const content = await promises.readFile(configPath, 'utf8');
5454
const config = yaml.load(content) as Config;
55-
return config;
55+
return {
56+
...this.defaultConfig(),
57+
...config,
58+
};
5659
} catch (error) {
5760
console.warn('Error reading config file. Using default config.');
5861
console.warn(error);

cortex-js/src/usecases/chat/chat.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ExtensionModule } from '@/infrastructure/repositories/extensions/extens
55
import { ModelRepositoryModule } from '@/infrastructure/repositories/models/model.module';
66
import { HttpModule } from '@nestjs/axios';
77
import { TelemetryModule } from '../telemetry/telemetry.module';
8+
import { FileManagerModule } from '@/infrastructure/services/file-manager/file-manager.module';
89

910
@Module({
1011
imports: [
@@ -13,6 +14,7 @@ import { TelemetryModule } from '../telemetry/telemetry.module';
1314
ModelRepositoryModule,
1415
HttpModule,
1516
TelemetryModule,
17+
FileManagerModule,
1618
],
1719
controllers: [],
1820
providers: [ChatUsecases],

0 commit comments

Comments
 (0)