Simple vector database operations with Qdrant
Project description
Vector Search
A simple Python package for vector database operations using Qdrant.
Features
- Initialize connection with Qdrant vector database
- Parse, chunk, and process text into vector embeddings
- Search for relevant text chunks based on semantic similarity
Installation
pip install vector-search
Usage
CLI Commands
You can use the vector-search console script with three commands: init, process, and search.
init
Initialize the vector database:
vector-search init \
--collection COLLECTION_NAME \
[--model MODEL_NAME] \
[--qdrant-url QDRANT_URL] \
[--qdrant-key QDRANT_API_KEY] \
[--qdrant-path QDRANT_PATH]
Options:
--collection(str, default:"documents")--model(str, default:"all-MiniLM-L6-v2")--qdrant-url(str) — Qdrant Cloud URL--qdrant-key(str) — Qdrant API key--qdrant-path(str) — Path for local Qdrant
process
Process a JSON file of documents and add to the database:
vector-search process \
--input INPUT_FILE.json \
[--collection COLLECTION_NAME] \
[--chunk-size CHUNK_SIZE] \
[--overlap OVERLAP] \
[--qdrant-url QDRANT_URL] \
[--qdrant-key QDRANT_API_KEY] \
[--qdrant-path QDRANT_PATH]
Options:
--input(str, required) — Path to JSON{ name: text }--collection(str, default:"documents")--chunk-size(int, default:200) — words per chunk--overlap(int, default:50) — overlapping words--qdrant-url,--qdrant-key,--qdrant-path— same asinit
search
Search for relevant chunks:
vector-search search \
--query QUERY_TEXT \
[--collection COLLECTION_NAME] \
[--k K] \
[--output OUTPUT_FILE.json] \
[--qdrant-url QDRANT_URL] \
[--qdrant-key QDRANT_API_KEY] \
[--qdrant-path QDRANT_PATH]
Options:
--query(str, required) — query text--collection(str, default:"documents")--k(int, default:5) — number of results--output(str) — path to write JSON output (defaults to stdout)--qdrant-url,--qdrant-key,--qdrant-path— same asinit
Python API
Import and initialize VectorDB:
from ragger_simple.db import VectorDB
db = VectorDB(
collection_name="my_documents",
model_name="all-MiniLM-L6-v2",
qdrant_url=None,
qdrant_api_key=None,
qdrant_path=None,
qdrant_timeout=500.0,
)
Constructor parameters:
collection_name(str) — Qdrant collection namemodel_name(str) — sentence-transformers modelqdrant_url(str, optional) — cloud URLqdrant_api_key(str, optional) — cloud API keyqdrant_path(str, optional) — local pathqdrant_timeout(float, default:500) — request timeout
Methods:
db.add_documents(
documents: Dict[str, str],
chunk_size: int = 200,
overlap: int = 50,
)
documents— dict mapping doc names to textchunk_size— words per chunkoverlap— overlapping words
results = db.search(
query: str,
k: int = 5,
) -> List[Dict]
query— query textk— number of results
Example:
documents = {
"Article 1": "This is the content of article 1...",
"Article 2": "This is the content of article 2..."
}
db.add_documents(documents, chunk_size=200, overlap=50)
results = db.search("your query here", k=5)
print(results)
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ragger_simple-0.1.1.tar.gz.
File metadata
- Download URL: ragger_simple-0.1.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b0d2ca61a889e58a9c45b50831d6cf0f262aa5e589d55e4f7723cfca0ddfbff
|
|
| MD5 |
0ef0af64995e85cb7d3db5b7d933f8df
|
|
| BLAKE2b-256 |
cff800becb445f3944b4f1afd7ac01efe907730f49f5c83b4abacd5fb5c64ccb
|
File details
Details for the file ragger_simple-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ragger_simple-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
907254b961071c427212658f8f946019bd57f7b7130d7512acf929a455e690ac
|
|
| MD5 |
6f574983e5de63e1b6176970f7ddf40a
|
|
| BLAKE2b-256 |
374bb0a4edfd83b60774a146df507da24269006474052b1d69d61ffa4b5d3562
|