-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support cortex configs and engines commands
- Loading branch information
Showing
34 changed files
with
512 additions
and
177 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Module } from '@nestjs/common'; | ||
import GroqEngineExtension from './groq.engine'; | ||
import MistralEngineExtension from './mistral.engine'; | ||
import OpenAIEngineExtension from './openai.engine'; | ||
import { HttpModule, HttpService } from '@nestjs/axios'; | ||
import { ConfigsUsecases } from '@/usecases/configs/configs.usecase'; | ||
import { ConfigsModule } from '@/usecases/configs/configs.module'; | ||
|
||
const provider = { | ||
provide: 'EXTENSIONS_PROVIDER', | ||
inject: [HttpService, ConfigsUsecases], | ||
useFactory: (httpService: HttpService, configUsecases: ConfigsUsecases) => [ | ||
new OpenAIEngineExtension(httpService, configUsecases), | ||
new GroqEngineExtension(httpService, configUsecases), | ||
new MistralEngineExtension(httpService, configUsecases), | ||
], | ||
}; | ||
|
||
@Module({ | ||
imports: [HttpModule, ConfigsModule], | ||
controllers: [], | ||
providers: [provider], | ||
exports: [provider], | ||
}) | ||
export class ExtensionsModule {} |
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,30 @@ | ||
import { HttpService } from '@nestjs/axios'; | ||
import { OAIEngineExtension } from '../domain/abstracts/oai.abstract'; | ||
import { ConfigsUsecases } from '@/usecases/configs/configs.usecase'; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
export default class GroqEngineExtension extends OAIEngineExtension { | ||
provider: string = 'groq'; | ||
apiUrl = 'https://api.groq.com/openai/v1/chat/completions'; | ||
name = 'Groq Inference Engine'; | ||
description = 'This extension enables fast Groq chat completion API calls'; | ||
|
||
constructor( | ||
protected readonly httpService: HttpService, | ||
protected readonly configsUsecases: ConfigsUsecases, | ||
) { | ||
super(httpService); | ||
} | ||
|
||
async onLoad() { | ||
const configs = (await this.configsUsecases.getGroupConfigs( | ||
this.provider, | ||
)) as unknown as { apiKey: string }; | ||
if (!configs?.apiKey) | ||
await this.configsUsecases.saveConfig('apiKey', '', this.provider); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import { HttpService } from '@nestjs/axios'; | ||
import { OAIEngineExtension } from '../domain/abstracts/oai.abstract'; | ||
import { ConfigsUsecases } from '@/usecases/configs/configs.usecase'; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
export default class MistralEngineExtension extends OAIEngineExtension { | ||
provider: string = 'mistral'; | ||
apiUrl = 'https://api.mistral.ai/v1/chat/completions'; | ||
name = 'Mistral Inference Engine'; | ||
description = 'This extension enables Mistral chat completion API calls'; | ||
|
||
constructor( | ||
protected readonly httpService: HttpService, | ||
protected readonly configsUsecases: ConfigsUsecases, | ||
) { | ||
super(httpService); | ||
} | ||
|
||
async onLoad() { | ||
const configs = (await this.configsUsecases.getGroupConfigs( | ||
this.provider, | ||
)) as unknown as { apiKey: string }; | ||
if (!configs?.apiKey) | ||
await this.configsUsecases.saveConfig('apiKey', '', this.provider); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import { HttpService } from '@nestjs/axios'; | ||
import { OAIEngineExtension } from '../domain/abstracts/oai.abstract'; | ||
import { ConfigsUsecases } from '@/usecases/configs/configs.usecase'; | ||
|
||
/** | ||
* 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. | ||
*/ | ||
export default class OpenAIEngineExtension extends OAIEngineExtension { | ||
provider: string = 'openai'; | ||
apiUrl = 'https://api.openai.com/v1/chat/completions'; | ||
name = 'OpenAI Inference Engine'; | ||
description? = 'This extension enables OpenAI chat completion API calls'; | ||
|
||
constructor( | ||
protected readonly httpService: HttpService, | ||
protected readonly configsUsecases: ConfigsUsecases, | ||
) { | ||
super(httpService); | ||
} | ||
|
||
async onLoad() { | ||
const configs = (await this.configsUsecases.getGroupConfigs( | ||
this.provider, | ||
)) as unknown as { apiKey: string }; | ||
if (!configs?.apiKey) | ||
await this.configsUsecases.saveConfig('apiKey', '', this.provider); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.