Skip to content

Commit

Permalink
updating hye web model model_lib_url api
Browse files Browse the repository at this point in the history
  • Loading branch information
OvidijusParsiunas committed Dec 21, 2023
1 parent bd85c3e commit 3c8024b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion component/src/types/webModel/webLLM/webLLMShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export interface ChatConfig {
export interface ModelRecord {
model_url: string;
local_id: string;
model_lib_url: string;
required_features?: Array<string>;
}

export interface AppConfig {
model_list: Array<ModelRecord>;
model_lib_map: Record<string, string>;
use_cache?: boolean;
}

Expand Down
12 changes: 5 additions & 7 deletions component/src/webModel/webModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,12 @@ export class WebModel extends BaseServiceIO {
let model = WebModel.DEFAULT_MODEL;
if (this._webModel.model) model = this._webModel.model;
const appConfig = JSON.parse(JSON.stringify(config)) as AppConfig;
if (this._webModel.urls?.model) {
if (this._webModel.urls) {
const modelConfig = appConfig.model_list.find((modelConfig) => (modelConfig.local_id = model));
if (modelConfig) modelConfig.model_url = this._webModel.urls.model;
}
if (this._webModel.urls?.wasm) {
const modelKey = model as keyof typeof appConfig.model_lib_map;
const wasm = appConfig.model_lib_map[modelKey];
if (wasm) appConfig.model_lib_map[modelKey] = this._webModel.urls.wasm;
if (modelConfig) {
if (this._webModel.urls.model) modelConfig.model_url = this._webModel.urls.model;
if (this._webModel.urls.wasm) modelConfig.model_lib_url = this._webModel.urls.wasm;
}
}
if (this._webModel.load?.skipCache) appConfig.use_cache = false;
return {model, appConfig};
Expand Down

0 comments on commit 3c8024b

Please sign in to comment.