02 Ingest documents
Before you start
Read 01 RAG concepts in ArcFlow. Export Qdrant URL before ingest:
Stub embedding works without ARCFLOW_EMBEDDING_PROVIDER. Production ingest should use a real embedding string and matching provider env vars.
Concept
VectorStore lives in arcflow.memory (not re-exported from the top-level arcflow package on all branches). Construct it once, then call ingest per document:
| Argument | Role |
|---|---|
namespace | Qdrant collection key; must match agent MemoryConfig.namespace |
key | Logical document id (replace content by re-ingesting with the same key) |
text | Raw string to chunk and embed |
The return value is the number of chunks written. Empty namespace raises MemoryConfigurationError.
Ingest is separate from Workflow.run(). Typical patterns:
- Setup script: ingest in
main()before creating the workflow (seeexamples/support/ticket_rag_bot.py). - One-shot demo: read a file, ingest, then run the query in the same process (see
memory_guide_qa.pyon the restructure branch).
Chunking defaults come from the runtime when ingest is called without per-call overrides. Set MemoryChunkingConfig on the agent so retrieval expects the same segment sizes you used conceptually at ingest time.
Example
Save as ingest_demo.py:
Run:
File-based ingest (pattern from restructure branch memory_guide_qa.py):
Use the same NAMESPACE on the agent in that branch's script.
Domain examples that ingest before run:
| Example | Namespace | Key |
|---|---|---|
examples/support/ticket_rag_bot.py | support-tickets | kb |
examples/education/course_qa.py | course-101 | syllabus |
examples/healthcare/protocol_qa.py | clinical-kb | protocols |
Verify
| Check | Expected |
|---|---|
store.ingest("", "k", "text") | MemoryConfigurationError |
| Successful ingest | Positive integer chunk count |
store.search(NAMESPACE, query, top_k=2) after ingest | Non-empty list when Qdrant is up and namespace matches |
Re-ingesting with the same key replaces that document's chunks rather than duplicating under a new id.
Next
03 Retrieval and agent wiring connects ingested namespaces to agents and verifies MemoryRetrieved on query runs.