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

Commit 51a58cb

Browse files
authored
fix: cortex chat without arguments should work (#652)
1 parent 785f621 commit 51a58cb

File tree

10 files changed

+22
-17
lines changed

10 files changed

+22
-17
lines changed

cortex-js/src/extensions/groq/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@janhq/groq-inference-engine",
33
"productName": "Groq Inference Engine",
44
"version": "1.0.0",
5-
"main": "dist/index.js",
5+
"main": "dist/extensions/groq/index.js",
66
"type": "commonjs",
77
"description": "This extension enables Groq chat completion API calls",
88
"author": "Jan <service@jan.ai>",

cortex-js/src/extensions/mistral/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@janhq/mistral-inference-engine",
33
"productName": "Mistral Inference Engine",
44
"version": "1.0.0",
5-
"main": "dist/index.js",
5+
"main": "dist/extensions/mistral/index.js",
66
"type": "commonjs",
77
"description": "This extension enables Mistral chat completion API calls",
88
"author": "Jan <service@jan.ai>",

cortex-js/src/extensions/openai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@janhq/openai-inference-engine",
33
"productName": "OpenAI Inference Engine",
44
"version": "1.0.0",
5-
"main": "dist/index.js",
5+
"main": "dist/extensions/openai/index.js",
66
"type": "commonjs",
77
"description": "This extension enables OpenAI chat completion API calls",
88
"author": "Jan <service@jan.ai>",

cortex-js/src/infrastructure/commanders/chat.command.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export class ChatCommand extends CommandRunner {
4848
}
4949
}
5050

51+
if (!message) options.attach = true;
52+
5153
return this.chatCliUsecases.chat(
5254
modelId,
5355
options.threadId,

cortex-js/src/infrastructure/commanders/models/model-pull.command.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export class ModelPullCommand extends CommandRunner {
2525
exit(1);
2626
}
2727

28-
const branches = await this.tryToGetBranches(input[0]);
28+
const branches = /[:/]/.test(input[0])
29+
? undefined
30+
: await this.tryToGetBranches(input[0]);
2931

3032
if (!branches) {
3133
await this.modelsCliUsecases.pullModel(input[0]);

cortex-js/src/infrastructure/commanders/models/model-stop.command.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ export class ModelStopCommand extends CommandRunner {
1414
exit(1);
1515
}
1616

17-
await this.modelsCliUsecases
18-
.stopModel(input[0])
19-
.then(() => this.modelsCliUsecases.stopModel(input[0]))
20-
.then(console.log);
17+
await this.modelsCliUsecases.stopModel(input[0]).then(console.log);
2118
}
2219
}

cortex-js/src/infrastructure/commanders/usecases/init.cli.usecases.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { firstValueFrom } from 'rxjs';
1010
import { FileManagerService } from '@/file-manager/file-manager.service';
1111
import { rm } from 'fs/promises';
1212
import { exec } from 'child_process';
13+
import { appPath } from '../utils/app-path';
1314

1415
@Injectable()
1516
export class InitCliUsecases {
@@ -257,8 +258,8 @@ export class InitCliUsecases {
257258

258259
exec(
259260
join(
260-
__dirname,
261-
`../../../../bin/cpuinfo${process.platform !== 'linux' ? '.exe' : ''}`,
261+
appPath,
262+
`bin/cpuinfo${process.platform !== 'linux' ? '.exe' : ''}`,
262263
),
263264
(error, stdout) => {
264265
if (error) {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { join } from 'path';
2+
3+
/**
4+
* Path to the root of the application.
5+
*/
6+
export const appPath = join(__dirname, '../../../../../');

cortex-js/src/infrastructure/providers/cortex/cortex.provider.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ import { normalizeModelId } from '@/infrastructure/commanders/utils/normalize-mo
1010
import { firstValueFrom } from 'rxjs';
1111
import { FileManagerService } from '@/file-manager/file-manager.service';
1212

13-
/**
14-
* A class that implements the InferenceExtension interface from the @janhq/core package.
15-
* The class provides methods for initializing and stopping a model, and for making inference requests.
16-
* It also subscribes to events emitted by the @janhq/core package and handles new message requests.
17-
*/
1813
@Injectable()
1914
export default class CortexProvider extends OAIEngineExtension {
2015
provider: string = 'cortex';

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Extension } from '@/domain/abstracts/extension.abstract';
44
import { readdir, lstat, access } from 'fs/promises';
55
import { join } from 'path';
66
import { EngineExtension } from '@/domain/abstracts/engine.abstract';
7+
import { appPath } from '@/infrastructure/commanders/utils/app-path';
78

89
@Injectable()
910
export class ExtensionRepositoryImpl implements ExtensionRepository {
@@ -36,12 +37,13 @@ export class ExtensionRepositoryImpl implements ExtensionRepository {
3637
}
3738

3839
loadCoreExtensions(): void {
39-
const extensionsPath = join(__dirname, './../../../extensions');
40+
const extensionsPath = join(appPath, 'src', 'extensions');
4041
this.loadExtensions(extensionsPath);
4142
}
4243

4344
loadExternalExtensions(): void {
44-
const extensionsPath = process.env.EXTENSIONS_PATH ?? 'extensions';
45+
const extensionsPath =
46+
process.env.EXTENSIONS_PATH ?? join(appPath, 'extensions');
4547
this.loadExtensions(extensionsPath);
4648
}
4749

0 commit comments

Comments
 (0)