Skill: cinience/aliyun-milvus-search (version 1.0.0)

--- name: aliyun-milvus-search description: Use when working with AliCloud Milvus (serverless) with PyMilvus to create collections, insert vectors, and run filtered similarity search. Optimized for Claude Code/Codex vector retrieval flows. version: 1.0.0 --- Category: provider # AliCloud Milvus (Serverless) via PyMilvus This skill uses standard PyMilvus APIs to connect to AliCloud Milvus and run vector search. ## Prerequisites - Install SDK (recommended in a venv to avoid PEP 668 limits): ```bash python3 -m venv .venv . .venv/bin/activate python -m pip install --upgrade pymilvus ``` - Provide connection via environment variables: - `MILVUS_URI` (e.g. `http://<host>:19530`) - `MILVUS_TOKEN` (`<username>:<password>`) - `MILVUS_DB` (default: `default`) ## Quickstart (Python) ```python import os from pymilvus import MilvusClient client = MilvusClient( uri=os.getenv("MILVUS_URI"), [REDACTED_SECRET]"MILVUS_TOKEN"), db_name=os.getenv("MILVUS_DB", "default"), ) # 1) Create a collection client.create_collection( collection_name="docs", dimension=768, ) # 2) Insert data items = [ {"id": 1, "vector": [0.01] * 768, "source": "kb", "chunk": 0}, {"id": 2, "vector": [0.02] * 768, "source": "kb", "chunk": 1}, ] client.insert(collection_name="docs", data=items) # 3) Search query_vectors = [[0.01] * 768] res = client.search( collection_name="docs", data=query_vectors, limit=5, filter='source == "kb" and chunk >= 0', output_fields=["source", "chunk"], ) print(res) ``` ## Script quickstart ```bash python skills/ai/search/aliyun-milvus-search/scripts/quickstart.py ``` Environment variables: - `MILVUS_URI` - `MILVUS_TOKEN` - `MILVUS_DB` (optional) - `MILVUS_COLLECTION` (optional) - `MILVUS_DIMENSION` (optional) Optional args: `--collection`, `--dimension`, `--limit`, `--filter`. ## Notes for Claude Code/Codex - Insert is async; wait a few seconds before searching newly inserted data. - Keep vector `dimension` aligned with your embedding model. - Use filters to enforce tenant scoping or dataset partitions. ## Error handling - Auth errors: check `MILVUS_TOKEN` and instance permissions. - Dimension mismatch: ensure all vectors match collection dimension. - Network errors: verify VPC/public access settings on the instance. ## Validation ```bash mkdir -p output/aliyun-milvus-search for f in skills/ai/search/aliyun-milvus-search/scripts/*.py; do python3 -m py_compile "$f" done echo "py_compile_ok" > output/aliyun-milvus-search/validate.txt ``` Pass criteria: command exits 0 and `output/aliyun-milvus-search/validate.txt` is generated. ## Output And Evidence - Save artifacts, command outputs, and API response summaries under `output/aliyun-milvus-search/`. - Include key parameters (region/resource id/time range) in evidence files for reproducibility. ## Workflow 1) Confirm user intent, region, identifiers, and whether the operation is read-only or mutating. 2) Run one minimal read-only query first to verify connectivity and permissions. 3) Execute the target operation with explicit parameters and bounded scope. 4) Verify results and save output/evidence files. ## References - PyMilvus `MilvusClient` examples for AliCloud Milvus - Source list: `references/sources.md`

path: agents/openai.yaml
content: interface:
  display_name: "Alibaba Cloud AI Search Milvus"
  short_description: "Milvus collection and vector query"
  default_prompt: "Use $alicloud-ai-search-milvus to complete this ai/search task on Alibaba Cloud."


path: references/sources.md
content: 官方文档来源（用于后续更新）
============================

- （暂无外部文档链接）


path: scripts/quickstart.py
content: import argparse
import os
import sys

from pymilvus import MilvusClient


def get_env(name: str, default: str | None = None) -> str:
    value = os.getenv(name, default)
    if not value:
        print(f"Missing env var: {name}", file=sys.stderr)
        sys.exit(1)
    return value


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(description="AliCloud Milvus quickstart")
    parser.add_argument("--collection", default=os.getenv("MILVUS_COLLECTION", "docs"))
    parser.add_argument("--dimension", type=int, default=int(os.getenv("MILVUS_DIMENSION", "8")))
    parser.add_argument("--limit", type=int, default=5)
    parser.add_argument("--filter", default='source == "kb" and chunk >= 0')
    return parser.parse_args()


def main() -> None:
    args = parse_args()
    client = MilvusClient(
        uri=get_env("MILVUS_URI"),
        [REDACTED_SECRET]"MILVUS_TOKEN"),
        db_name=get_env("MILVUS_DB", "default"),
    )

    print("Creating collection...")
    client.create_collection(collection_name=args.collection, dimension=args.dimension)

    print("Inserting data...")
    items = [
        {"id": 1, "vector": [0.01] * args.dimension, "source": "kb", "chunk": 0},
        {"id": 2, "vector": [0.02] * args.dimension, "source": "kb", "chunk": 1},
    ]
    client.insert(collection_name=args.collection, data=items)

    print("Searching...")
    query_vectors = [[0.01] * args.dimension]
    res = client.search(
        collection_name=args.collection,
        data=query_vectors,
        limit=args.limit,
        filter=args.filter,
        output_fields=["source", "chunk"],
    )
    print(res)


if __name__ == "__main__":
    main()


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)