Skip to main content

SIE integration for ChromaDB

Project description

sie-chroma

SIE integration for ChromaDB.

Installation

pip install sie-chroma

Features

  • SIEEmbeddingFunction: Custom embedding function for ChromaDB collections

Quick Start

Basic Usage

import chromadb
from sie_chroma import SIEEmbeddingFunction

# Create SIE embedding function
embedding_function = SIEEmbeddingFunction(
    base_url="http://localhost:8080",
    model="BAAI/bge-m3",
)

# Create ChromaDB client and collection
client = chromadb.Client()
collection = client.create_collection(
    name="my_collection",
    embedding_function=embedding_function,
)

# Add documents (embeddings are generated automatically)
collection.add(
    documents=[
        "Machine learning enables pattern recognition.",
        "Deep learning uses neural networks.",
        "Natural language processing analyzes text.",
    ],
    ids=["doc1", "doc2", "doc3"],
)

# Query the collection
results = collection.query(
    query_texts=["What is deep learning?"],
    n_results=2,
)
print(results["documents"])

With Persistent Storage

import chromadb
from sie_chroma import SIEEmbeddingFunction

# Persistent client
client = chromadb.PersistentClient(path="./chroma_data")

embedding_function = SIEEmbeddingFunction(
    base_url="http://localhost:8080",
    model="BAAI/bge-m3",
)

# Get or create collection
collection = client.get_or_create_collection(
    name="research_papers",
    embedding_function=embedding_function,
)

# Add documents with metadata
collection.add(
    documents=["Paper about transformers...", "Study on attention mechanisms..."],
    metadatas=[{"year": 2023}, {"year": 2024}],
    ids=["paper1", "paper2"],
)

# Query with metadata filtering
results = collection.query(
    query_texts=["attention in neural networks"],
    n_results=5,
    where={"year": {"$gte": 2023}},
)

With LangChain or LlamaIndex

The SIEEmbeddingFunction works with ChromaDB's LangChain and LlamaIndex integrations:

# LangChain
from langchain_chroma import Chroma
from sie_chroma import SIEEmbeddingFunction

embedding_function = SIEEmbeddingFunction(model="BAAI/bge-m3")
vectorstore = Chroma(
    collection_name="docs",
    embedding_function=embedding_function,  # Works directly!
)

# LlamaIndex
from llama_index.vector_stores.chroma import ChromaVectorStore

# SIE can also be used via LlamaIndex's SIEEmbedding

SIE Server

Start the SIE server before using this integration:

mise run serve -d cpu -p 8080

Testing

# Unit tests (no server required)
pytest

# Integration tests (requires running server)
pytest -m integration

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

sie_chroma-0.6.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

sie_chroma-0.6.2-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file sie_chroma-0.6.2.tar.gz.

File metadata

  • Download URL: sie_chroma-0.6.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sie_chroma-0.6.2.tar.gz
Algorithm Hash digest
SHA256 d39f0fb10070712311da7098d13fc22d30ff440b308ca24ba1c098b358a3695f
MD5 d401748d4e121d781b31e6afffb5f03f
BLAKE2b-256 b7ed796cf6a10dad7de8b1c5c8d199edc960bf1b91420ebd99cbc0f7e7f9c8a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for sie_chroma-0.6.2.tar.gz:

Publisher: release-python.yml on superlinked/sie-internal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sie_chroma-0.6.2-py3-none-any.whl.

File metadata

  • Download URL: sie_chroma-0.6.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sie_chroma-0.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9e658748c53d886edb5895bef9a55df85aa45d7f887eff3d294759ba6ff2dc9
MD5 db85e2099f8251b4ab7ec03082be0f2b
BLAKE2b-256 c8c07f0d45f964761094a912ad7da18935ef91c63d7e60dd2cf1ca2223e86b54

See more details on using hashes here.

Provenance

The following attestation bundles were made for sie_chroma-0.6.2-py3-none-any.whl:

Publisher: release-python.yml on superlinked/sie-internal

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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