v2

latestOpenAPI 3.1.02026-08-0382170235.8 KB
query
query

Unified query with automatic routing

Execute a unified query against a POT with automatic strategy selection.

How it works:

  1. Classifies query (factual → CAG, semantic → RAG, relational → GraphRAG)
  2. Executes optimal strategy first
  3. Automatically falls back to RAG if CAG insufficient
  4. Returns results with routing metadata

Strategies:

  • auto (default): Automatic selection based on query classification
  • cag: Force CAG-only (fast, keyword-based)
  • rag: Force RAG-only (semantic search with embeddings)
  • graph_rag: Force GraphRAG (graph traversal for relational queries)

Fallback Logic: When enable_fallback=true and strategy=auto:

  • If CAG returns suggestion != "sufficient", executes RAG
  • If classification confidence is low, prefers RAG
  • Metadata shows which strategy was actually used

Latency:

  • CAG-only: ~50ms
  • RAG: ~500ms
  • CAG with fallback: ~550ms
  • GraphRAG: ~200-800ms (depends on graph density)
post/pots/{pot_id}/query

Path parameters

pot_idstring required

POT identifier (UUID or slug)

POT identifier (UUID or slug)

Request body

querystring required

Query text for retrieval

top_kinteger

Maximum results to return

strategy'auto' | 'cag' | 'rag' | 'graph_rag'

Force strategy or auto-select based on query classification

enable_fallbackboolean

Allow automatic fallback from CAG to RAG when results insufficient

include_edgesboolean

Include edge context (contradictions, relationships) in response

include_stancesboolean

Include stance summaries for contradiction edges (requires include_edges=True)

Example request

{
  "enable_fallback": true,
  "filters": {
    "domain": "architecture",
    "levels": [
      "CONSTITUTION",
      "VERIFIED"
    ],
    "tags": [
      "core"
    ]
  },
  "query": "What is POT Index?",
  "strategy": "auto",
  "top_k": 5
}

Response

Successful query

is_knowledge_gapboolean required

Convenience flag: true when retrieval likely hit a knowledge gap (gap_signal.confidence < threshold). The integrator decides whether to act on it.

Example response

{
  "data": {
    "results": [
      {
        "content": "POT Index es el sistema de scoring...",
        "domain": "architecture",
        "fact_id": "01234567-89ab-cdef-0123-456789abcdef",
        "level": "VERIFIED",
        "match_details": {
          "keyword_score": 0.95,
          "matched_keywords": [
            "POT",
            "Index"
          ]
        },
        "pot_score": 0.85,
        "score": 0.92,
        "source": "cag",
        "tags": [
          "core",
          "scoring"
        ]
      }
    ],
    "total_results": 1
  },
  "gap_signal": {
    "average_score": 0.85,
    "confidence": 0.85,
    "high_certainty_facts": 1,
    "is_knowledge_gap": false,
    "reasons": [
      "1_high_certainty_facts"
    ],
    "threshold": 0.45,
    "total_facts": 1,
    "version": "v2"
  },
  "is_knowledge_gap": false,
  "metadata": {
    "cag_attempted": true,
    "cag_duration_ms": 42,
    "cag_results_count": 1,
    "cag_suggestion": "sufficient",
    "classification": {
      "category": "factual",
      "confidence": 0.9,
      "reasoning": [
        "What-question pattern detected"
      ],
      "suggested_strategy": "cag"
    },
    "fallback_triggered": false,
    "rag_duration_ms": 0,
    "strategy_used": "cag",
    "total_duration_ms": 45
  }
}