mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-12 21:53:00 -06:00
refactor: consolidate remaining coercion helpers (#122020)
This commit is contained in:
committed by
GitHub
parent
24bbb416b5
commit
cad77fb39c
@@ -14,6 +14,7 @@ import {
|
||||
type MemoryEmbeddingProviderCreateOptions,
|
||||
type MemoryEmbeddingProviderCreateResult,
|
||||
} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
||||
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
import { formatLlamaCppSetupError, resolveNodeLlamaCppImportUrl } from "./node-llama.runtime.js";
|
||||
|
||||
type LlamaCppLocalOptions = {
|
||||
@@ -42,10 +43,6 @@ type LlamaCppModelIdentity = {
|
||||
}>;
|
||||
};
|
||||
|
||||
function normalizeOptionalString(value: unknown): string | undefined {
|
||||
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
||||
}
|
||||
|
||||
function readLocalOptions(options: { local?: unknown }): LlamaCppLocalOptions {
|
||||
const local = options.local as LlamaCppLocalOptions | undefined;
|
||||
return local ?? {};
|
||||
|
||||
@@ -82,9 +82,7 @@ function extractText(content: unknown): string {
|
||||
}
|
||||
|
||||
function normalizeArguments(value: unknown): Record<string, unknown> {
|
||||
return value && typeof value === "object" && !Array.isArray(value)
|
||||
? (value as Record<string, unknown>)
|
||||
: {};
|
||||
return asNonArrayRecord(value);
|
||||
}
|
||||
|
||||
async function resolveLlamaCppResponseGrammar(params: {
|
||||
@@ -710,3 +708,4 @@ if (process.env.VITEST || process.env.NODE_ENV === "test") {
|
||||
mapToolsToLlamaFunctions,
|
||||
});
|
||||
}
|
||||
import { asNonArrayRecord } from "openclaw/plugin-sdk/string-coerce-runtime";
|
||||
|
||||
Reference in New Issue
Block a user