mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 20:50:52 +08:00
同时收敛启动与运维脚本默认行为(含 wiki worker)、更新 Admin 可观测性与相关测试,降低首轮时延并提高运行稳定性。 Made-with: Cursor
56 lines
1.8 KiB
TypeScript
56 lines
1.8 KiB
TypeScript
import {
|
|
isMissingEmbeddingApiKeyError,
|
|
mapBatchEmbeddingsByIndex,
|
|
sanitizeEmbeddingCacheHeaders,
|
|
type MemoryEmbeddingProviderAdapter,
|
|
} from "openclaw/plugin-sdk/memory-core-host-engine-embeddings";
|
|
import { runVoyageEmbeddingBatches } from "./embedding-batch.js";
|
|
import {
|
|
createVoyageEmbeddingProvider,
|
|
DEFAULT_VOYAGE_EMBEDDING_MODEL,
|
|
} from "./embedding-provider.js";
|
|
|
|
export const voyageMemoryEmbeddingProviderAdapter: MemoryEmbeddingProviderAdapter = {
|
|
id: "voyage",
|
|
defaultModel: DEFAULT_VOYAGE_EMBEDDING_MODEL,
|
|
transport: "remote",
|
|
authProviderId: "voyage",
|
|
autoSelectPriority: 40,
|
|
allowExplicitWhenConfiguredAuto: true,
|
|
shouldContinueAutoSelection: isMissingEmbeddingApiKeyError,
|
|
create: async (options) => {
|
|
const { provider, client } = await createVoyageEmbeddingProvider({
|
|
...options,
|
|
provider: "voyage",
|
|
fallback: "none",
|
|
});
|
|
return {
|
|
provider,
|
|
runtime: {
|
|
id: "voyage",
|
|
cacheKeyData: {
|
|
provider: "voyage",
|
|
baseUrl: client.baseUrl,
|
|
model: client.model,
|
|
headers: sanitizeEmbeddingCacheHeaders(client.headers, ["authorization"]),
|
|
},
|
|
batchEmbed: async (batch) => {
|
|
const byCustomId = await runVoyageEmbeddingBatches({
|
|
client,
|
|
agentId: batch.agentId,
|
|
requests: batch.chunks.map((chunk, index) => ({
|
|
custom_id: String(index),
|
|
body: { input: chunk.text },
|
|
})),
|
|
wait: batch.wait,
|
|
concurrency: batch.concurrency,
|
|
pollIntervalMs: batch.pollIntervalMs,
|
|
timeoutMs: batch.timeoutMs,
|
|
debug: batch.debug,
|
|
});
|
|
return mapBatchEmbeddingsByIndex(byCustomId, batch.chunks.length);
|
|
},
|
|
},
|
|
};
|
|
},
|
|
};
|