mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-11-05 07:39:44 +00:00
Merge 19f5cb26b6 into ad443e155c
This commit is contained in:
commit
49c2e8d9d8
3 changed files with 61 additions and 18 deletions
|
|
@ -4,6 +4,7 @@ import {
|
|||
AnalyticsChatResponseSchema,
|
||||
AnalyticsMemoryResponseSchema,
|
||||
AnalyticsUsageResponseSchema,
|
||||
BatchAddDocumentsRequestSchema,
|
||||
BulkDeleteMemoriesResponseSchema,
|
||||
BulkDeleteMemoriesSchema,
|
||||
ConnectionResponseSchema,
|
||||
|
|
@ -215,23 +216,7 @@ export const apiSchema = createSchema({
|
|||
output: MemoryResponseSchema,
|
||||
},
|
||||
"@post/documents/batch": {
|
||||
input: z.object({
|
||||
documents: z
|
||||
.array(
|
||||
z.object({
|
||||
content: z.string(),
|
||||
containerTags: z.array(z.string()).optional(),
|
||||
containerTag: z.string().optional(),
|
||||
entityContext: z.string().max(1500).optional(),
|
||||
metadata: z.record(z.unknown()).optional(),
|
||||
}),
|
||||
)
|
||||
.min(1)
|
||||
.max(600),
|
||||
containerTag: z.string().optional(),
|
||||
entityContext: z.string().max(1500).optional(),
|
||||
metadata: z.record(z.unknown()).optional(),
|
||||
}),
|
||||
input: BatchAddDocumentsRequestSchema,
|
||||
output: z.object({
|
||||
results: z.array(
|
||||
z.object({
|
||||
|
|
|
|||
|
|
@ -1,9 +1,11 @@
|
|||
import { describe, expect, it } from "bun:test"
|
||||
import { readFileSync } from "node:fs"
|
||||
import {
|
||||
BatchAddDocumentsRequestSchema,
|
||||
BulkDeleteMemoriesSchema,
|
||||
DocumentsWithMemoriesQuerySchema,
|
||||
ListMemoriesQuerySchema,
|
||||
MemoryAddSchema,
|
||||
SearchRequestSchema,
|
||||
Searchv4RequestSchema,
|
||||
} from "./api"
|
||||
|
|
@ -175,3 +177,32 @@ describe("pagination query schemas", () => {
|
|||
expect(BulkDeleteMemoriesSchema.safeParse(ok).success).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("document add input schemas", () => {
|
||||
it("preserves dreaming on a single document add", () => {
|
||||
const parsed = MemoryAddSchema.parse({
|
||||
content: "probe",
|
||||
dreaming: "instant",
|
||||
})
|
||||
|
||||
expect(parsed).toEqual({ content: "probe", dreaming: "instant" })
|
||||
})
|
||||
|
||||
it("preserves dreaming on a batch document add", () => {
|
||||
const parsed = BatchAddDocumentsRequestSchema.parse({
|
||||
documents: [{ content: "probe" }],
|
||||
dreaming: "dynamic",
|
||||
})
|
||||
|
||||
expect(parsed).toEqual({
|
||||
documents: [{ content: "probe" }],
|
||||
dreaming: "dynamic",
|
||||
})
|
||||
})
|
||||
|
||||
it("rejects an invalid dreaming mode", () => {
|
||||
expect(() =>
|
||||
MemoryAddSchema.parse({ content: "probe", dreaming: "later" }),
|
||||
).toThrow()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -170,7 +170,34 @@ export const MemoryUpdateSchema = z.object({
|
|||
}),
|
||||
})
|
||||
|
||||
export const MemoryAddSchema = MemoryUpdateSchema
|
||||
export const DreamingModeSchema = z.enum(["dynamic", "instant"]).openapi({
|
||||
description:
|
||||
'Processing mode. "dynamic" (default) groups related documents together so memories form from coherent units. "instant" processes each document on its own right away and bills one extra operation per document.',
|
||||
example: "instant",
|
||||
})
|
||||
|
||||
export const MemoryAddSchema = MemoryUpdateSchema.extend({
|
||||
dreaming: DreamingModeSchema.optional(),
|
||||
})
|
||||
|
||||
export const BatchAddDocumentsRequestSchema = z.object({
|
||||
documents: z
|
||||
.array(
|
||||
z.object({
|
||||
content: z.string(),
|
||||
containerTags: z.array(z.string()).optional(),
|
||||
containerTag: z.string().optional(),
|
||||
entityContext: z.string().max(1500).optional(),
|
||||
metadata: z.record(z.unknown()).optional(),
|
||||
}),
|
||||
)
|
||||
.min(1)
|
||||
.max(600),
|
||||
containerTag: z.string().optional(),
|
||||
entityContext: z.string().max(1500).optional(),
|
||||
metadata: z.record(z.unknown()).optional(),
|
||||
dreaming: DreamingModeSchema.optional(),
|
||||
})
|
||||
|
||||
export const PaginationSchema = z
|
||||
.object({
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue