Skip to content

Commit

Permalink
feat: support multiple variant load
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed May 3, 2024
1 parent aba7286 commit fab8bc7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export interface LlamaModelOptionsExtended extends LlamaModelOptions {
lib_variant?: string
}

let module: Module | null = null
const mods: { [key: string]: Module } = {}

export const loadModel = async (options: LlamaModelOptionsExtended): Promise<LlamaContext> => {
module ??= await loadModule(options.lib_variant)
return new module.LlamaContext(options)
const variant = options.lib_variant ?? 'default'
mods[variant] ??= await loadModule(options.lib_variant)
return new mods[variant].LlamaContext(options)
}

0 comments on commit fab8bc7

Please sign in to comment.