AI Tasks
AI Tasks are actions that AI Agents can perform. Some tasks are simple, like getting basic information, while others use AI models or external tools to process data.
Arkalos provides built-in tasks like converting natural language to SQL, querying a data warehouse, and displaying data.
Tasks are essential building blocks — without them, an AI Agent can't do anything.
Creating a Task
Let's create two tasks:
- Basic Task: Find the user's IP address.
- AI-Powered Task: A natural language calculator.
Basic Task: What is My IP
Create a new file: app/ai/tasks/what_is_my_ip_task.py
import socket
from arkalos.ai import AITask
class WhatIsMyIpTask(AITask):
@property
def NAME(self):
return "what_is_my_ip"
@property
def DESCRIPTION(self):
return "Get the user's IP address."
def run(self, message):
hostname = socket.gethostname()
return socket.gethostbyname(hostname)
Every AI Task in Arkalos must implement the AITask
contract and three key properties/methods:
NAME
: A unique name for the task.DESCRIPTION
: A clear and descriptive explanation of what the task does. Other tasks and AI Agents can use this information to determine if the task is capable of processing a certain input.run(message)
: The main function that processes input and returns a result. We don't use user's input in this example.
AI Task: Natural Language Calculator
Create a new file: app/ai/tasks/calc_task.py
from arkalos.ai import AITask
class CalcTask(AITask):
@property
def NAME(self):
return "calc"
@property
def DESCRIPTION(self):
return "Solve mathematical expressions from natural language."
def run(self, message):
prompt = f"""
### Instructions:
You are a calculator. Solve the following expression:
### Input:
`{message}`
### Response:
Return only the final numerical result.
"""
return self.generateTextResponse(prompt)
This task uses an AI model to process user input, generate a math formula, and return a single calculated value.
The response time depends on your computer's CPU, RAM, GPU, and the AI model set in the .env
file.
Using Tasks in an Agent
Now that we have tasks, let’s add them to an AI Agent! Learn how here →