openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
paths:
  /health:
    get:
      tags:
        - Health API
      summary: Check API health status
      description: Endpoint to check health status of the API.
      responses:
        '200':
          description: Service is up and running
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
                example:
                  status: Success
                  message: Service is up and running.
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X GET "http://localhost:8888/health"
  /documents:
    get:
      tags:
        - Document Ingestion API
      summary: Get list of documents ingested
      description: Get the list of documents ingested in the system.
      responses:
        '200':
          description: List of documents
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  metadata:
                    type: object
                    properties:
                      documents:
                        type: array
                        items:
                          type: string
                examples:
                  documents_present:
                    summary: Documents present
                    value:
                      status: Success
                      metadata:
                        documents: ["doc1.pdf", "doc2.txt"]
                  no_documents:
                    summary: No documents ingested
                    value:
                      status: Success
                      metadata:
                        documents: []
        '500':
          description: Error message
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: Error message
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X GET "http://localhost:8888/documents"
    post:
      tags:
        - Document Ingestion API
      summary: Upload documents to create and store embeddings
      description: Ingests documents into the system and creates embeddings.
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                files:
                  type: array
                  items:
                    type: string
                    format: binary
      responses:
        '200':
          description: Documents ingested
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
                  metadata:
                    type: object
                    properties:
                      documents:
                        type: array
                        items:
                          type: string
                example:
                  status: Success
                  message: Files have been successfully ingested and embeddings created.
                  metadata:
                    documents: ["doc1.pdf", "doc2.txt"]
        '400':
          description: Invalid file format
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: Invalid file format. Please upload files in pdf, txt, or docx format.
        '500':
          description: Error message
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: Error message
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X POST "http://localhost:8888/documents" -H "Content-Type: multipart/form-data" -F "files=@./doc1.pdf"
    delete:
      tags:
        - Document Ingestion API
      summary: Delete embeddings from vectorstore
      description: Deletes embeddings from the vectorstore.
      parameters:
        - name: document
          in: query
          schema:
            type: string
          description: Name of the document to delete. Defaults to an empty string.
        - name: delete_all
          in: query
          schema:
            type: boolean
          description: Flag to delete all embeddings. Defaults to False.
      responses:
        '204':
          description: No content
        '500':
          description: Error message
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: Error message
      examples:
        curl:
          summary: Curl example
          value: |
            curl -X DELETE "http://localhost:8888/documents?delete_all=True"
            curl -X DELETE "http://localhost:8888/documents?document=doc1.pdf"
  /devices:
    get:
      tags:
        - Device API
      summary: Get available devices list
      description: Retrieve a list of devices.
      responses:
        '200':
          description: List of devices
          content:
            application/json:
              schema:
                type: object
                properties:
                  devices:
                    type: array
                    items:
                      type: string
                example:
                  devices: ["device1", "device2", "device3"]
        '500':
          description: Error message
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: Error retrieving devices list.
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X GET "http://localhost:8888/devices"
  /devices/{device}:
    get:
      tags:
        - Device API
      summary: Get device property
      description: Retrieve information about a specific device, including its properties. If the device is not found, an error is returned.
      parameters:
        - name: device
          in: path
          required: true
          description: The name of the device to retrieve information for.
          schema:
            type: string
      responses:
        '200':
          description: Device properties retrieved successfully
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                example:
                  property1: value1
                  property2: value2
        '404':
          description: Device not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: 'Device device_name not found. Available devices: [device1, device2]'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: An unexpected error occurred while retrieving the device properties.
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X GET "http://localhost:8888/devices/device1"
  /chat:
    post:
      tags:
        - Chat API
      summary: Get chat response
      description: Handles a chat request by processing the query through a series of models and returning the response.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                input:
                  type: string
                stream:
                  type: boolean
                  default: true
      responses:
        '200':
          description: Chat response
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: Success
                  metadata:
                    type: string
                    example: Response data
            text/event-stream:
              schema:
                type: string
                example: 'data: chunk\n\n'
        '500':
          description: Error message
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                example:
                  detail: Error message
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X POST "http://localhost:8888/chat" -H "Content-Type: application/json" -d '{"input": "what is load_chain?"}'
  /ollama-models:
    get:
      tags:
        - Model API
      summary: Checks status of OLLAMA models
      description: Retrieves the list of currently loaded Ollama models.
      responses:
        '200':
          description: List of loaded Ollama models
          content:
            application/json:
              schema:
                type: object
                properties:
                  model_list:
                    type: array
                    items:
                      type: string
              example:
                model_list: ["llama2", "mistral", "phi3"]
        '500':
          description: Error retrieving model list
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: Error message
          examples:
            curl:
              summary: Curl example
              value: |
                curl -X GET "http://localhost:8888/ollama-models"
  /ollama-model:
    get:
      tags:
        - Model API
      summary: Gets OLLAMA model metadata
      description: Retrieves metadata for a specified OLLAMA model.
      parameters:
        - name: model_id
          in: query
          required: false
          schema:
            type: string
          description: The identifier of the OLLAMA model.
      responses:
        '200':
          description: Metadata information about the specified OLLAMA model
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
              example:
                model_id: llama2
                name: Llama 2
                version: 1.0
                description: Meta's Llama 2 model
                parameters:
                  num_layers: 32
                  hidden_size: 4096
        '404':
          description: Model not found or error retrieving metadata
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: Model with id 'llama2' not found.
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
              example:
                detail: An unexpected error occurred while retrieving the model metadata.
      examples:
        curl:
          summary: Curl example
          value: |
            curl -X GET "http://localhost:8888/ollama-model?model_id=llama2"
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    QuestionRequest:
      properties:
        input:
          type: string
          title: Input
      type: object
      required:
        - input
      title: QuestionRequest
    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
