Skip to navigation

Create or edit a memory

Without id, creates a memory, and outcome is one of:

  • saved: the memory was written.
  • replaced: a lesson or fact of the same kind was similar enough to count as a near-duplicate ([memory] duplicate_similarity). The new memory was written and the old one deleted; previous_title names it.
  • duplicate: nothing was written, and id is the memory that already exists. This happens when the same text is already stored under the same id, and when an episode has a near-duplicate episode, because episodes are never replaced.

With id, edits that memory. A successful edit always answers replaced, with the memory’s id after the edit and its own old title in previous_title. Tell an edit from a replaced near-duplicate by whether you sent id. An edit that changes the kind or text changes the id, because the id derives from both. If that new id belongs to a different memory that already exists, nothing is written and the answer is duplicate with that memory’s id.

Writes are serialised inside the dashboard.

Request

This endpoint expects an object.
kindstringRequired

lesson, fact or episode (case-insensitive).

textstringRequired
10 to 2,000 characters after trimming.
scopestringRequired

global or an empty string for a global memory; otherwise the project path it applies to.

idstringOptional

Leave out to create a memory. Give an existing id (or unique prefix) to edit it. A blank id is refused.

confidenceintegerOptional0-100Defaults to 100
A percent.

Response

The outcome of the write.
savedobject
OR
replacedobject

Either a new memory replaced a near-duplicate of the same kind, which is now gone, or an edit succeeded. id is the memory’s id after the write.

OR
duplicateobject

Nothing was written. id is the memory that already exists: the same text under the same id, a near-duplicate episode, or the memory an edit’s new id would collide with.

Errors

400
Bad Request Error
404
Not Found Error
409
Conflict Error
413
Content Too Large Error
421
Misdirected Request Error
503
Service Unavailable Error