Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_addcontenttorag Discord

Swarmauri Add Content to RAG Tool

swarmauri_tool_addcontenttorag writes text into a RAG knowledge base, with optional metadata tags. It is the storage counterpart of swarmauri_tool_queryknowledgebase: one tool puts content in, the other reads ranked results back out.

Features

  • Add text content to any knowledge base that provides add_documents(documents), the same contract the query tool reads from.
  • Attach metadata tags to each write, so results can be filtered later.
  • Copies the caller's mapping instead of storing their dict, so a later mutation elsewhere cannot rewrite what was indexed.
  • Keeps the adapter out of serialized state. The knowledge base is excluded from model_dump(), so a tool can be logged or persisted without carrying a live database handle.
  • Wraps store failures in a RuntimeError without passing connection details through to the caller.

Installation

# With uv
uv add swarmauri_tool_addcontenttorag

# With pip
pip install swarmauri_tool_addcontenttorag

Usage

from swarmauri_tool_addcontenttorag import AddContentToRAGTool


class InMemoryKnowledgeBase:
    """Any object with add_documents(documents) works."""

    def __init__(self):
        self.documents = []

    def add_documents(self, documents):
        self.documents.extend(documents)


knowledge_base = InMemoryKnowledgeBase()

tool = AddContentToRAGTool()
tool.knowledge_base = knowledge_base

tool(content="Reset your password from Settings.", metadata={"source": "handbook"})
# {"added": 1, "content_length": 34, "metadata": {"source": "handbook"}}

knowledge_base.documents
# [{"content": "Reset your password from Settings.",
#   "metadata": {"source": "handbook"}}]

Result keys

Key Type Meaning
added int Number of documents written
content_length int Characters written
metadata dict Tags stored with the content

Expected workflows

  • Load a knowledge base at startup. Add each document or chunk before the agent starts answering.
  • Update it while running. Add new content as it arrives; the paired query tool sees it without a restart.
  • Tag as you write. Store source, page or version with each entry so retrieval can filter on it.

FAQ

Does it chunk content?
No. It writes what it is given. Chunking belongs upstream, where the document is split, so the tool never silently alters what was stored.

How is versioning handled?
Through metadata. Tag each write with a version or timestamp; replacing an earlier version is the store's decision, not this tool's.

What if the store fails mid-write?
The error is wrapped in a RuntimeError with the original chained for logs but not shown to the caller.

Metadata ownership and ingestion scope

Mapping inputs, including read-only mappings, are normalized to a dict. JSON-style metadata (nested built-in dictionaries, lists, and scalar values) is deep-copied before creating the SDK Document. Returned metadata is a separate snapshot of the submitted tags, so mutating these ordinary input or returned containers cannot change stored document tags. Custom Python values obey their own deepcopy protocol; objects that deliberately return themselves from that protocol do not carry the same isolation guarantee. Both snapshots are prepared before calling the store, so copy failures cannot report an error after a successful write. Metadata must be a mapping whose values support copying. Invalid input raises ValueError before any write.

This tool ingests one text document per call. Callers own format conversion, chunking, preprocessing, and version conventions in metadata. The configured store owns indexing, persistence, and replacement policy. The tool does not claim automatic preprocessing or version management. Store failures expose a generic public message; the chained original exception remains available to trusted diagnostic code.

Metadata

Release files for swarmauri_tool_addcontenttorag 0.1.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_tool_addcontenttorag 0.1.0.dev1
File Size Uploaded Provenance Actions
swarmauri_tool_addcontenttorag-0.1.0.dev1.tar.gz 9.0 kB Without provenance Details for swarmauri_tool_addcontenttorag-0.1.0.dev1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_tool_addcontenttorag 0.1.0.dev1
File Interpreter ABI Platform Actions
swarmauri_tool_addcontenttorag-0.1.0.dev1-py3-none-any.whl Python 3 none any Details for swarmauri_tool_addcontenttorag-0.1.0.dev1-py3-none-any.whl

Total release size: 19.6 kB

Release files / swarmauri_tool_addcontenttorag-0.1.0.dev1.tar.gz

Download URL swarmauri_tool_addcontenttorag-0.1.0.dev1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ac2a869a58201a01b9a62a760485ae0683c76b81d0b7b0483d30a0ee48417e42
BLAKE2b-256 checksum
How to use checksums
704219b3a435acabf948bcbaece291fd15ea307e853093e9cbfca736de66c020
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / swarmauri_tool_addcontenttorag-0.1.0.dev1-py3-none-any.whl

Download URL swarmauri_tool_addcontenttorag-0.1.0.dev1-py3-none-any.whl
Size 10.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39da20adbd6b573a28ad55c754416be61eb01c9d839d67553c0a05faedd234fd
BLAKE2b-256 checksum
How to use checksums
ced99a902c022a1d510e256e01a03eedcc11e768c64a132a0bb5fb89924a976e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for swarmauri_tool_addcontenttorag 0.1.0.dev1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page