Skip to content

Class: Llama

Properties

onDispose

ts
readonly onDispose: EventRelay<void>;

Defined in

bindings/Llama.ts:61

Accessors

disposed

ts
get disposed(): boolean

Returns

boolean

Defined in

bindings/Llama.ts:138


classes

ts
get classes(): LlamaClasses

Returns

LlamaClasses

Defined in

bindings/Llama.ts:142


gpu

ts
get gpu(): LlamaGpuType

Returns

LlamaGpuType

Defined in

bindings/Llama.ts:149


supportsGpuOffloading

ts
get supportsGpuOffloading(): boolean

Returns

boolean

Defined in

bindings/Llama.ts:153


supportsMmap

ts
get supportsMmap(): boolean

Returns

boolean

Defined in

bindings/Llama.ts:157


supportsMlock

ts
get supportsMlock(): boolean

Returns

boolean

Defined in

bindings/Llama.ts:161


cpuMathCores

ts
get cpuMathCores(): number

The number of CPU cores that are useful for math

Returns

number

Defined in

bindings/Llama.ts:166


maxThreads

ts
get maxThreads(): number

The maximum number of threads that can be used by the Llama instance.

If set to 0, the Llama instance will have no limit on the number of threads.

See the maxThreads option of getLlama for more information.

ts
set maxThreads(value: number): void

Parameters

ParameterType
valuenumber

Returns

number

Defined in

bindings/Llama.ts:177


logLevel

ts
get logLevel(): LlamaLogLevel
ts
set logLevel(value: LlamaLogLevel): void

Parameters

ParameterType
valueLlamaLogLevel

Returns

LlamaLogLevel

Defined in

bindings/Llama.ts:185


logger

ts
get logger(): (level: LlamaLogLevel, message: string) => void
ts
set logger(value: (level: LlamaLogLevel, message: string) => void): void

Parameters

ParameterType
value(level: LlamaLogLevel, message: string) => void

Returns

Function

Parameters
ParameterType
levelLlamaLogLevel
messagestring
Returns

void

Defined in

bindings/Llama.ts:199


buildType

ts
get buildType(): "localBuild" | "prebuilt"

Returns

"localBuild" | "prebuilt"

Defined in

bindings/Llama.ts:210


cmakeOptions

ts
get cmakeOptions(): Readonly<Record<string, string>>

Returns

Readonly<Record<string, string>>

Defined in

bindings/Llama.ts:214


llamaCppRelease

ts
get llamaCppRelease(): {
  repo: string;
  release: string;
}

Returns

ts
{
  repo: string;
  release: string;
}
repo
ts
readonly repo: string;
release
ts
readonly release: string;

Defined in

bindings/Llama.ts:218


systemInfo

ts
get systemInfo(): string

Returns

string

Defined in

bindings/Llama.ts:222


vramPaddingSize

ts
get vramPaddingSize(): number

VRAM padding used for memory size calculations, as these calculations are not always accurate. This is set by default to ensure stability, but can be configured when you call getLlama.

See vramPadding on getLlama for more information.

Returns

number

Defined in

bindings/Llama.ts:234

Methods

dispose()

ts
dispose(): Promise<void>

Returns

Promise<void>

Defined in

bindings/Llama.ts:123


getVramState()

ts
getVramState(): Promise<{
  total: number;
  used: number;
  free: number;
 }>

Returns

Promise<{ total: number; used: number; free: number; }>

total
ts
total: number;
used
ts
used: number;
free
ts
free: number;

Defined in

bindings/Llama.ts:238


getGpuDeviceNames()

ts
getGpuDeviceNames(): Promise<string[]>

Returns

Promise<string[]>

Defined in

bindings/Llama.ts:250


loadModel()

ts
loadModel(options: LlamaModelOptions): Promise<LlamaModel>

Parameters

ParameterType
optionsLlamaModelOptions

Returns

Promise<LlamaModel>

Defined in

bindings/Llama.ts:258


createGrammarForJsonSchema()

ts
createGrammarForJsonSchema<T>(schema: T): Promise<LlamaJsonSchemaGrammar<T>>

Type Parameters

Type Parameter
T extends Readonly<GbnfJsonSchema>

Parameters

ParameterType
schemaT

Returns

Promise<LlamaJsonSchemaGrammar<T>>

Defined in

bindings/Llama.ts:273


getGrammarFor()

ts
getGrammarFor(type: 
  | "json"
  | "json_arr"
  | "list"
  | "c"
  | "arithmetic"
  | "japanese"
  | "chess"): Promise<LlamaGrammar>

Parameters

ParameterType
type| "json" | "json_arr" | "list" | "c" | "arithmetic" | "japanese" | "chess"

Returns

Promise<LlamaGrammar>

Defined in

bindings/Llama.ts:277


createGrammar()

ts
createGrammar(options: LlamaGrammarOptions): Promise<LlamaGrammar>

Parameters

ParameterType
optionsLlamaGrammarOptions

Returns

Promise<LlamaGrammar>

Defined in

bindings/Llama.ts:281


defaultConsoleLogger()

ts
static defaultConsoleLogger(level: LlamaLogLevel, message: string): void

Parameters

ParameterType
levelLlamaLogLevel
messagestring

Returns

void

Defined in

bindings/Llama.ts:439