mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:40:43 +00:00
perf: narrow local llama type surface
This commit is contained in:
@@ -1,3 +1,29 @@
|
||||
export type LlamaEmbedding = {
|
||||
vector: Float32Array | number[];
|
||||
};
|
||||
|
||||
export type LlamaEmbeddingContext = {
|
||||
getEmbeddingFor: (text: string) => Promise<LlamaEmbedding>;
|
||||
};
|
||||
|
||||
export type LlamaModel = {
|
||||
createEmbeddingContext: () => 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");
|
||||
return import(NODE_LLAMA_CPP_MODULE) as Promise<NodeLlamaCppModule>;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import type { Llama, LlamaEmbeddingContext, LlamaModel } from "node-llama-cpp";
|
||||
import { normalizeOptionalString } from "../../shared/string-coerce.js";
|
||||
import { sanitizeAndNormalizeEmbedding } from "./embedding-vectors.js";
|
||||
import type { EmbeddingProvider, EmbeddingProviderOptions } from "./embeddings.types.js";
|
||||
import { importNodeLlamaCpp } from "./node-llama.js";
|
||||
import {
|
||||
importNodeLlamaCpp,
|
||||
type Llama,
|
||||
type LlamaEmbeddingContext,
|
||||
type LlamaModel,
|
||||
} from "./node-llama.js";
|
||||
|
||||
export type {
|
||||
EmbeddingProvider,
|
||||
|
||||
@@ -1,3 +1,29 @@
|
||||
export type LlamaEmbedding = {
|
||||
vector: Float32Array | number[];
|
||||
};
|
||||
|
||||
export type LlamaEmbeddingContext = {
|
||||
getEmbeddingFor: (text: string) => Promise<LlamaEmbedding>;
|
||||
};
|
||||
|
||||
export type LlamaModel = {
|
||||
createEmbeddingContext: () => 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");
|
||||
return import(NODE_LLAMA_CPP_MODULE) as Promise<NodeLlamaCppModule>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user