360 Secure SkillHub
360 安全技能中心

Vector DB Toolkit

面向 AI/RAG 应用的向量数据库操作工具包:用 Python 脚本统一封装 Qdrant、Chroma 与纯 Python 内存后端,支持创建集合、批量写入向量与 payload、按向量检索 top-k 结果,并提供可选的文本嵌入辅助模块,附带两种后端的使用参考与示例脚本。

kaiyuelv
kaiyuelv
热度 31.84
最近更新 2026-05-11 17:47:44
分类:开发依赖:代码执行 / 读写文件 / 第三方 API应用场景:API 集成 / 数据处理 / 自动化脚本

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add vector-db-toolkit
Metadata
name
vector-db-toolkit
description
Vector database operations toolkit for AI/RAG applications. Supports Qdrant, Chroma, and in-memory vector stores. Use when working with embeddings, semantic search, similarity queries, vector collections, or RAG retrieval pipelines. Triggers on phrases like "vector database", "embedding search", "semantic similarity", "Qdrant", "Chroma", "vector store", "embedding retrieval".

Vector Database Toolkit

Operations toolkit for vector databases used in AI and RAG systems.

Supported Backends

  • Qdrant - Open-source vector DB (REST/gRPC API)
  • Chroma - Lightweight embedded vector DB
  • InMemory - Pure Python fallback for small datasets

Quick Start

Qdrant

from scripts.qdrant_client import VectorClient

client = VectorClient(backend="qdrant", url="http://localhost:6333")
client.create_collection("docs", dimension=768)
client.upsert("docs", ids=["a", "b"], vectors=[[0.1, ...], [0.2, ...]], payloads=[{"title": "A"}, {"title": "B"}])
results = client.search("docs", vector=[0.1, ...], top_k=5)

Chroma

client = VectorClient(backend="chroma", path="/tmp/chroma")
client.create_collection("docs")
client.upsert("docs", ids=["a"], vectors=[[0.1, ...]], payloads=[{"title": "A"}])
results = client.search("docs", vector=[0.1, ...], top_k=5)

Scripts

  • scripts/vector_client.py - Unified client for all backends
  • scripts/qdrant_client.py - Qdrant-specific operations
  • scripts/chroma_client.py - Chroma-specific operations
  • scripts/embedding_utils.py - Text-to-embedding helpers (optional OpenAI, sentence-transformers)

References

  • references/qdrant_api.md - Qdrant API patterns
  • references/chroma_api.md - Chroma API patterns