feat: configure HuggingfaceToken via cortex.cpp
This commit is contained in:
parent
e2a45095b2
commit
fe6412e1d4
@ -20,6 +20,10 @@ import { deleteModelFiles } from './legacy/delete'
|
|||||||
|
|
||||||
declare const SETTINGS: Array<any>
|
declare const SETTINGS: Array<any>
|
||||||
|
|
||||||
|
export enum Settings {
|
||||||
|
huggingfaceToken = 'hugging-face-access-token',
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A extension for models
|
* A extension for models
|
||||||
*/
|
*/
|
||||||
@ -33,10 +37,29 @@ export default class JanModelExtension extends ModelExtension {
|
|||||||
async onLoad() {
|
async onLoad() {
|
||||||
this.registerSettings(SETTINGS)
|
this.registerSettings(SETTINGS)
|
||||||
|
|
||||||
|
// Configure huggingface token if available
|
||||||
|
const huggingfaceToken = await this.getSetting<string>(
|
||||||
|
Settings.huggingfaceToken,
|
||||||
|
undefined
|
||||||
|
)
|
||||||
|
if (huggingfaceToken)
|
||||||
|
this.cortexAPI.configs({ huggingface_token: huggingfaceToken })
|
||||||
|
|
||||||
// Listen to app download events
|
// Listen to app download events
|
||||||
this.handleDesktopEvents()
|
this.handleDesktopEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscribe to settings update and make change accordingly
|
||||||
|
* @param key
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
onSettingUpdate<T>(key: string, value: T): void {
|
||||||
|
if (key === Settings.huggingfaceToken) {
|
||||||
|
this.cortexAPI.configs({ huggingface_token: value })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the extension is unloaded.
|
* Called when the extension is unloaded.
|
||||||
* @override
|
* @override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user