Outputs are the bots way to communicate information back to the user. They are the main method for displaying the results of the bots work back to the user. In designing bots, we strive to provide user with helpful formatting and a rich expirience. To that end, little bots support a wide variety of output types that are rendered into different UIs. This document will cover how to return outputs, as well as the different types of supported bot outputs.Documentation Index
Fetch the complete documentation index at: https://docs.lilbots.io/llms.txt
Use this file to discover all available pages before exploring further.
Returning Outputs
Outputs are returned from the bot’smain function, by a simple return statement at the end of the function. The return value can be either a single output, or an array of outputs. The following example shows a bot that returns a single output:
Standard Output Properties
type (string, optional)
The type of output. See the next section for a list of supported types. If not supplied, type will be infered based on type specific keys.title (string, optional)
The title of the output. This is used in the UI to display the output. It is recomended to give your outputs meaningful titles.description (string, optional)
A description of the output. This is used in the UI to display the output. It is recomended to give your outputs meaningful descriptions.Output Types
Text Output
Type:text
Markdown Output
Type:markdown
Table Output
Type:table
columns parameter.
- If you don’t specify the
columnsparameter, all keys in the first row will be used as columns. - If you pass an array of strings, these will be the keys used as columns.
- Optionally, you can pass an array of objects, each containing
keyandtitle- to give a nicer title to the columns. This will map the keys in the rows to the titles in the columns.
File Output
Type:file
Image Output
Type:image
JSON Output
Type:json
Logs
Your bot can also print logs while it’s running. Just use the standard log function in your bots runtime. Anything printed tostdout or stderr will be streamed to the UI live while the bot is running.
Logs are useful when building and debugging bots, and they are also a great way to communicate progress to the user while the bot is running as they are streamed live.
Creating Good Outputs
When designing your bot, you should strive to create outputs that are easy to read and understand. The following are some tips for creating good outputs:Use Meaningful Titles and Descriptions
When creating outputs, you should always give them meaningful titles and descriptions. This will help the user understand what the output is about, and will make it easier for them to find the output later.Ordering Outputs
Outputs are presented in an accordion, with the first output expanded by default and all other outputs collapsed by default. Thus, the first output should be the “main” output of your bot, and the rest should be supporting outputs. For instance, if your bot generates and executes a SQL query, the first output should be the results of the query, and the second output should be the query itself (which isn’t the main output of the bot, but may sometimes be useful).Use The Right Data Type
We offer multiple output types to help create the right user experience for any data. Try to use the right output type for your data. Some examples:- If you are returning a list of items, use the table output, don’t just print them as a comma separated list.
- If you are generating an image, use the image output - don’t just return the link to the image as text.
- If you are returning a JSON object, use the JSON output - don’t just print it as a string.
- If you are returning longer text, format it with markdown instead of just returning plain text.