La documentation est disponible en anglais.
Documentation / Technical guides
RAG document upload
Ingest a file into the workspace knowledge base, then pass document_id in rag_options (requires an active RAG governance policy).
Supported extensions include pdf, txt, md, csv, json, docx (see RAG_UPLOAD_EXTENSIONS in the SDK). rag_ensure_document uploads and waits, or reuses a ready document with the same filename when reuse_existing=True (default). Enable RAG via create_governance_policy(..., kind="rag") first.
from tokensaver_sdk import TokenSaver
ts = TokenSaver(api_key="ts_...")
doc = ts.rag_ensure_document("./path/to/example_document.docx")
doc_id = str(doc["document_id"])
q1 = ts.ask(
"What is this document about? Answer in one short paragraph.",
provider="openai",
model="gpt-4o",
rag_similarity_threshold=0.55,
rag_options={"document_ids": [doc_id]},
)
print(q1.text)
q2 = ts.ask(
"List three key points from the document.",
provider="openai",
model="gpt-4o",
compression_level=4,
rag_options={"document_ids": [doc_id], "top_k": 8},
)
print(q2.text)
Lower-level upload (no wait)
meta = ts.rag_upload_document("./notes.md", name="notes.md")
ts.rag_wait_document_ready(meta["document_id"])
# Or one call:
# ready = ts.rag_upload_and_wait("./data/report.pdf")