Class QdrantTools

java.lang.Object
com.tnsai.tools.database.QdrantTools

public class QdrantTools extends Object
Function-shape Qdrant vector-database tools — the LangChain-style replacement for the Qdrant half of the legacy VectorDBTool (#188).

Five typed @Tool methods covering the Qdrant operations that show up in agent / RAG flows:

MethodEndpointIdempotent
qdrantCollections()GET /collections✓
qdrantCount(java.lang.String)GET /collections/{c}✓
qdrantSearch(java.lang.String, java.util.List<java.lang.Double>, int, java.lang.String)POST /collections/{c}/points/search✓
qdrantCreateCollection(java.lang.String, int, java.lang.String)PUT /collections/{c}✓ (PUT semantics)
qdrantUpsert(java.lang.String, java.util.List<java.util.Map<java.lang.String, java.lang.Object>>)PUT /collections/{c}/points✓ (PUT semantics)

Weaviate support lives in a separate POJO (Phase 2 batch 5e). Splitting the two backends keeps each POJO focused, lets the LLM see only one set of tool names per agent, and removes the legacy "backend" routing parameter.

Connection

QDRANT_URL (default http://localhost:6333) and the optional QDRANT_API_KEY (Qdrant Cloud) are constructor-injected. The LLM never sees them.

Since:
0.5.7 (Phase 2 batch 5d — built-in tool migration to function shape, see #188)
  • Constructor Details

    • QdrantTools

      public QdrantTools()
      Default constructor — picks QDRANT_URL + QDRANT_API_KEY from env.
    • QdrantTools

      public QdrantTools(String baseUrl)
      Explicit URL constructor (no API key — for local / unauthenticated Qdrant).
    • QdrantTools

      public QdrantTools(String baseUrl, String apiKey)
      Explicit URL + API key constructor (Qdrant Cloud).
    • QdrantTools

      public QdrantTools(String baseUrl, String apiKey, okhttp3.OkHttpClient http, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Full constructor for tests or shared HTTP/JSON instances.
  • Method Details

    • qdrantCollections

      @Tool(name="qdrant_collections", description="List all collections in the configured Qdrant instance. Returns the collection names as a JSON array. Read-only.", keywords={"qdrant","vector","collections","list"}, idempotent=true) public List<String> qdrantCollections() throws IOException
      Throws:
      IOException
    • qdrantCount

      @Tool(name="qdrant_count", description="Get metadata for a Qdrant collection \u2014 vector count, dimension, distance metric, optimizer/indexing state. Returns a structured map; use vectors_count for the scalar point count. Read-only.", keywords={"qdrant","vector","count","size","info"}, idempotent=true) public Map<String,Object> qdrantCount(@ToolParam(description="Collection name") String collection) throws IOException
      Throws:
      IOException
    • qdrantSearch

      @Tool(name="qdrant_search", description="Find the {limit} most similar points to the given query vector in a Qdrant collection. Optional {filterJson} is a Qdrant filter object (JSON string, e.g. {\"must\": [{\"key\": \"category\", \"match\": {\"value\": \"news\"}}]}); leave blank for no filter. Returns a list of {id, score, payload} maps. Read-only.", keywords={"qdrant","vector","search","similarity","rag","knn"}, idempotent=true) public List<Map<String,Object>> qdrantSearch(@ToolParam(description="Collection name") String collection, @ToolParam(description="Query vector \u2014 array of floats matching the collection\'s dimension") List<Double> vector, @ToolParam(description="Number of results (1..1000); 0 falls back to default 10",required=false,defaultValue="0") int limit, @ToolParam(description="Qdrant filter JSON (optional); blank = no filter",required=false,defaultValue="") String filterJson) throws IOException
      Throws:
      IOException
    • qdrantCreateCollection

      @Tool(name="qdrant_create_collection", description="DESTRUCTIVE: create a Qdrant collection with the given vector dimension and distance metric. PUT semantics \u2014 calling twice with the same args is a no-op; calling with different config on an existing collection is an error from Qdrant\'s side. {distance} accepts \"cosine\" (default), \"euclid\", or \"dot\".", keywords={"qdrant","vector","create","collection"}, idempotent=true) public Map<String,Object> qdrantCreateCollection(@ToolParam(description="Collection name") String collection, @ToolParam(description="Vector dimension (e.g. 1536 for OpenAI text-embedding-3-small)") int dimension, @ToolParam(description="Distance metric \u2014 \"cosine\" (default), \"euclid\", or \"dot\"",required=false,defaultValue="cosine") String distance) throws IOException
      Throws:
      IOException
    • qdrantUpsert

      @Tool(name="qdrant_upsert", description="DESTRUCTIVE: insert or update points in a Qdrant collection. {points} is a list of {id, vector, payload?} maps; ids may be strings or integers. PUT semantics \u2014 same id with new vector overwrites. The endpoint is called with wait=true so the response confirms the write completed.", keywords={"qdrant","vector","upsert","insert","embedding"}, idempotent=true) public Map<String,Object> qdrantUpsert(@ToolParam(description="Collection name") String collection, @ToolParam(description="Points \u2014 list of {id, vector, payload?} maps") List<Map<String,Object>> points) throws IOException
      Throws:
      IOException