create_index_from_files builds a new index directly from raw documents. You upload PDF and
DOCX files; the server parses them, splits them into chunks, generates embeddings, and builds
the index. The call returns when the index is ready to query.
Requires
moss 1.7.3+. Also available in JavaScript as
createIndexFromFiles (@moss-dev/moss 1.7.1+).How it works
The call handles the full flow: it registers the files, uploads each one, and triggers parsing, embedding, and the index build server-side. It blocks until the index is ready and returns aMutationResult. Jobs time out after 30 minutes.
There is no progress callback in Python.
Files
Each entry is aParseFileInput:
Limits:
- 1 to 20 files per call. Each call creates a new index, and files cannot be appended to an existing index afterwards, so an index is built from at most 20 files.
- 50 MB per file, enforced server-side. The SDK does not pre-check size; an oversized file fails during the job.
Options
- model_id (
Optional[str]=None) - defaults to"moss-minilm";"moss-mediumlm"is also supported."custom"is not supported - the server generates embeddings during parsing. - parse_options (Optional[
ParseOptions] =None) - extraction controls, below.
Parse options
All fields ofParseOptions are optional; omitted fields use
the server defaults.
What gets indexed
Documents are parsed into retrieval-sized chunks with layout awareness. Repeating page headers, footers, and page numbers are excluded from the indexed text. A scanned or image-only document produces no readable text unless OCR runs - if a file fails with “No readable text was found”, retry withparse_options=ParseOptions(ocr_mode="full_ocr").
Querying a parse-built index
Query the index without loading it -client.query(name, text) runs server-side when the
index is not loaded locally:
Errors
Passingmodel_id="custom" raises ValueError before anything is uploaded. Other failures
raise RuntimeError with the same messages as the JavaScript SDK: