π§° Functions
π What Are Functions?β
Functions are like plugins for Sage WebUI. They help you extend its capabilitiesβwhether itβs adding support for new AI model providers like Anthropic or Vertex AI, tweaking how messages are processed, or introducing custom buttons to the interface for better usability.
Unlike external tools that may require complex integrations, Functions are built-in and run within the Sage WebUI environment. That means they are fast, modular, and donβt rely on external dependencies.
Think of Functions as modular building blocks that let you enhance how the WebUI works, tailored exactly to what you need. Theyβre lightweight, highly customizable, and written in pure Python, so you have the freedom to create anythingβfrom new AI-powered workflows to integrations with anything you use, like Google Search or Home Assistant.
ποΈ Types of Functionsβ
There are three types of Functions in Sage WebUI, each with a specific purpose. Letβs break them down and explain exactly what they do:
1. Pipe Function β Create Custom "Agents/Models" β
A Pipe Function is how you create custom agents/models or integrations, which then appear in the interface as if they were standalone models.
What does it do?
- Pipes let you define complex workflows. For instance, you could create a Pipe that sends data to Model A and Model B, processes their outputs, and combines the results into one finalized answer.
- Pipes donβt even have to use AI! They can be setups for search APIs, weather data, or even systems like Home Assistant. Basically, anything youβd like to interact with can become part of Sage WebUI.
Use case example:
Imagine you want to query Google Search directly from Sage WebUI. You can create a Pipe Function that:
- Takes your message as the search query.
- Sends the query to Google Searchβs API.
- Processes the response and returns it to you inside the WebUI like a normal "model" response.
When enabled, Pipe Functions show up as their own selectable model. Use Pipes whenever you need custom functionality that works like a model in the interface.
For a detailed guide, see Pipe Functions.
2. Filter Function β Modify Inputs and Outputsβ
A Filter Function is like a tool for tweaking data before it gets sent to the AI or after it comes back.
What does it do?
Filters act as "hooks" in the workflow and have two main parts:
- Inlet: Adjust the input that is sent to the model. For example, adding additional instructions, keywords, or formatting tweaks.
- Outlet: Modify the output that you receive from the model. For instance, cleaning up the response, adjusting tone, or formatting data into a specific style.
Use case example:
Suppose youβre working on a project that needs precise formatting. You can use a Filter to ensure:
- Your input is always transformed into the required format.
- The output from the model is cleaned up before being displayed.
Filters are linked to specific models or can be enabled for all models globally, depending on your needs.
Check out the full guide for more examples and instructions: Filter Functions.
3. Action Function β Add Custom Buttonsβ
An Action Function is used to add custom buttons to the chat interface.
What does it do?
Actions allow you to define interactive shortcuts that trigger specific functionality directly from the chat. These buttons appear underneath individual chat messages, giving you convenient, one-click access to the actions you define.
Use case example:
Letβs say you often need to summarize long messages or generate specific outputs like translations. You can create an Action Function to:
- Add a βSummarizeβ button under every incoming message.
- When clicked, it triggers your custom function to process that message and return the summary.
Buttons provide a clean and user-friendly way to interact with extended functionality you define.
Learn how to set them up in the Action Functions Guide.
π οΈ How to Use Functionsβ
Here's how to put Functions to work in Sage WebUI:
1. Install Functionsβ
You can install Functions via the Sage WebUI interface or by importing them manually. You can find community-created functions on the Sage WebUI Community Site.