v2

latestOpenAPI 3.1.02026-08-0382170235.8 KB
cag
cag

CAG keyword/entity search

Execute CAG (Cached Augmented Generation) search over cached facts.

How it works:

  1. Tokenizes query into keywords and entities
  2. Looks up matching facts in cache (Constitution + High-Certainty)
  3. Scores by keyword overlap, entity overlap, and POT Score
  4. Returns results with confidence metadata

Scoring formula: score = (keyword_score * 0.5) + (entity_score * 0.3) + (pot_score * 0.2)

Confidence suggestions:

  • sufficient: Good matches found, likely complete answer
  • consider_rag: Partial matches, client may want to also query RAG
  • no_match: No meaningful matches, definitely query RAG

Note: Client decides whether to follow up with RAG based on suggestion.

post/pots/{pot_id}/cag/search

Path parameters

pot_idstring required

POT identifier (UUID or slug)

POT identifier (UUID or slug)

Request body

querystring required

Query text for keyword/entity matching

top_kinteger

Maximum results to return

include_constitutionboolean

Include Constitution facts in search

min_pot_scorenumber

Minimum POT Index threshold

Example request

{
  "include_constitution": true,
  "min_pot_score": 0,
  "query": "What is POT Index?",
  "top_k": 10
}

Response

Successful search

Example response

{
  "confidence": {
    "match_quality": 0.92,
    "results_count": 1,
    "suggestion": "sufficient",
    "top_score": 0.92
  },
  "data": {
    "results": [
      {
        "content": "POT Index assigns certainty scores 0-1",
        "domain": "core",
        "fact_id": "const_001",
        "level": "CONSTITUTION",
        "match_details": {
          "entity_score": 1,
          "keyword_score": 0.8,
          "matched_entities": [
            "POT Index"
          ],
          "matched_keywords": [
            "pot",
            "index"
          ]
        },
        "pot_score": 1,
        "score": 0.92,
        "tags": [
          "pot-index"
        ]
      }
    ],
    "total_results": 1
  },
  "metadata": {
    "cache_status": "hit",
    "latency_ms": 12,
    "pot_id": "scipot-core",
    "query": "What is POT Index?",
    "retrieval_strategy": "CAG"
  }
}