{
  "$defs": {
    "SearchHit": {
      "description": "A single retrieval result.\n\nAttributes:\n    chunk_id: The matching chunk ID.\n    document_id: The parent document ID.\n    score: Similarity/relevance score (higher is better).\n    text: The chunk text.\n    metadata: Chunk metadata/provenance.",
      "properties": {
        "chunk_id": {
          "title": "Chunk Id",
          "type": "string"
        },
        "document_id": {
          "title": "Document Id",
          "type": "string"
        },
        "score": {
          "title": "Score",
          "type": "number"
        },
        "text": {
          "title": "Text",
          "type": "string"
        },
        "metadata": {
          "additionalProperties": true,
          "title": "Metadata",
          "type": "object"
        }
      },
      "required": [
        "chunk_id",
        "document_id",
        "score",
        "text"
      ],
      "title": "SearchHit",
      "type": "object"
    },
    "Usage": {
      "description": "Token accounting for a single request, normalised across providers.",
      "properties": {
        "prompt_tokens": {
          "default": 0,
          "title": "Prompt Tokens",
          "type": "integer"
        },
        "completion_tokens": {
          "default": 0,
          "title": "Completion Tokens",
          "type": "integer"
        },
        "total_tokens": {
          "default": 0,
          "title": "Total Tokens",
          "type": "integer"
        }
      },
      "title": "Usage",
      "type": "object"
    }
  },
  "description": "A grounded answer plus the sources it was built from.\n\nAttributes:\n    query: The original question.\n    answer: The generated answer text.\n    citations: The retrieved chunks used as context, in citation order\n        ([1], [2], ...).\n    usage: Token usage for the generation call.",
  "properties": {
    "query": {
      "title": "Query",
      "type": "string"
    },
    "answer": {
      "title": "Answer",
      "type": "string"
    },
    "citations": {
      "items": {
        "$ref": "#/$defs/SearchHit"
      },
      "title": "Citations",
      "type": "array"
    },
    "usage": {
      "$ref": "#/$defs/Usage"
    }
  },
  "required": [
    "query",
    "answer"
  ],
  "title": "AnswerResult",
  "type": "object"
}
