diff --git a/cortex-js/src/extensions/groq/package.json b/cortex-js/src/extensions/groq/package.json index dbf69b035..ea8e2579b 100644 --- a/cortex-js/src/extensions/groq/package.json +++ b/cortex-js/src/extensions/groq/package.json @@ -2,7 +2,7 @@ "name": "@janhq/groq-inference-engine", "productName": "Groq Inference Engine", "version": "1.0.0", - "main": "dist/index.js", + "main": "dist/extensions/groq/index.js", "type": "commonjs", "description": "This extension enables Groq chat completion API calls", "author": "Jan ", diff --git a/cortex-js/src/extensions/mistral/package.json b/cortex-js/src/extensions/mistral/package.json index aa445adfd..38255c81a 100644 --- a/cortex-js/src/extensions/mistral/package.json +++ b/cortex-js/src/extensions/mistral/package.json @@ -2,7 +2,7 @@ "name": "@janhq/mistral-inference-engine", "productName": "Mistral Inference Engine", "version": "1.0.0", - "main": "dist/index.js", + "main": "dist/extensions/mistral/index.js", "type": "commonjs", "description": "This extension enables Mistral chat completion API calls", "author": "Jan ", diff --git a/cortex-js/src/extensions/openai/package.json b/cortex-js/src/extensions/openai/package.json index b230e32b4..3fa4f179d 100644 --- a/cortex-js/src/extensions/openai/package.json +++ b/cortex-js/src/extensions/openai/package.json @@ -2,7 +2,7 @@ "name": "@janhq/openai-inference-engine", "productName": "OpenAI Inference Engine", "version": "1.0.0", - "main": "dist/index.js", + "main": "dist/extensions/openai/index.js", "type": "commonjs", "description": "This extension enables OpenAI chat completion API calls", "author": "Jan ", diff --git a/cortex-js/src/infrastructure/commanders/chat.command.ts b/cortex-js/src/infrastructure/commanders/chat.command.ts index a9084d2a7..5023ef645 100644 --- a/cortex-js/src/infrastructure/commanders/chat.command.ts +++ b/cortex-js/src/infrastructure/commanders/chat.command.ts @@ -48,6 +48,8 @@ export class ChatCommand extends CommandRunner { } } + if (!message) options.attach = true; + return this.chatCliUsecases.chat( modelId, options.threadId, diff --git a/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts b/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts index 1dade38de..f8b6891b9 100644 --- a/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts +++ b/cortex-js/src/infrastructure/commanders/models/model-pull.command.ts @@ -25,7 +25,9 @@ export class ModelPullCommand extends CommandRunner { exit(1); } - const branches = await this.tryToGetBranches(input[0]); + const branches = /[:/]/.test(input[0]) + ? undefined + : await this.tryToGetBranches(input[0]); if (!branches) { await this.modelsCliUsecases.pullModel(input[0]); diff --git a/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts b/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts index 300356359..327b997e5 100644 --- a/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts +++ b/cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts @@ -10,6 +10,7 @@ import { firstValueFrom } from 'rxjs'; import { FileManagerService } from '@/file-manager/file-manager.service'; import { rm } from 'fs/promises'; import { exec } from 'child_process'; +import { appPath } from '../utils/app-path'; @Injectable() export class InitCliUsecases { @@ -257,8 +258,8 @@ export class InitCliUsecases { exec( join( - __dirname, - `../../../../bin/cpuinfo${process.platform !== 'linux' ? '.exe' : ''}`, + appPath, + `bin/cpuinfo${process.platform !== 'linux' ? '.exe' : ''}`, ), (error, stdout) => { if (error) { diff --git a/cortex-js/src/infrastructure/commanders/utils/app-path.ts b/cortex-js/src/infrastructure/commanders/utils/app-path.ts new file mode 100644 index 000000000..b11a8c5aa --- /dev/null +++ b/cortex-js/src/infrastructure/commanders/utils/app-path.ts @@ -0,0 +1,6 @@ +import { join } from 'path'; + +/** + * Path to the root of the application. + */ +export const appPath = join(__dirname, '../../../../../'); diff --git a/cortex-js/src/infrastructure/providers/cortex/cortex.provider.ts b/cortex-js/src/infrastructure/providers/cortex/cortex.provider.ts index 5a6702b23..2c367ee47 100644 --- a/cortex-js/src/infrastructure/providers/cortex/cortex.provider.ts +++ b/cortex-js/src/infrastructure/providers/cortex/cortex.provider.ts @@ -10,11 +10,6 @@ import { normalizeModelId } from '@/infrastructure/commanders/utils/normalize-mo import { firstValueFrom } from 'rxjs'; import { FileManagerService } from '@/file-manager/file-manager.service'; -/** - * A class that implements the InferenceExtension interface from the @janhq/core package. - * The class provides methods for initializing and stopping a model, and for making inference requests. - * It also subscribes to events emitted by the @janhq/core package and handles new message requests. - */ @Injectable() export default class CortexProvider extends OAIEngineExtension { provider: string = 'cortex'; diff --git a/cortex-js/src/infrastructure/repositories/extensions/extension.repository.ts b/cortex-js/src/infrastructure/repositories/extensions/extension.repository.ts index bec23f4cc..a1f2c69f0 100644 --- a/cortex-js/src/infrastructure/repositories/extensions/extension.repository.ts +++ b/cortex-js/src/infrastructure/repositories/extensions/extension.repository.ts @@ -4,6 +4,7 @@ import { Extension } from '@/domain/abstracts/extension.abstract'; import { readdir, lstat, access } from 'fs/promises'; import { join } from 'path'; import { EngineExtension } from '@/domain/abstracts/engine.abstract'; +import { appPath } from '@/infrastructure/commanders/utils/app-path'; @Injectable() export class ExtensionRepositoryImpl implements ExtensionRepository { @@ -36,12 +37,13 @@ export class ExtensionRepositoryImpl implements ExtensionRepository { } loadCoreExtensions(): void { - const extensionsPath = join(__dirname, './../../../extensions'); + const extensionsPath = join(appPath, 'src', 'extensions'); this.loadExtensions(extensionsPath); } loadExternalExtensions(): void { - const extensionsPath = process.env.EXTENSIONS_PATH ?? 'extensions'; + const extensionsPath = + process.env.EXTENSIONS_PATH ?? join(appPath, 'extensions'); this.loadExtensions(extensionsPath); }