<aside> <img src="/icons/info-alternate_gray.svg" alt="/icons/info-alternate_gray.svg" width="40px" /> The OpenAI Beta Assistant API allows the developer to create custom function calls. “Function calling lets you describe custom functions of your app or external APIs to the assistant. This allows the assistant to intelligently call those functions by outputting a JSON object containing relevant arguments.” - OpenAI

Below we show our JSON structures for each of the four functions assigned to the AI Alchemist:

</aside>

get_documentation()

{
  "name": "get_documentation",
  "description": "Call the get_documentation function whenever you are unsure of how to code something in SPIKE 3 MicroPython. Specific functions and imports you may query are [motor, motor_pair, color_sensor, distance_sensor, motion_sensor, force_sensor, sound, light_matrix, runloop]. Do not assume that any legacy code will be correct. Instead, use the get_documentation function to retrieve examples of how to use SPIKE 3 features. This includes syntax for importing libraries, using classes, and specific functions. A query will always return required imports, proper syntax, and required parameter descriptions. If you do not get a query response it means that your query does not exist in the database, ask the human using get_feedback to determine what the right query is for your specific case.",
  "parameters": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "The class that requires documentation."
      }
    },
    "required": [
      "query"
    ]
  }
}

run_code()

{
  "name": "run_code",
  "description": "Call the run_code function to run the code on the robot. In return you will be provided the output of the code from the REPL . If your code returns errors, try to diagnose them yourself, or use get_documentation or get_feedback to resolve the issue.",
  "parameters": {
    "type": "object",
    "properties": {
      "code": {
        "type": "string",
        "description": "The micropython code you want to run on the SPIKE Prime. You MUST format the code in one line. Separate each line using backslash n and no spaces. You also MUST include 4 consistent spaces for indentation."
      },
      "runtime": {
        "type": "string",
        "description": "The duration for which you would like the code to run in seconds before it is stopped."
      }
    },
    "required": [
      "code",
      "runtime"
    ]
  }
}

get_visual_feedback()

{
  "name": "get_visual_feedback",
  "description": "Call the get_visual_feedback function to inspect the visual physical conditions of the robot using a sequence of images. You will get a written description answering your query in response. For example, if you need to check if the robot is moving or if the light matrix is displaying something you should call the get_visual_feedback function. To get useful feedback it is important that your query is clear and specific.",
  "parameters": {
    "type": "object",
    "properties": {
      "query": {
        "type": "string",
        "description": "A specific question describing what you would like to know about the robot in the image sequence. Example: 'Did the spike prime robot move forward over time'"
      },
      "image_num": {
        "type": "string",
        "description": "How many images you would like to be taken of the robot. More images will be able to provide more information about the robot's movement over time."
      },
      "interval": {
        "type": "string",
        "description": "The duration of time in between when each image is taken. Use this in tandem with image_num to increase or decrease the time frame over which you are observing the robot."
      }
    },
    "required": [
      "query",
      "image_num",
      "interval"
    ]
  }
}

get_feedback()

{
  "name": "get_feedback",
  "description": "Call the get_feedback function to verify characteristics of the robot such as sensor ports, robot actions like motion or sound, or to get help on code that returns errors.",
  "parameters": {
    "type": "object",
    "properties": {
      "prompt": {
        "type": "string",
        "description": "A specific question for the human that you need to verify or improve the success of your code."
      }
    },
    "required": [
      "prompt"
    ]
  }
}