-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/cicd-cortex-js
- Loading branch information
Showing
41 changed files
with
403 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,16 @@ | ||
import { Model } from '../models/model.interface'; | ||
/* eslint-disable no-unused-vars, @typescript-eslint/no-unused-vars */ | ||
import { Model, ModelSettingParams } from '../models/model.interface'; | ||
import { Extension } from './extension.abstract'; | ||
|
||
export abstract class EngineExtension extends Extension { | ||
abstract provider: string; | ||
|
||
abstract inference(completion: any, req: any, stream: any, res?: any): void; | ||
|
||
async loadModel(model: Model): Promise<void> {} | ||
async loadModel( | ||
model: Model, | ||
settingParams?: ModelSettingParams, | ||
): Promise<void> {} | ||
|
||
async unloadModel(modelId: string): Promise<void> {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ChatUsecases } from '@/usecases/chat/chat.usecases'; | ||
import { CommandRunner, SubCommand } from 'nest-commander'; | ||
import { ChatCliUsecases } from './usecases/chat.cli.usecases'; | ||
|
||
@SubCommand({ name: 'chat' }) | ||
export class ChatCommand extends CommandRunner { | ||
constructor(private readonly chatUsecases: ChatUsecases) { | ||
super(); | ||
} | ||
|
||
async run(input: string[]): Promise<void> { | ||
const chatCliService = new ChatCliUsecases(this.chatUsecases); | ||
return chatCliService.run(input); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 18 additions & 48 deletions
66
cortex-js/src/infrastructure/commanders/models.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,22 @@ | ||
import { ModelsUsecases } from '@/usecases/models/models.usecases'; | ||
import { CommandRunner, SubCommand } from 'nest-commander'; | ||
import { PullCommand } from './pull.command'; | ||
import { StartCommand } from './start.command'; | ||
import { ModelStartCommand } from './models/model-start.command'; | ||
import { ModelGetCommand } from './models/model-get.command'; | ||
import { ModelListCommand } from './models/model-list.command'; | ||
import { ModelStopCommand } from './models/model-stop.command'; | ||
import { ModelPullCommand } from './models/model-pull.command'; | ||
import { ModelRemoveCommand } from './models/model-remove.command'; | ||
|
||
@SubCommand({ name: 'models', subCommands: [PullCommand, StartCommand] }) | ||
@SubCommand({ | ||
name: 'models', | ||
subCommands: [ | ||
ModelPullCommand, | ||
ModelStartCommand, | ||
ModelStopCommand, | ||
ModelListCommand, | ||
ModelGetCommand, | ||
ModelRemoveCommand, | ||
], | ||
}) | ||
export class ModelsCommand extends CommandRunner { | ||
constructor(private readonly modelsUsecases: ModelsUsecases) { | ||
super(); | ||
} | ||
|
||
async run(input: string[]): Promise<void> { | ||
const command = input[0]; | ||
const modelId = input[1]; | ||
|
||
if (command !== 'list') { | ||
if (!modelId) { | ||
console.log('Model ID is required'); | ||
return; | ||
} | ||
} | ||
|
||
switch (command) { | ||
case 'list': | ||
this.modelsUsecases.findAll().then(console.log); | ||
return; | ||
case 'get': | ||
this.modelsUsecases.findOne(modelId).then(console.log); | ||
return; | ||
case 'remove': | ||
this.modelsUsecases.remove(modelId).then(console.log); | ||
return; | ||
|
||
case 'stop': | ||
return this.modelsUsecases | ||
.stopModel(modelId) | ||
.then(console.log) | ||
.catch(console.error); | ||
|
||
case 'stats': | ||
case 'fetch': | ||
case 'build': { | ||
console.log('Command is not supported yet'); | ||
return; | ||
} | ||
|
||
default: | ||
console.error(`Command ${command} is not supported`); | ||
return; | ||
} | ||
} | ||
async run(): Promise<void> {} | ||
} |
22 changes: 22 additions & 0 deletions
22
cortex-js/src/infrastructure/commanders/models/model-get.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ModelsUsecases } from '@/usecases/models/models.usecases'; | ||
import { CommandRunner, SubCommand } from 'nest-commander'; | ||
import { ModelsCliUsecases } from '../usecases/models.cli.usecases'; | ||
import { exit } from 'node:process'; | ||
|
||
@SubCommand({ name: 'get' }) | ||
export class ModelGetCommand extends CommandRunner { | ||
constructor(private readonly modelsUsecases: ModelsUsecases) { | ||
super(); | ||
} | ||
|
||
async run(input: string[]): Promise<void> { | ||
if (input.length === 0) { | ||
console.error('Model ID is required'); | ||
exit(1); | ||
} | ||
|
||
const modelsCliUsecases = new ModelsCliUsecases(this.modelsUsecases); | ||
const models = await modelsCliUsecases.getModel(input[0]); | ||
console.log(models); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
cortex-js/src/infrastructure/commanders/models/model-list.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ModelsUsecases } from '@/usecases/models/models.usecases'; | ||
import { CommandRunner, SubCommand } from 'nest-commander'; | ||
import { ModelsCliUsecases } from '../usecases/models.cli.usecases'; | ||
|
||
@SubCommand({ name: 'list' }) | ||
export class ModelListCommand extends CommandRunner { | ||
constructor(private readonly modelsUsecases: ModelsUsecases) { | ||
super(); | ||
} | ||
|
||
async run(): Promise<void> { | ||
const modelsCliUsecases = new ModelsCliUsecases(this.modelsUsecases); | ||
const models = await modelsCliUsecases.listAllModels(); | ||
console.log(models); | ||
} | ||
} |
Oops, something went wrong.