Skip to main content

Requirements

  • Python 3.13 or later.
  • An existing Sphinx project.
  • An API key provided to you by Sphinx.
The package name is sphinx_learn. The Python import name is sphinx_ai.

createKnowledgeBaseClient

createKnowledgeBaseClient(api_key: str, project_id: str) -> KnowledgeBaseClient

Document

A document is an input to an ingest job. Currently, the supported document type is:
  • File: A document supplied as bytes with a source filename or path.

File

File(path: str, content: bytes) File is immutable. Its constructor validates the path and content immediately, raising TypeError for incorrect types or ValueError for invalid values. Create a new File to change its path or content.

KnowledgeBaseClient.fit

knowledge_base.fit(prompt: str, docs: list[Document]) -> Ingestion The method validates the prompt, document types, document count, and total content size before uploading, uploads documents sequentially, and then submits one agentic_ingest job. Leading and trailing whitespace is removed from the prompt when the job is submitted.

Input constraints

These limits are enforced locally before any upload. Per-file constraints are checked when you construct each File; prompt and batch constraints are checked by .fit. Size and count limits are inclusive. Text files must satisfy both the byte-size and estimated-token limits. The token estimate allows at most 1,000,000 decoded characters per file; it is not a model-specific tokenizer count. An optional UTF-8 byte-order mark counts toward the byte size but is excluded from the decoded character count. The text limits apply to files without a supported binary extension, regardless of their filename.

Source paths

Allowed characters are ASCII letters (A–Z, a–z), digits (0–9), and:
Use / to separate path segments. Empty segments and segments equal to . or .. are rejected. Consequently, paths cannot start or end with / or contain //. Spaces, backslashes, colons, and non-ASCII characters are also rejected.

Supported formats

Extension checks are case-insensitive. Any extension outside the binary list, or no extension, takes the text-validation path. For example, a binary .xls or ZIP archive will fail text validation; .xlsx and .ods are the supported binary spreadsheet formats. A filename consisting only of an extension, such as .pdf, is treated as having no extension. For the listed binary extensions, the client does not inspect whether the bytes form a valid document. A corrupt or mislabeled file can pass local validation and fail during ingestion. Renaming an unsupported binary file does not convert it to a supported format. MIME types are inferred from the filename, with application/octet-stream as the fallback.

Failure handling

Ingestion.job_url

ingestion.job_url() -> str Returns the job’s Sphinx UI URL.