mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-27 09:21:35 +07:00
fix(memory): bootstrap proxy for LanceDB embeddings
This commit is contained in:
committed by
Ayaan Zaidi
parent
2c3cf4f387
commit
09a4453026
@@ -204,6 +204,7 @@ describe("memory plugin e2e", () => {
|
||||
const embeddingsCreate = vi.fn(async () => ({
|
||||
data: [{ embedding: [0.1, 0.2, 0.3] }],
|
||||
}));
|
||||
const ensureGlobalUndiciEnvProxyDispatcher = vi.fn();
|
||||
const toArray = vi.fn(async () => []);
|
||||
const limit = vi.fn(() => ({ toArray }));
|
||||
const vectorSearch = vi.fn(() => ({ limit }));
|
||||
@@ -220,6 +221,9 @@ describe("memory plugin e2e", () => {
|
||||
}));
|
||||
|
||||
vi.resetModules();
|
||||
vi.doMock("openclaw/plugin-sdk/infra-runtime", () => ({
|
||||
ensureGlobalUndiciEnvProxyDispatcher,
|
||||
}));
|
||||
vi.doMock("openai", () => ({
|
||||
default: class MockOpenAI {
|
||||
embeddings = { create: embeddingsCreate };
|
||||
@@ -277,6 +281,10 @@ describe("memory plugin e2e", () => {
|
||||
await recallTool.execute("test-call-dims", { query: "hello dimensions" });
|
||||
|
||||
expect(loadLanceDbModule).toHaveBeenCalledTimes(1);
|
||||
expect(ensureGlobalUndiciEnvProxyDispatcher).toHaveBeenCalledOnce();
|
||||
expect(ensureGlobalUndiciEnvProxyDispatcher.mock.invocationCallOrder[0]).toBeLessThan(
|
||||
embeddingsCreate.mock.invocationCallOrder[0],
|
||||
);
|
||||
expect(embeddingsCreate).toHaveBeenCalledWith({
|
||||
model: "text-embedding-3-small",
|
||||
input: "hello dimensions",
|
||||
|
||||
@@ -10,6 +10,7 @@ import { randomUUID } from "node:crypto";
|
||||
import type * as LanceDB from "@lancedb/lancedb";
|
||||
import { Type } from "@sinclair/typebox";
|
||||
import OpenAI from "openai";
|
||||
import { ensureGlobalUndiciEnvProxyDispatcher } from "openclaw/plugin-sdk/infra-runtime";
|
||||
import { definePluginEntry, type OpenClawPluginApi } from "./api.js";
|
||||
import {
|
||||
DEFAULT_CAPTURE_MAX_CHARS,
|
||||
@@ -168,6 +169,7 @@ class Embeddings {
|
||||
if (this.dimensions) {
|
||||
params.dimensions = this.dimensions;
|
||||
}
|
||||
ensureGlobalUndiciEnvProxyDispatcher();
|
||||
const response = await this.client.embeddings.create(params);
|
||||
return response.data[0].embedding;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user