Skip to main content

An AI-powered task scheduler with natural language support

Project description

Certainly! Here's the documentation in Markdown format:


AI Task Scheduler API Documentation

Overview

The AI Task Scheduler API is a powerful tool for scheduling and managing tasks using natural language. It leverages AI to automatically select and execute the appropriate tools based on task descriptions. This API is designed for enterprise-grade applications, offering robust features for task management, health monitoring, and API key management.

Key Features

  • Natural Language Task Scheduling: Easily schedule tasks using simple, human-readable descriptions.
  • Automated Tool Selection: The AI selects the best tool for the job based on the task description.
  • Health Monitoring: Keep track of system health and performance metrics.
  • Flexible Job Management: Manage tasks with ease, including scheduling, status checking, and cancellation.
  • Secure API Key Management: Generate and manage API keys with role-based access control.

Getting Started

Prerequisites

  • Python 3.9+
  • FastAPI
  • Supabase
  • Anthropic API Key

Installation

  1. Clone the repository:

    git clone https://github.com/your-repo/ai-task-scheduler.git
    cd ai-task-scheduler
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Set up environment variables:

    • Copy .env.example to .env and fill in your credentials.
  4. Run the application:

    uvicorn main:app --reload
    

API Endpoints

Task Management

  • Create Task

    • Endpoint: POST /tasks
    • Description: Schedule a new task using natural language.
    • Request Body:
      {
        "description": "Send an SMS to +1234567890 tomorrow at 9 AM about the meeting",
        "schedule_time": "2024-03-20T09:00:00Z",
        "tags": ["reminder", "meeting"]
      }
      
    • Response:
      {
        "status": "scheduled",
        "job_id": "task_123abc",
        "scheduled_time": "2024-03-20T09:00:00Z",
        "description": "Send an SMS to +1234567890 tomorrow at 9 AM about the meeting",
        "tags": ["reminder", "meeting"]
      }
      
  • Get Task Status

    • Endpoint: GET /tasks/{job_id}
    • Description: Retrieve the current status and details of a scheduled task.
    • Response:
      {
        "job_id": "task_123abc",
        "status": "scheduled",
        "scheduled_for": "2024-03-20T09:00:00Z",
        "metadata": {}
      }
      
  • Cancel Task

    • Endpoint: DELETE /tasks/{job_id}
    • Description: Cancel a scheduled task that hasn't started execution.
    • Response:
      {
        "status": "cancelled",
        "job_id": "task_123abc"
      }
      

System Monitoring

  • Health Check
    • Endpoint: GET /health
    • Description: Returns detailed system health metrics including scheduler status, resource usage, and component health.
    • Response:
      {
        "status": "healthy",
        "timestamp": "2024-03-20T09:00:00Z",
        "metrics": {
          "cpu_usage": 20.5,
          "memory_usage": 45.3,
          "disk_usage": 70.1,
          "scheduler": {
            "healthy": true,
            "active_jobs": 5,
            "failed_jobs": 0,
            "last_successful_execution": "2024-03-20T08:00:00Z"
          }
        },
        "version": "1.0.0"
      }
      

Debugging

  • List Registered Tools
    • Endpoint: GET /debug/tools
    • Description: List all registered tools and their metadata.
    • Response:
      {
        "tool_count": 3,
        "tools": [
          {
            "name": "SMSTool",
            "type": "SMSTool",
            "metadata": {
              "name": "SMSTool",
              "description": "Tool for sending SMS messages",
              "category": "communication",
              "parameters": [
                {
                  "name": "phone_number",
                  "type": "string",
                  "description": "The recipient's phone number",
                  "required": true
                },
                {
                  "name": "message",
                  "type": "string",
                  "description": "The message content",
                  "required": true
                }
              ],
              "return_type": "string",
              "version": "1.0.0"
            }
          }
        ]
      }
      

Registering Tools

To register a new tool, follow these steps:

  1. Create a Tool Class: Inherit from BaseTool and implement the required methods.

    from llm_scheduler.tools.base import BaseTool, ToolMetadata, ToolParameter
    
    class MyCustomTool(BaseTool):
        def _get_metadata(self) -> ToolMetadata:
            return ToolMetadata(
                name="MyCustomTool",
                description="A custom tool for demonstration purposes",
                category="utility",
                parameters=[
                    ToolParameter(name="param1", type="string", description="A parameter", required=True)
                ],
                return_type="string"
            )
    
        async def execute(self, **kwargs) -> str:
            # Implement the tool's functionality here
            return "Execution result"
    
  2. Register the Tool: Add the tool to the ToolRegistry in main.py.

    from my_tools import MyCustomTool
    
    # Register tools
    tools = [
        SMSTool(),
        CalendarTool(),
        WeatherAlertTool(),
        MyCustomTool()  # Add your custom tool here
    ]
    
    for tool in tools:
        registry.register_tool(tool)
    

Additional Utilities

Feel free to add more endpoints or utilities as needed. For example, you could add an endpoint to list all scheduled tasks or to retrieve logs for debugging purposes.


This documentation should provide a comprehensive overview of your API's capabilities and how to use it effectively. If you have any specific features or utilities you'd like to add, let me know!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_scheduler-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llm_scheduler-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file llm_scheduler-0.1.0.tar.gz.

File metadata

  • Download URL: llm_scheduler-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for llm_scheduler-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f09eea4738588dcebfb15d5f7ad1506c14314873575c9106eb9ed0a935226858
MD5 0d41c67ce932662b0a94979068842d3e
BLAKE2b-256 5bb0bfd8767c273ee425fdc9062841b14d41d8413bda6cd23a0a243e0026e104

See more details on using hashes here.

File details

Details for the file llm_scheduler-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llm_scheduler-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for llm_scheduler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6978e4b1e6d3c4de333b96bb8b51aa358b85d8ae229d2bf0a64c4a97d4295950
MD5 23817b73eb2198f21f4c7c303edd9f4c
BLAKE2b-256 2922c94114734db168d19a2e7cb9243465d5e5c5cba47133a2895665f2166ed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page