Files
openclaw/packages/memory-host-sdk/src/host/node-llama.ts
2026-04-28 05:49:07 +01:00

32 lines
804 B
TypeScript

export type LlamaEmbedding = {
vector: Float32Array | number[];
};
export type LlamaEmbeddingContext = {
getEmbeddingFor: (text: string) => Promise<LlamaEmbedding>;
};
export type LlamaModel = {
createEmbeddingContext: (options?: {
contextSize?: number | "auto";
}) => Promise<LlamaEmbeddingContext>;
};
export type Llama = {
loadModel: (params: { modelPath: string }) => Promise<LlamaModel>;
};
export type NodeLlamaCppModule = {
LlamaLogLevel: {
error: number;
};
getLlama: (params: { logLevel: number }) => Promise<Llama>;
resolveModelFile: (modelPath: string, cacheDir?: string) => Promise<string>;
};
const NODE_LLAMA_CPP_MODULE = "node-llama-cpp";
export async function importNodeLlamaCpp() {
return import(NODE_LLAMA_CPP_MODULE) as Promise<NodeLlamaCppModule>;
}