Skip to main content

Generic vector infrastructure components

Project description

Civec

Package-ready vector infrastructure for building vector database pipelines.

The base install contains typed records, namespace policies, and protocol seams. Optional extras add storage, query, transport, HTTP, and geometry integrations without forcing those dependencies into the minimal install.

Install

uv add civec
uv add "civec[query,lancedb,rules-geometry]"

Develop

uv sync --all-extras
uv run python -m pytest
uv run pyright

Core Concepts

  • VectorRecord: generic stored vector with id, namespace_id, vector, source_timestamp, ingested_at, and metadata.
  • NamespaceRecord: generic tenant-like namespace model with shard, index, retention, and metadata policies.
  • RecordTransformer: converts raw app messages into normalized VectorRecord objects.
  • QueryVectorProvider: converts text, image, or custom query payloads into query vectors.
  • ShardRouter: maps records and queries to storage shards by namespace.
  • GenericQueryService: searches LanceDB-like shards and returns JSON-safe result rows.
  • civec.extensions.reranking: exact reranking helpers for retriever flows.
  • civec.extensions.detection_queues: generic top-K review queue scoring and rule helpers.
  • civec.extensions.gateway: generic namespace routing and message mutation service.
  • civec.clients: typed HTTP client helpers for service adapters.
  • IngestionEngine: transforms, partitions, batches, and writes records through injected app adapters.
  • rules: reusable field access, condition models, and route evaluation used by gateways and review queues.

Ingestion

from dataclasses import dataclass
from datetime import datetime, timezone

from civec.ingestion import IngestionEngine, IngestionEngineConfig
from civec.models import VectorRecord


@dataclass(frozen=True)
class Event:
    event_id: str
    namespace_id: str
    vector: list[float]


class EventTransformer:
    def parse_records(self, message: Event, now: datetime) -> list[VectorRecord]:
        return [
            VectorRecord(
                id=message.event_id,
                namespace_id=message.namespace_id,
                vector=message.vector,
                source_timestamp=None,
                ingested_at=now,
                metadata={},
            )
        ]

Provide a partitioner and writer for your app. The library handles transformation and batching; your adapter owns transport acknowledgements, environment variables, and concrete storage wiring.

Query And Reranking

GenericQueryService expects a shard registry and LanceDB-like connection. Configure column names for your schema:

from civec.query import GenericQueryService, QueryColumnConfig
from civec.extensions.reranking import attach_cosine_similarity

service = GenericQueryService(
    db_conn,
    registry,
    logger,
    columns=QueryColumnConfig(
        namespace_column="namespace_id",
        timestamp_column="ingested_at",
        vector_column="vector",
    ),
)

App layers can keep legacy names like tenant_id or ts_ingested by setting QueryColumnConfig instead of changing external APIs.

Rules

The civec.rules package evaluates generic JSON documents using typed field definitions, condition configs, and route definitions. It is suitable for routing gateways and rule-filtered review queues. Install rules-geometry when using WKT or GeoJSON intersection operators.

Dependency Extras

  • clients: HTTP client helper dependencies.
  • lancedb: LanceDB and PyArrow helpers.
  • query: NumPy/Pandas query helpers.
  • rabbitmq: RabbitMQ transport adapter dependencies.
  • fastapi: FastAPI adapter dependencies.
  • tenants-sql: SQL tenant/shard registry dependencies.
  • rules-geometry: Shapely-backed geometry rule operators.
  • detections: Detection queue storage dependencies.
  • gateway: Gateway support dependencies.
  • gateway-ui: Streamlit UI dependencies.
  • dev: test and type-check tooling.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

civec-0.1.0.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

civec-0.1.0-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file civec-0.1.0.tar.gz.

File metadata

  • Download URL: civec-0.1.0.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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}

File hashes

Hashes for civec-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da4c0caebe06bd93c3c7fef94e45be0d1d58926ab4e95d560cfdb3cba460c9ef
MD5 f903413dab1462616119235817ec3367
BLAKE2b-256 86ebe619f9be8c11daa1d5b47cde8cd1af251bcf7fc26490fdca4f9c36ba8137

See more details on using hashes here.

File details

Details for the file civec-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: civec-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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}

File hashes

Hashes for civec-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdfb6e181bbb91f572cf97064d038c0113651d2e3f90e1a46428592723c56d8f
MD5 472fb3d9ec2c0bf5bc9569d1452cf0fb
BLAKE2b-256 78d00589300e75778a7cce3f3c01b8b159f4ad1e266c07d9449ef95c34c1ccb4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page