?
DataSourceDocument
TypeA document in the corpus and its ingest state, as returned by documents().
One document in the corpus, as documents() returns it. It carries the document's id, its ingest status, an errorMessage when parsing failed, chunk and page counts, the metadata set at add time, and timestamps. Poll it after add until status reaches done, and read errorMessage to see why a document failed to parse.
DataSourceDocument.ts
interface DataSourceDocument { id: string filename: string | null status: 'processing' | 'done' | 'error' errorMessage: string | null chunkCount: number | null pageCount: number | null metadata: DocumentMetadata | null createdAt: string ingestedAt: string | null }
Fields
id
string
The document id, used with chunks() and documentIds filters.
filename
string | null
Original filename.
status
enum
Where the document is in ingest.
errorMessage
string | null
Why parsing failed, when status is error.
chunkCount
number | null
Chunks produced, once done.
pageCount
number | null
Pages, for paged formats.
metadata
DocumentMetadata | null
Tags set at add time.
createdAt
string
When the document was added.
ingestedAt
string | null
When processing finished.
Surface failures
const failed = (await Policies.documents()) .filter((d) => d.status === 'error') .map((d) => ({ file: d.filename, why: d.errorMessage }));