Skip to content

API Reference

peter-olai edited this page May 8, 2025 · 4 revisions

API Reference

This section details the API endpoints provided by the Chat-Service. These are primarily defined in the src/routes/ directory.

Endpoints

Debug Logs

Endpoints defined in src/routes/debug.py.

  • GET /api/debug/logs
    • Description: Returns in-memory logs for progress and failures. Useful for debugging the service's current state.
    • Request Body: None.
    • Response:
      {
        "progressLog": [ /* list of progress entries */ ],
        "failureLog": [ /* list of failure entries */ ]
      }

Progress

Endpoints defined in src/routes/progress.py. These are used for tracking task completion, potentially for user-facing objectives or internal processes.

  • POST /api/progress/initializeTasks

    • Description: Initializes a list of tasks, including their subtasks and steps. This can be used to set up a new set of trackable items.
    • Request Body:
      {
        "items": [
          {
            "taskName": "string",
            "status": "pending", // or "started", "complete"
            "subtaskProgress": [
              {
                "subtaskName": "string",
                "status": "pending" // or "started", "complete"
              }
            ],
            "startedAt": "datetime string (optional)",
            "completedAt": "datetime string (optional)"
          }
        ]
      }
    • Response:
      {
        "message": "Tasks initialized",
        "data": { /* the taskHierarchy sent in the request */ }
      }
  • POST /api/progress/updateTask

    • Description: Handles updates to task progress (e.g., marking as started or complete).
    • Request Body:
      {
        "taskName": "string",
        "status": "started", // or "pending", "complete"
        "subtaskProgress": [ /* same structure as in initializeTasks */ ],
        "startedAt": "datetime string (optional)",
        "completedAt": "datetime string (optional)"
      }
    • Response:
      {
        "message": "Progress updated" / "Progress received" / "Task completed",
        "data": { /* updated or new task entry */ }
      }
    • Notes: If a task is "started" or "pending" and already exists as incomplete, it's updated. If new, it's added. If "complete", an existing active task is marked as completed.
  • GET /api/progress

    • Description: Returns the entire in-memory log of progress entries.
    • Request Body: None.
    • Response:
      [ /* list of progress data entries */ ]

Upload

Endpoint defined in src/routes/upload.py. Used for uploading documents for context, used for the RAG Service.

  • POST /upload/
    • Description: Receives a document file, processes it (e.g., for embedding), and stores it.
    • Request Parameters:
      • file: The document file to upload (e.g., .txt, .md). Sent as multipart/form-data.
      • category (optional query parameter): The category of the document. Defaults to "General Information".
        • Possible values include: "Behavioral Context", "General Information", "Conversational Assets", "Training Data", "Miscellaneous", "FishFeeding", "Laboratory", "FishFactory", "FishWelfare", "FishMaintenance", "Ocean".
    • Response (Success):
      {
        "message": "File uploaded and processed successfully",
        "category": "string" // The category used
      }
    • Response (Error):
      {
        "detail": "Error message"
      }
      (HTTP 500 for processing failures, or other relevant HTTP error codes)

Chat / Query (Placeholder)

This endpoint's definition and location are yet to be fully confirmed from the codebase. It's expected to handle interactions with the LLM.

  • POST /chat (Example Path)
    • Description: Sends text to the LLM for a response, potentially using RAG.
    • Request Body (Example):
      {
        "question": "User's query.",
        "user_information": ["unique_user_identifier"],
        "progress": [ /* list of ProgressData objects - definition TBD */ ],
        "user_actions": [ /* list of strings describing user actions */ ],
        "base_prompt": "System-level instructions for the LLM.",
        "context": "Relevant contextual information as a string."
      }
    • Response (Example):
      {
        "response_text": "LLM generated response.",
        "source_documents": [ /* If RAG is used */ ]
      }

Clone this wiki locally