SupInput
The SupInput object represents a collection of input data in various formats (text, images, audio, video, and other files) used as input to patch functions. It is available as sup.input in your patch functions.
The instance on sup.input looks for input data from different pieces of the message that invoked the patch, and the message it replied to, prioritizing input from the invocation message over the reply.
The effect is flexibility in how a patch gets it input. For example sup.input.text will either contain the text used to invoke the patch with (/user/patch <input>), or if none is provided but the patch as a reply to another message, then sup.input.text will contain the text from the message being replied to. If both are available, then sup.input.text will be set to the text from the invocation, and sup.input.texts will be an array containing both. This is sufficient for most patches, though for more fine-grained control, the invocation’s text can be retrieved via sup.message.body, and the reply’s via sup.reply.body.
sup.input.image(s), sup.input.audio(s), sup.input.video(s), and sup.input.files(s) work similarly, with the priority:
- Attachments on the invocation message
- Media returned by the message being replied to
- Files attached to the reply message
SupInput: { "text": "sup, world!", "texts": ["sup, world!"], "image": { "url": "https://user-uploads.cdn.overworld.xyz/cumnehs74u2bfcas8gxsdzqx.webp", "width": 256, "height": 256 }, "images": [{ "url": "https://user-uploads.cdn.overworld.xyz/cumnehs74u2bfcas8gxsdzqx.webp", "width": 256, "height": 256 }], "audio": { "url": "https://user-uploads.cdn.overworld.xyz/k49lv3f90remnuqln1i8xt9p.mp3", "duration": 1.5 }, "audios": [{ "url": "https://user-uploads.cdn.overworld.xyz/k49lv3f90remnuqln1i8xt9p.mp3", "duration": 1.5 }], "video": undefined, "videos": [], "files": [{ "url": "https://user-uploads.cdn.overworld.xyz/document.pdf", "name": "document.pdf", "size": 1024000 }]}Properties
text
type: string | undefined
Gets the first text from the texts array, or undefined if there are no texts.
Priority:
- Text from the message that invoked the patch
- Text from the message that this message is replying to
texts
type: string[]
Array of text inputs. This will contain multiple entries if the patch message has text, and is replying to another message with its own text.
Priority:
- Text from the message that invoked the patch
- Text from the message that this message is replying to
image
type: SupImage | undefined
Gets the first image from the images array, or undefined if there are no images.
images
type: SupImage[]
Array of images included in the input.
audio
type: SupAudio | undefined
Gets the first audio file from the audios array, or undefined if there are no audio files.
audios
type: SupAudio[]
Array of audio files (such as voice messages) included in the input.
video
type: SupVideo | undefined
Gets the first video from the videos array, or undefined if there are no videos.
videos
type: SupVideo[]
Array of video files included in the input.
files
type: SupFile[]
Array of other files that aren’t audio, video, or images.
combined
type: (string | SupAudio | SupImage | SupVideo | SupFile)[]
Returns an array containing all text, audio, video, and images combined. This is particularly useful when working with sup.ai.prompt() which can process multiple types of input together.
The array preserves the order: texts first, followed by audios, images, and videos.