Function Editor

Sometimes it's necessary to translate (i.e. map) data in ways that defy a good visual programming experience. Examples include:

  • Building a specialized prompt payload from the current context
  • Performing a custom mapping from an LLM completion to a series actions
  • Building an API request payload from the current context
  • Translating an API response into a series of actions

Functions allow you to incorporate these types of translations into your assistant's flow and are maintained in the Function Editor. Functions are easily bootstrapped with the correct signatures from the Flow Editor and you can jump to a function's definition from anywhere that it's referenced in the flow:

Using the f(x) goto to open a function referenced by a Call Function Behavior with the Flow and Function editors open simultaneously

Using the f(x) goto to open a function referenced by a Call Function Behavior with the Flow and Function editors open simultaneously

Functions in AI Studio are technically 'pure' functions - meaning they are pure transformations of their inputs to an output without any reliance on external state (e.g. network calls). However, because Functions operate on the context and the context is always up-to-date with any state changes, search results, or API results accumulated earlier in the flow, Functions can easily consider external data in their mappings.

Function Runtimes

📘

You can find a list of example functions here.