fix: normalize gateway dev mode detection
This commit is contained in:
@@ -55,11 +55,7 @@ describe("memory indexing with OpenAI batches", () => {
|
||||
let uploadedRequests: Array<{ custom_id?: string }> = [];
|
||||
const fetchMock = vi.fn(async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url =
|
||||
typeof input === "string"
|
||||
? input
|
||||
: input instanceof URL
|
||||
? input.toString()
|
||||
: input.url;
|
||||
typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
|
||||
if (url.endsWith("/files")) {
|
||||
const body = init?.body;
|
||||
if (!(body instanceof FormData)) {
|
||||
|
||||
@@ -71,10 +71,7 @@ describe("memory embedding batches", () => {
|
||||
await manager.sync({ force: true });
|
||||
|
||||
const status = manager.status();
|
||||
const totalTexts = embedBatch.mock.calls.reduce(
|
||||
(sum, call) => sum + (call[0]?.length ?? 0),
|
||||
0,
|
||||
);
|
||||
const totalTexts = embedBatch.mock.calls.reduce((sum, call) => sum + (call[0]?.length ?? 0), 0);
|
||||
expect(totalTexts).toBe(status.chunks);
|
||||
expect(embedBatch.mock.calls.length).toBeGreaterThan(1);
|
||||
});
|
||||
|
||||
@@ -711,7 +711,10 @@ export class MemoryIndexManager {
|
||||
}));
|
||||
}
|
||||
|
||||
private shouldSyncSessions(params?: { reason?: string; force?: boolean }, needsFullReindex = false) {
|
||||
private shouldSyncSessions(
|
||||
params?: { reason?: string; force?: boolean },
|
||||
needsFullReindex = false,
|
||||
) {
|
||||
if (!this.sources.has("sessions")) return false;
|
||||
if (params?.force) return true;
|
||||
const reason = params?.reason;
|
||||
@@ -876,9 +879,7 @@ export class MemoryIndexManager {
|
||||
force?: boolean;
|
||||
progress?: (update: MemorySyncProgressUpdate) => void;
|
||||
}) {
|
||||
const progress = params?.progress
|
||||
? this.createSyncProgress(params.progress)
|
||||
: undefined;
|
||||
const progress = params?.progress ? this.createSyncProgress(params.progress) : undefined;
|
||||
const vectorReady = await this.ensureVectorReady();
|
||||
const meta = this.readMeta();
|
||||
const needsFullReindex =
|
||||
@@ -972,7 +973,10 @@ export class MemoryIndexManager {
|
||||
}
|
||||
|
||||
private normalizeSessionText(value: string): string {
|
||||
return value.replace(/\s*\n+\s*/g, " ").replace(/\s+/g, " ").trim();
|
||||
return value
|
||||
.replace(/\s*\n+\s*/g, " ")
|
||||
.replace(/\s+/g, " ")
|
||||
.trim();
|
||||
}
|
||||
|
||||
private extractSessionText(content: unknown): string | null {
|
||||
|
||||
Reference in New Issue
Block a user