One observation
The example below is one observation.
Send a
timestamp when you send old messages. Without it, every message looks like it happened now.
Clients written before
speaker existed. Without speaker, Priors reads the first tag as the speaker, does not keep the tags, and records user when there are no tags either. This still works, but send speaker in new code: it keeps your tags as labels.Images in an observation
The observe calls do not accept image bytes. There are two ways to include an image:img_url: a URL that the Priors servers can download. Priors downloads the image, writes a description of it, and learns the description together with your text. The URL can be up to 2,048 characters. The download must finish within 10 seconds. The image must be JPEG, PNG, GIF, or WebP, and at most 10 MB. A URL onlocalhost, on a private network, or behind a login cannot be downloaded.blip_caption: your own description of the image. The agent learns it together with the downloaded description, or instead of it when the download fails.
blip_caption when you have one.
The observe call: learn only
Use observe when you want the agent to remember something and you do not need an answer. One call can carry up to 100 observations.
The success response
The status is202. Nothing has been learned yet. Save the observation_id.
Errors
The first table lists errors where your request is wrong. Correct the request before you send it again.
The second table lists errors where your request is correct but Priors cannot accept it now. Wait, then send the same request again.
Follow the learning
Learning finishes after the202. To know when it is done, poll the status: call GET .../observe/{observation_id}/status every one or two seconds until status is committed.
committed, failed, and cancelled are final. The other values change.
turns_processed counts the pieces that have been read. The memory for the last piece is written a moment after the read. So turns_processed can equal turns_total before the status is committed. Wait for committed.
Three more fields can appear on the status:
Cancel an observation
POST .../observe/{observation_id}/cancel stops learning that has not finished. The response is 200 with the status after the cancel. Pieces that were already learned stay learned. If the learning had already finished, the call returns the final status and changes nothing.
The observe-file call: learn from a document
Upload a file, and the agent reads it for you. Priors converts the file to text, splits the text into pieces, and learns each piece as one observation.
multipart/form-data. The table below lists every field.
One call carries one file. To upload several files, send several calls, one after another.
The success response
The status is202. The file has been converted and split. Learning starts now.
Then poll the status in the same way as for
observe.
An agent reads one file at a time. A second file sent while it reads one is not refused: it is accepted with queued: true and starts when the first one finishes.
Upload the same file again safely
Send anIdempotency-Key header with a value that is unique for this upload. If you send the same key and the same file again, Priors returns the original 202 and does not read or charge the file again. If you send the same key with a different file, Priors returns 409. Priors keeps a key for 24 hours.
Errors
Priors converts and splits the file before it returns202. So every problem with the file itself is an error on this call, not a failed status later.
The first table lists errors where the file is the problem. Correct the file, then upload it again.
Two
409 codes are neither of those, and waiting does not clear them:
document_already_ingestedmeans this agent already read these exact bytes in another thread. One memory index serves every thread, so what that read learned is already searchable from here. To read the file again anyway, sendallow_duplicate=true. That stores a second copy of every memory, which costs more and puts duplicates in competition during retrieval, so send it only when you mean it.document_uploaded_elsewheremeans an upload of this file in another thread stopped partway or failed. Finish it there withfinish-learning, which learns and charges only what is left. Or sendallow_duplicate=trueto read the whole file again here, charged in full.
After the 202
Learning can still stop after the file was accepted. The status then reads failed, and error says why in one sentence. Pieces that were already learned stay learned, and Priors keeps a copy of the file.
To finish it, call finish-learning on its source_id. You do not send the file again, and only the pieces that were not learned are read and charged. Uploading the same file again to the same thread also resumes it.
A restart of Priors does not stop an upload. The status reads interrupted, then the upload resumes by itself.
What to send
- Send facts, decisions, and events. Send them soon after they happen, with a
timestamp. - Send each document once. Priors detects a repeat upload of the same bytes and skips it.
- Do not send secrets. Everything you send can become a memory that the agent repeats in an answer.