patch failing calls to cortex

This commit is contained in:
Thien Tran 2025-05-28 16:21:08 +08:00 committed by Louis
parent 31971e7821
commit 39bb3f34d6
No known key found for this signature in database
GPG Key ID: 44FA9F4D33C37DE2
4 changed files with 27 additions and 20 deletions

View File

@ -51,7 +51,7 @@ export default class JanEngineManagementExtension extends EngineManagementExtens
*/
async onLoad() {
// Update default local engine
this.updateDefaultEngine()
// this.updateDefaultEngine()
// Migrate
this.migrate()
@ -66,6 +66,7 @@ export default class JanEngineManagementExtension extends EngineManagementExtens
* @returns A Promise that resolves to an object of list engines.
*/
async getEngines(): Promise<Engines> {
return {}
return this.apiInstance().then((api) =>
api
.get('v1/engines')
@ -94,6 +95,7 @@ export default class JanEngineManagementExtension extends EngineManagementExtens
* @returns A Promise that resolves to an array of installed engine.
*/
async getInstalledEngines(name: string): Promise<EngineVariant[]> {
return []
return this.apiInstance().then((api) =>
api
.get(`v1/engines/${name}`)

View File

@ -23,7 +23,7 @@ import {
} from '@janhq/core'
import { invoke } from '@tauri-apps/api/core'
import { createHmac } from 'crypto'
// import { createHmac } from 'crypto'
type LlamacppConfig = {
n_gpu_layers: number;
@ -131,8 +131,9 @@ export default class llamacpp_extension extends AIEngine {
}
private generateApiKey(modelId: string): string {
const hash = createHmac('sha256', this.apiSecret).update(modelId).digest("base64")
return hash
return ''
// const hash = createHmac('sha256', this.apiSecret).update(modelId).digest("base64")
// return hash
}
// Implement the required LocalProvider interface methods

View File

@ -288,6 +288,7 @@ export default class JanModelExtension extends ModelExtension {
* @param model
*/
async getSources(): Promise<ModelSource[]> {
return []
const sources = await this.apiInstance()
.then((api) => api.get('v1/models/sources').json<Data<ModelSource>>())
.then((e) => (typeof e === 'object' ? (e.data as ModelSource[]) : []))
@ -304,6 +305,7 @@ export default class JanModelExtension extends ModelExtension {
* @param model
*/
async addSource(source: string): Promise<any> {
return
return this.apiInstance().then((api) =>
api.post('v1/models/sources', {
json: {
@ -353,6 +355,7 @@ export default class JanModelExtension extends ModelExtension {
* @returns
*/
async fetchModels(): Promise<Model[]> {
return []
return this.apiInstance()
.then((api) => api.get('v1/models?limit=-1').json<Data<Model>>())
.then((e) =>
@ -401,6 +404,7 @@ export default class JanModelExtension extends ModelExtension {
* Fetch models from cortex.so
*/
fetchModelsHub = async () => {
return
const models = await this.fetchModels()
defaultModelSources.forEach((model) => {

View File

@ -87,7 +87,7 @@ pub async fn load_llama_model(
let mut command = Command::new(server_path);
let model_path = args[2].replace("-m", "");
let api_key = args[1].replace("--api-key", "")
let api_key = args[1].replace("--api-key", "");
command.args(args);
// Optional: Redirect stdio if needed (e.g., for logging within Jan)