Skip to content

Commit

Permalink
fix: cortex chat without arguments should work
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Jun 3, 2024
1 parent 785f621 commit 2e4d57f
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cortex-js/src/extensions/groq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion cortex-js/src/extensions/mistral/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion cortex-js/src/extensions/openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>",
Expand Down
2 changes: 2 additions & 0 deletions cortex-js/src/infrastructure/commanders/chat.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export class ChatCommand extends CommandRunner {
}
}

if (!message) options.attach = true;

return this.chatCliUsecases.chat(
modelId,
options.threadId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions cortex-js/src/infrastructure/commanders/utils/app-path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { join } from 'path';

/**
* Path to the root of the application.
*/
export const appPath = join(__dirname, '../../../../../');
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 2e4d57f

Please sign in to comment.