Skip to main content

Knowledge bank

Documents your avatar can search when a question goes beyond its prompt.

The knowledge bank is where you put the documents an avatar should be able to answer from — a product manual, a policy handbook, a course reader. Uploaded documents are split into chunks and indexed, and the avatar searches them during a conversation when it needs to.

Documents are separate from what an avatar remembers about the people it talks to — that is Memory.

Uploading a document​

cURL
curl -s "https://backend.goldenengine.ai/v1/knowledge-bank/upload" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
ConstraintValue
FormatsPDF and DOCX only
Maximum size50 MB per file

The filename must end in .pdf or .docx, and if the file part carries a content type it must be application/pdf or application/vnd.openxmlformats-officedocument.wordprocessingml.document. Anything else — including the generic application/octet-stream that many HTTP clients send by default — is rejected with 400. In Node.js, give the Blob a type, as in the sample above.

To load several documents in one request, post up to five of them as repeated files fields to /v1/knowledge-bank/upload/batch. Every file is checked — type, extension, empty, size, and a count of 1 to 5 — before any is stored, so one bad file fails the whole request with 400 and nothing is queued. Otherwise the response lists one result per file, in the order you sent them — 201 when all were queued, 207 when some were not. The upload guide shows how to read it.

Processing​

Extraction is asynchronous — the upload returns before the document is searchable.

uploaded → processing → completed
↘ failed
StatusMeaning
uploadedStored, extraction not started
processingBeing parsed and chunked
completedIndexed and searchable
failedExtraction errored, or the queue was unavailable; see error_message

Poll GET /v1/knowledge-bank/{item_id} until it reaches completed. A finished item reports chunk_count and total_tokens, which tell you how much text was actually extracted. A scanned PDF with no text layer ends in failed with error_message set to "Document contains no extractable text" — run it through OCR and upload it again. A completed item with a surprisingly low total_tokens usually means only part of the file had a text layer.

GET /v1/knowledge-bank lists the documents in the account bank — the ones not attached to any avatar — and DELETE /v1/knowledge-bank/{item_id} removes one. Both GET and DELETE on /v1/knowledge-bank/{item_id} return 404 for a document that is attached to an avatar; use the avatar's knowledge endpoints below for those.

Which avatars see a document​

Where a document sits decides who can search it:

Where the document isWho can use it
In the account bank, unattachedNo avatar
Uploaded or attached to one of your avatarsThat avatar only
Attached to a stock avatarThat stock avatar, in your account's conversations

A document answers only for the avatar it was uploaded or attached to. An upload to /v1/knowledge-bank/upload lands in the account bank and is used by no avatar until you attach it — upload straight to the avatar instead if you already know which one it is for.

Stock avatars draw on two sources: their own built-in documents, and documents you have attached to that stock avatar from your account. Attaching to a stock avatar is recorded per account and leaves the document in your bank, so the same bank document can be attached to several stock avatars.

Attaching to an avatar​

Upload straight to an avatar to scope a document to it from the start:

cURL
curl -s "https://backend.goldenengine.ai/v1/avatars/$AVATAR_ID/knowledge" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \

This uploads and attaches in one step; POST /v1/avatars/{avatar_id}/knowledge/batch does the same for up to five files. To attach a document that is already in the bank, send its id to POST /v1/avatars/{avatar_id}/knowledge/attach; that returns 409 if the document has not finished extracting or is already attached to another of your avatars. GET /v1/avatars/{avatar_id}/knowledge lists what is attached.

PATCH /v1/avatars/{avatar_id} with knowledge_base_ids sets the avatar's documents in one go. It replaces the whole set: documents you leave out go back to the account bank (where no avatar uses them), and documents you list are moved to this avatar. It does not make the checks /attach makes — it will move a document that is still processing, or take one away from another avatar, without an error. An id the account does not own is rejected with 422.

How retrieval works​

Retrieval is decided by the language model, not applied to every message. The avatar is given a search_knowledge_base tool and instructed to call it before answering any question that its documents might cover. Greetings and acknowledgements skip the search.

When the tool fires:

  1. The model issues a search query derived from what the user asked.
  2. The query is embedded and matched against the chunks of every document the avatar can see — the documents uploaded or attached to it. Weak matches are dropped and duplicate passages removed, and if nothing matches by meaning a keyword pass looks for names the transcription may have garbled.
  3. Matching chunks are returned to the model, which answers from them.

Two consequences worth designing around. First, an avatar that never calls the tool will answer from the model's own knowledge — if answers look generic, the documents are usually attached to a different avatar, still processing, or empty of extractable text. Second, retrieval adds latency to the turn where it happens, so turns that trigger a search are slower than ordinary conversation.

Testing retrieval​

POST /v1/knowledge-bank/search runs a similarity search over the account bank without starting a conversation. Use it to check that a document's text was extracted and chunked the way you expect:

cURL
curl -s "https://backend.goldenengine.ai/v1/knowledge-bank/search" \
-H "X-Api-Key: $GOLDENENGINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "how do I reset my password", "limit": 5}'
{
"chunks": [
{
"knowledge_base_item_id": "b71f...",
"filename": "handbook.pdf",
"chunk_index": 42,
"content": "To reset your password, visit...",
"page_number": 7,
"token_count": 118
}
]
}

limit defaults to 5 and caps at 20.

This is not the avatar's own search. It covers only documents in the account bank — the ones no avatar uses until you attach them — and anything already attached to one of your avatars is invisible to it. Use it to check a document before you attach it. It returns the nearest chunks as they are, with no similarity threshold, no de-duplication, and no keyword fallback. Good results here tell you the text is in the index; they do not guarantee the avatar will retrieve the same passage. If a question fails in conversation, empty or off-topic results here point at the documents; good results that the avatar still ignores point at the prompt.