mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-11-04 07:30:17 +00:00
fix(lib): forward dreaming in $fetch document add and batch requests
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
parent
225fbf0e0c
commit
0025cfe519
3 changed files with 34 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
BulkDeleteMemoriesSchema,
|
||||
ConnectionResponseSchema,
|
||||
ContainerTagSettingsUpdateSchema,
|
||||
DreamingSchema,
|
||||
CreateProjectSchema,
|
||||
DeleteProjectResponseSchema,
|
||||
DeleteProjectSchema,
|
||||
|
|
@ -231,6 +232,7 @@ export const apiSchema = createSchema({
|
|||
containerTag: z.string().optional(),
|
||||
entityContext: z.string().max(1500).optional(),
|
||||
metadata: z.record(z.unknown()).optional(),
|
||||
dreaming: DreamingSchema.optional(),
|
||||
}),
|
||||
output: z.object({
|
||||
results: z.array(
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ import {
|
|||
BulkDeleteMemoriesSchema,
|
||||
DocumentsWithMemoriesQuerySchema,
|
||||
ListMemoriesQuerySchema,
|
||||
MemoryAddSchema,
|
||||
MemoryUpdateSchema,
|
||||
SearchRequestSchema,
|
||||
Searchv4RequestSchema,
|
||||
} from "./api"
|
||||
|
|
@ -175,3 +177,24 @@ describe("pagination query schemas", () => {
|
|||
expect(BulkDeleteMemoriesSchema.safeParse(ok).success).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("document add schemas", () => {
|
||||
it("keeps dreaming on add requests", () => {
|
||||
expect(
|
||||
MemoryAddSchema.parse({ content: "probe", dreaming: "instant" }),
|
||||
).toEqual({ content: "probe", dreaming: "instant" })
|
||||
})
|
||||
|
||||
it("rejects unknown dreaming modes", () => {
|
||||
expect(
|
||||
MemoryAddSchema.safeParse({ content: "probe", dreaming: "eager" })
|
||||
.success,
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it("does not add dreaming to update requests", () => {
|
||||
expect(
|
||||
MemoryUpdateSchema.parse({ content: "probe", dreaming: "instant" }),
|
||||
).toEqual({ content: "probe" })
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -170,7 +170,15 @@ export const MemoryUpdateSchema = z.object({
|
|||
}),
|
||||
})
|
||||
|
||||
export const MemoryAddSchema = MemoryUpdateSchema
|
||||
export const DreamingSchema = z.enum(["dynamic", "instant"]).openapi({
|
||||
description:
|
||||
'Processing mode. "dynamic" (default) groups related documents together before extracting memories; "instant" processes each document on its own right away.',
|
||||
example: "instant",
|
||||
})
|
||||
|
||||
export const MemoryAddSchema = MemoryUpdateSchema.extend({
|
||||
dreaming: DreamingSchema.optional(),
|
||||
})
|
||||
|
||||
export const PaginationSchema = z
|
||||
.object({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue