Manage Skills in Pymirokai

Pymirokai provides an API to manage custom skills, allowing users to upload, remove, list, and enable/disable skills dynamically on the robot. This document explains how to use these features effectively.


Uploading a Skill

To upload a new skill to the robot, use the upload_skill_file method. This function takes the file path of the skill as an argument and sends it to the robot.

Example:

async with connect(ip, api_key) as robot:
    response = await robot.upload_skill_file("path/to/skill.py")
    print(response)

Expected Response:

{"status": "success", "message": "Skill uploaded successfully"}

This response confirms that the skill file has been uploaded and is now available on the robot.


Removing a Skill

To remove an existing skill from the robot, use remove_skill_file. This function requires the name of the skill to be removed.

Example:

async with connect(ip, api_key) as robot:
    response = await robot.remove_skill_file("skill_name")
    print(response)

Expected Response:

{"status": "success", "message": "Skill removed successfully"}

The skill is now deleted from the robot and can no longer be used.


Listing Available Skills files

To get a list of all currently available skills files on the robot, use list_skill_files. This function does not require any parameters.

Example:

async with connect(ip, api_key) as robot:
    response = await robot.list_skill_files()
    print(response)

Expected Response:

{"skills": ["lyrics.py", "news.py", "disabled.rhyme"]}

This response provides a list of all uploaded skills.


Enabling or Disabling a Skill

To enable or disable a specific skill on the robot, use enable_skill_file. This function requires:

  • The name of the skill file to enable or disable.

  • A boolean value (True to enable, False to disable).

Example (Enable a Skill):

async with connect(ip, api_key) as robot:
    response = await robot.enable_skill_file("fetch_rhymes.py", True)
    print(response)

Example (Disable a Skill):

async with connect(ip, api_key) as robot:
    response = await robot.enable_skill_file("fetch_rhymes.py", False)
    print(response)

Expected Response:

{"status": "success", "message": "Skill enabled successfully"}

or

{"status": "success", "message": "Skill disabled successfully"}

This confirms whether the skill was successfully enabled or disabled.


Summary of Skill Management Methods

Function

Purpose

Parameters

Expected Response

upload_skill_file(skill_path: str)

Uploads a new skill to the robot

skill_path (path to the skill file)

{ "status": "success", "message": "Skill uploaded successfully" }

remove_skill_file(skill_name: str)

Removes a skill from the robot

skill_name (name of the skill)

{ "status": "success", "message": "Skill removed successfully" }

list_skill_files()

Retrieves a list of all available skills

None

{ "skills": ["skill1.py", "skill2.py"] }

enable_skill_file(skill_name: str, enable: bool)

Enables or disables a skill

skill_name (name of the skill file), enable (True/False)

{ "status": "success", "message": "Skill enabled/disabled successfully" }


By using these methods, users can effectively manage custom skills on their Pymirokai robot, ensuring that only the necessary skills are available and active at any given time.