> ## Documentation Index
> Fetch the complete documentation index at: https://docs.capedigital.co.ke/llms.txt
> Use this file to discover all available pages before exploring further.

# Ask Knowledge Base



## OpenAPI

````yaml /openapi/document.yaml post /knowledge-base/ask
openapi: 3.1.0
info:
  title: Document Service
  description: Centralised document management system.
  version: 1.0.0
servers:
  - url: https://api.diginacape.co.ke/documents
    description: Production
security: []
paths:
  /knowledge-base/ask:
    post:
      tags:
        - Knowledge Base
      summary: Ask Knowledge Base
      operationId: ask_knowledge_base_knowledge_base_ask_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AskKnowledgeBaseRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AskKnowledgeBaseResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AskKnowledgeBaseRequest:
      properties:
        question:
          type: string
          minLength: 3
          title: Question
        limit:
          type: integer
          maximum: 20
          minimum: 1
          title: Limit
          default: 5
      type: object
      required:
        - question
      title: AskKnowledgeBaseRequest
    AskKnowledgeBaseResponse:
      properties:
        question:
          type: string
          title: Question
        answer:
          type: string
          title: Answer
        sources:
          items:
            $ref: '#/components/schemas/KnowledgeBaseSource'
          type: array
          title: Sources
      type: object
      required:
        - question
        - answer
        - sources
      title: AskKnowledgeBaseResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    KnowledgeBaseSource:
      properties:
        document_id:
          type: string
          title: Document Id
        filename:
          type: string
          title: Filename
        score:
          type: number
          title: Score
      type: object
      required:
        - document_id
        - filename
        - score
      title: KnowledgeBaseSource
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````