Instructions
Platform components
Recording Instruction
To create an Instruction, In Sentius Copilot+ Application go to "Library" tab and click "Record" button in the upper right corner. One can copy ID of the Instruction by clicking on "..." button of the corresponding Instruction, click "Copy ID".
Using Particular Instruction
To use a particular Instruction, one should pass Instruction ID in a task request. One can copy ID of the Instruction by clicking on "..." button of the corresponding Instruction, click "Copy ID".
import requests
url = f"https://api.sentius.ai/dialog_sessions/<dialog_session_id>/chat"
params = {"api_key": "<your_api_key>"}
data = {
"text": "<task>",
"instruction_id": "<Instruction_id>",
}
response = requests.post(url, json=data, params=params)
print(response.json())
If the requested task was known and agent utilized recorded instruction to execute the task, in the response one can find two boolean attributes:
response.json()["attributes"]["temporary_attributes"]["replay_recorded_actions"]
-- whether recorded actions were replayed successfully;response.json()["attributes"]["temporary_attributes"]["generated_new_actions"]
-- whether Agent had to generate new actions in general mode to perform the task.
Retrieving Instructions
Personal Instructions
To get Instructions saved by the user, one can use the following code:
curl -X GET "https://api.sentius.ai/tasks/instructions?api_key=<your_api_key>" \
-H "Content-Type: application/json"
import requests
url = "https://api.sentius.ai/tasks/instructions"
params = {"api_key": "<your_api_key>"}
response = requests.get(url, params=params)
print(response.json())
Public Instructions
To get Instructions available for all users, one can use the following code:
curl -X GET "https://api.sentius.ai/tasks/instructions/common?api_key=<your_api_key>" \
-H "Content-Type: application/json"
import requests
url = "https://api.sentius.ai/tasks/instructions/common"
params = {"api_key": "<your_api_key>"}
response = requests.get(url, params=params)
print(response.json())
All Instructions
To get all Instructions, one can use the following code:
curl -X GET "https://api.sentius.ai/tasks/instructions/all?api_key=<your_api_key>" \
-H "Content-Type: application/json"
import requests
url = "https://api.sentius.ai/tasks/instructions/all"
params = {"api_key": "<your_api_key>"}
response = requests.get(url, params=params)
print(response.json())
Deleting Instructions
To delete Instruction with ID <Instruction_id>
, one can use the following code:
curl -X DELETE "https://api.example.com/tasks/instructions/<Instruction_id>?api_key=<your_api_key>" \
-H "Content-Type: application/json"
import requests
url = f"https://api.example.com/tasks/instructions/<Instruction_id>"
params = {"api_key": "<your_api_key>"}
response = requests.delete(url, params=params)
print(response.status_code)
Editing Instructions
Attention
Danger zone: If you replace instruction contents, you can not undo the action.
If you want to modify your personal instruction, it is recommended to first get all personal instructions using
"/instructions"
endpoint, select and save locally the instruction of interest, modify it as needed and then update
saved instruction using the following code that replaces
Instruction with ID <Instruction_id>
within the new instruction dictionary <instruction>
:
import requests
url = f"https://api.example.com/tasks/instructions/<Instruction_id>"
params = {"api_key": "<your_api_key>"}
response = requests.put(url, params=params, json=<instruction>)
print(response.status_code)