client.sources. Only the casing of the longer names differs:
Only drag-and-drop sources can be created with a key. Google Drive and
SharePoint sources need the console’s OAuth flow. They can show up in
sources.list() as organization sources, but you cannot create them here.How it works
sources.create runs the first four steps and returns while the source is
pending or syncing. Wait until it is synced before you search it.
Create a source
- Python SDK
- JavaScript SDK
- HTTP
files can be one file Path, a folder Path (its top-level files
only, no recursion, hidden files skipped), or an iterable of file Paths. The
SDK refuses these before any upload with InvalidParams:
- a plain
str: wrap a path inPath(...); - an empty list, or a file that does not exist;
- two files with the same name;
- more than 50 files.
files is one File, one { filename, content } object whose
content is a Blob, ArrayBuffer, or Uint8Array, or an array of them.
There is no path input: read the files yourself, as in the snippet above. A
string, an empty array, two files with the same name, or more than 50 files
throw InvalidParams before any upload. See
client.sources.
name is optional. Without it, the server generates one.
Two ids
A source has two ids. Do not mix them up.Wait for the sync
The wait method polls the source until it issynced. By default, it gives up
after 10 minutes and polls every 5 seconds. The Python SDK takes seconds
(timeout=600.0, interval=5.0). The JavaScript SDK takes milliseconds
({ timeout: 600_000, interval: 5_000 }).
- Python SDK
- JavaScript SDK
Give the source to an agent
Put the source’s numberid in an IndexedDocumentsCapability.
- Python SDK
- JavaScript SDK
- HTTP
chat.start, or
narrow it for one message with the message scope. See
Capabilities.
Chat as the key owner
A source created with a key is private to the key owner. A chat that searches it must run as the owner: create the client with the owner’s id as its user id. The owner isagent.owner on any agent the key created.
- Python SDK
- JavaScript SDK
- HTTP
You have no authorized document sources. The agent then says it found nothing. The
COMINTY_USER_ID of your client may not be the key owner, so read agent.owner.
Read a citation
An answer cites its documents inline, as<cite document_id="2698#10778" pages="1" name="facts.txt"/>. The id is the
source id, a #, and the document’s own identifier. It is not always a number.
Resolve it to its source and file:
- Python SDK
- JavaScript SDK
- HTTP
- An unknown id raises
NotFoundError(404). There is no call that lists documents. An empty id is refused before any request (ValueErrorin Python,InvalidParamsin JavaScript). document_urican be null. For a drag-and-drop source, it ends with the id of the file, the one the download method takes.
- Python SDK
- JavaScript SDK
- HTTP
Keep a source up to date
New files follow the same rule. After you add or remove a file, the source is
indexed again, and the change reaches the agent only once the source is
synced again.- Python SDK
- JavaScript SDK
- HTTP
- Adding files uploads them into the source’s drive, then requests a sync if the source’s status accepts one. If a sync is already running, the new files are left for it or for the daily sync. The limit of 50 files counts the files already in the source.
- Removing a file deletes it, then requests a sync under the same rule. An
empty file id is refused before any request (
ValueErrorin Python,InvalidParamsin JavaScript). updateonly changes the name. The drive of a drag-and-drop source cannot change.list()returns the key owner’s sources and the organization’s sources, archived ones included.get(pid)reads the list and picks, because a key has no single-source read. An unknownpidraisesNotFoundError.
APIError with status 400 and detail Operation is not valid.
pause returns the source as pausing. It reaches paused a moment later, and
only then does start resume it. A start while the source is still pausing
fails with the same 400.
Limits
- A source holds at most 50 files. The SDK checks it before it uploads.
- A user has at most 100 drives. Each
sources.createmakes one, and a drive cannot be deleted. Reuse a source and add files to it instead of creating a new one for every batch. - A presigned download URL is valid for 5 minutes.
- Uploads go straight to storage. The API key never reaches the storage host, and presigned signatures never appear in error messages.
Supported file types
The indexing pipeline reads more than 130 file formats. These are the most common ones.
Audio and video files are transcribed by the indexing pipeline. Almost every
common audio and video format works. The agent searches
and reads the transcript. For a video, it does not see the images, only what is
said.
What the agent can do with an indexed file
Indexing lets the agent find a file and read its content. Two limits apply today:- Spreadsheets are not part of the search. An Excel file (or another spreadsheet) is registered in the source with a document id, but the lexical and semantic search never returns its content. The agent can still list the documents of a source, spreadsheets included, and open one by its document id. It then reads the content extracted from the spreadsheet, as long as it is not too large. For a large spreadsheet, or to work on its data, attach the file to the chat instead, with the upload method of the Python SDK or the JavaScript SDK.
- The agent cannot download the raw file. It reads the indexed content, but it cannot fetch the original file to transform it, for example to edit a document or to compute on a spreadsheet. To get the original, download it from your own code, as in Read a citation.
Next steps
Custom agents
Create and manage the agent that searches the source.
Capabilities
Narrow the sources and documents of a thread or a message.