Periodic Scheduled Tasks
This feature automates the orchestration and execution of repetitive tasks, significantly boosting work efficiency and minimizing manual intervention.
- [Gai] Application: The central human-machine interface, responsible for receiving, executing, and displaying the results of various operational commands.
- [PyGai] Connector: Serves as the machine-to-machine communication bridge, handling task scheduling, instruction distribution, and centralized result processing.
Periodic scheduled tasks are configured and orchestrated via the [PyGai] Connector, with the [Gai] Application executing them and relaying results. This mechanism automates repetitive workflows, freeing users from routine periodic operations by entrusting them to the system.
Scheduled tasks are fundamentally the automated orchestration of AI operations, encompassing these core elements:
- Instruction Source: Defines where the task originates or from which system specific instructions are retrieved.
- Task Definition: Specifies the precise execution instructions, including operation content and parameters.
- Result Handling: Outlines the destination and notification mechanisms for task execution results.
1. Instruction Source
Instruction sources for the application are categorized into two types: local prompt library and Connector API.
- Local Prompt Library: Utilizes user-defined prompts stored directly within the application.
- Connector API: Fetches prompts dynamically by making requests to the
PyGaiConnector API.
2. Task Definition
Defines the task's execution schedule and specific operations.
- Execution Schedule: Supports flexible scheduling via Cron expressions, allowing for periodic execution (e.g., minute, hourly, daily, monthly, yearly).
- Execution Command: The specific instruction set for the application, typically a high-quality prompt or an operational script.
3. Result Handling
Mechanisms for storing and notifying about task execution results.
- Local Logging: All task execution results (success/failure status, detailed logs, and generated content) are comprehensively stored locally within the application.
- Connector Callback: In addition to local logging, task execution results are simultaneously transmitted back to the
PyGaiConnector via API for centralized management or further business logic processing. - Email Notification: Supports configurable email notifications to specified recipients upon task completion, enabling remote monitoring and asynchronous alerts.
T1-Using the Periodic Task Manager
From the application's homepage, click the 'Scheduled Tasks' button, then navigate to the category panel and select 'Create Task (new cron job)'.

- Task Status: Defines the task's lifecycle: Run, Stop, Pause, and Delete. A task must be in 'Run' state and saved to be eligible for scheduling and execution.
- Note: Upon application restart, 'Paused' tasks will automatically transition to 'Run' status, while 'Deleted' tasks will be permanently removed.
- Task Name: Assign a unique identifier to the task.
- Execution Frequency (Cron Expression): Configure the task's execution frequency using standard Cron expressions, with support for manual editing.
- Preset Frequency Options: Offers quick selection for common execution frequencies (e.g., hourly, daily, weekly, monthly, yearly).
- Instruction Source Type: Select the method for obtaining instructions. 'Prompt' refers to sourcing from the application's local prompt library; 'HTTP' refers to sourcing from the
PyGaiConnector API. - Instruction Source Identifier: Based on the selected source type, enter the corresponding prefix (e.g.,
Pfor Local Prompt,_Hfor HTTP) to identify the specific instruction or API endpoint. - Result Handling Type: Define the destination for task execution results. 'History' signifies local log recording; 'HTTP' indicates a callback to the
PyGaiConnector for further processing. - Result Callback Target: If 'HTTP' is selected for result handling, specify the
PyGaiConnector's API endpoint (e.g., by entering an_Hprefix). 'History' type does not require this setting. - Single Execution: If checked, the task will automatically deactivate after a single execution.
- Task Completion Email Notification: If enabled, an email notification will be sent upon task completion.
- Save Task: Saves the current configuration and adds it to the scheduling queue, enabling the task to commence execution at the specified time.
- Execute Immediately (Debug): Manually triggers a single task execution without saving the current configuration, primarily used for debugging.
Note 1: Saved tasks can be loaded and edited by navigating to the 'Scheduled Task Category Panel' -> 'Task List (crontab)'.
Note 2: 'Empty Input Silenced' option: Determines whether to silently skip execution when the task input is empty, preventing unnecessary error reports.
Best Practice Use Cases:
- Use Case A: Application generates content using local prompts, then callbacks the output to the
PyGaiConnector for downstream processing. - Use Case B: Dynamically retrieves prompts from the
PyGaiConnector API, generates content locally within the application, and callbacks the results to thePyGaiConnector.
T2-Scheduled Task Category Panel
From the application's homepage, click the 'Scheduled Tasks' button to access the functional category panel.

A. Main Function Area Entry: Provides quick access to various task management functionalities. B. Usage Statistics: Displays an overview of task execution metrics. C. Auxiliary Function Menu: Offers additional tools and configuration options.
- Create Literal Constants: Define immutable text or numeric data.
- Create HTTP Variables: Configure dynamic parameters for HTTP requests.
- Create Periodic Task: Configure tasks for periodic automated execution.
- Literal Constants List: Manage all defined literal constants.
- HTTP Variables List: Manage all defined HTTP variables.
- Task List: Manage all created periodic tasks.
- Task Execution Logs: View detailed log records for all executed tasks.
Note: A new 'HTTP Scheduled Task (new http job)' feature has been added, specifically designed for periodically initiating HTTP requests.
Retrieving Instructions from Connector
This feature enables the application to dynamically retrieve execution instructions or data from the PyGai Connector's API interface via HTTP requests. A complete HTTP request typically comprises a URL, request method (e.g., GET/POST), request headers, and request body (e.g., Form Data).
The following steps guide you through configuring the necessary constants and variables for HTTP requests, akin to using an HTTP debugging tool.
- Define literal constants, such as API endpoints or authorization credentials.
- Define HTTP variables, such as dynamic request URLs or headers.
T3-Defining Literal Constants
From the category panel, select 'Create Literal Constant' to open the editor.

- Constant Type: Selectable scope: 'Global' or 'Local'.
- Constant Name: Assign a unique identifier to the constant.
- Constant Value: Enter the specific data value for the constant.
- Save: Submit and save the constant definition.
T4-Defining HTTP Variables
HTTP variables use {{}} as delimiters. Naming conventions: must consist of letters, numbers, and underscores, and begin with a letter or an underscore.
From the category panel, select 'Create HTTP Variable' to open the editor.

- Variable Name: Assign a unique identifier to the HTTP request variable.
- Request Method: Select the HTTP request method (e.g., GET, POST).
- Request URL: Enter the target API's URL.
- Request Data Type: Select the data type: 'Header', 'Query Parameter (Param)', or 'Body Data'.
- Parameter Name: Enter the key for the request data.
- Parameter Value: Enter the value for the request data, supporting references to literal constants using
{{}}. - Delete Parameter: Remove the current request data entry.
- Add Parameter: Add a new request data entry (Type, Name, Value, Delete).
- Save: Submit and save the HTTP variable definition.
T5-Task Execution Logs
From the category panel, select 'Task Execution Logs' to view the list.

- Log Overview: Displays task status (S: Success, F: Failure), execution timestamp, and task name.
-
Execution Stage Status: Detailed breakdown of task execution status at various stages:
In (Input): Instruction retrieval stage (S: Success, F: Failure)Proc (Process): Content generation stage (S: Success, F: Failure)Out (Output): Result output stage (S: Success, F: Failure)- Error Message: If task execution fails, specific error details are displayed here; otherwise, it remains empty.
-
Action Options:
-
Delete: Removes this log entry.
- Copy: Copies the detailed log content in JSON format.
T6-HTTP Scheduled Task Manager
HTTP Scheduled Tasks differ from traditional periodic (Cron) tasks primarily in their function: HTTP tasks only periodically initiate HTTP requests, without further processing of the response data or content generation.
Note: Task success is typically indicated by an HTTP 200 status code. This feature is ideal for periodically triggering backend services.

- Task Status: Consistent with the task status definition in T1.
- Task Name: Consistent with the task naming rules in T1.
- Execution Frequency (Cron Expression): Consistent with the execution frequency configuration in T1.
- Preset Frequency Options: Consistent with the preset frequency options in T1.
- Instruction Source Type: Defaults to 'HTTP', indicating the task directly initiates an HTTP request.
- Instruction Source Identifier: Enter the target HTTP request's URL or an HTTP variable identifier.
- Result Handling Type: Defaults to 'History', meaning task execution results are only recorded in the application's local log.
- Result Callback Target: Leave empty, as results are only recorded in the local log.
- Single Execution: Consistent with the single execution setting in T1.
- Task Completion Email Notification: Consistent with the email notification setting in T1.
- Task Failure Email Notification: If checked, an email notification will be sent only upon task execution failure.
- Save Task: Consistent with the save functionality in T1.
- Execute Immediately (Debug): Consistent with the immediate execution functionality in T1, used for testing unsaved HTTP requests.
Important Note: Enabling 'Task Failure Email Notification' requires simultaneously activating 'Task Completion Email Notification' and the 'Email Notification' setting found under 'Settings'.