Skip to main content

Create an Action

Creating an action in TaskingAI is a straightforward process, whether you prefer using the user interface (UI) or a client SDK. Here's a guide to help you through both methods:

Bulk Create with Client SDK

You can also create an action with a client SDK using the bulk_create_actions method. Firstly you need to define your action schema and authentication type.

NUMBERS_API_SCHEMA = {
"openapi": "3.0.0",
"info": {
"title": "Numbers API",
"version": "1.0.0",
"description": "API for fetching interesting number facts"
},
"servers": [
{
"url": "http://numbersapi.com"
}
],
"paths": {
"/{number}": {
"get": {
"description": "Get fact about a number",
"operationId": "get_number_fact",
"summary": "Get fact about a number",
"parameters": [
{
"name": "number",
"in": "path",
"required": True,
"description": "The number to get the fact for",
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"description": "A fact about the number",
"content": {
"text/plain": {
"schema": {
"type": "string"
}
}
}
}
}
}
}
}
}

Then use the schema to create actions:

from taskingai.tool import Action
from taskingai.tool import ActionAuthentication, ActionAuthenticationType
from typing import List

actions: List[Action] = taskingai.tool.bulk_create_actions(
openapi_schema=NUMBERS_API_SCHEMA,
authentication=ActionAuthentication(
type=ActionAuthenticationType.NONE,
)
)

Here are some important schema considerations when creating an action:

  • Adherence to OpenAPI Specifications: Ensure your schema follows these standards.
  • Server URL: Include one server URL per action.
  • Method Description: This will be used as the action's description.
  • Action Name: Defined by the operationId in the schema.
  • Completeness: Ensure operationId and description are fully detailed.
  • Handling Multiple Paths/Methods: TaskingAI creates separate actions for each path/method.

Authentication

Now we support NONE, BASIC, BEARER or CUSTOM authentication types. Here are examples:

No Authentication:

ActionAuthentication(
type=ActionAuthenticationType.NONE,
)

Basic Authentication:

ActionAuthentication(
type=ActionAuthenticationType.BASIC,
secret="YOUR_BASIC_SECRET"
)

Bearer Token Authentication:

ActionAuthentication(
type=ActionAuthenticationType.BEARER,
secret="YOUR_BEARER_SECRET"
)

Custom Authentication:

ActionAuthentication(
type=ActionAuthenticationType.CUSTOM,
content={"Custom-Header": "CustomValue"}
)