Register an external agent
In addition to using the built-in agent builder studio within SUPERWISE®, you also have the flexibility to build agents using open-source frameworks or tools of your choice (currently, Flowise is the only supported one). Once your agent is up and running externally, you can easily register it in the platform to take advantage of additional capabilities like deployment, authentication, monitoring, and guardrails.
Let’s walk through an example using Flowise, an open-source visual LLM flow builder.
Registering a Flowise agent to a SUPERWISE®
Step 1: Prepare your Flowise flow
Before we begin, you will need to have a working flow within Flowise. You can do this by using Flowise SaaS (it's free to sign up) or a privately hosted deployment version of Flowise.
- If you're using a privately hosted version of Flowise and its APIs are not publicly accessible, please contact our support team at [email protected] for guidance on how to provide us access to your private host.
For the sake of this guide, we pre-built a simple LLM Chain that accepts a prompt (“Answer like a five years old”) and leverages an OpenAI model. Please note that to use an OpenAI model, we had to add our OpenAI token as credentials for Flowise. These credentials will need to be supplied later when registering the agent, as Flowise does not supply the full credentials via its APIs and export function.
We can use Flowise chat to test and ensure it's working before registering it with SUPERWISE®.
Step 2: Register your flow
Registering your existing Flowise flow is easy and can be done using a simple UI form or our SDK.
Using the UI
To register your flow, you only need to submit the following settings:
- Flowise URL: This should be the Flowise SaaS URL. This setting should only be changed for private Flowise deployments and should contain the deployed Flowise URL.
- Flow ID: Your flow identifier in Flowise.
- Flowise API Key: Provide your Flowise API token to enable the platform to access your account and collect details about the implemented flow.
Once you supply the details, just click “Done,” and that’s it! SUPERWISE® will collect all necessary information to support your implemented flow. After this, you will be redirected to our studio to configure your final settings before deploying your agent.
Credentials needed
Since Flowise does not expose your saved credentials, you will need to supply the credentials you used within the flow in our studio. Don’t worry; we will keep them safe and secure.
Good to know
Utilize the playground section to immediately test the chat agent based on your current configuration. Playground interactions are neither persisted nor recorded.
Using the sdk
By providing a valid Flowise API token and a few basic details, the platform will collect all required information and credentials that are implemented within your flow. The code snippet below will print all your existing flow credentials.
from superwise_api.superwise_client import SuperwiseClient
from superwise_api.models.agent.agent import FlowiseAppConfig
# Step 1 - Authenticate and Get Flow credentials schema
url="https://cloud.flowiseai.com/api/v1/" # unless hosted privately
flowise_api_key=<FLOWISE-API-KEY>
flow_id=<FLOW-ID>
# init superwise client
sw = SuperwiseClient(
client_id=<SUPERWISE-CLIENT-ID>,
client_secret=<SUPERWISE-CLIENT-SECRET>
)
# get credentials schema
credentials_schema = sw.agent.get_flowise_credential_schema(
url=url,
api_key=flowise_api_key,
flow_id=flow_id
)
print(credentials_schema.model_dump_json(indent=2))
For the demo flow above, here is the print result:
{
"a7a01c13-6aeb-4db4-bcb7-d6fbd8cf1ca0": {
"name": "demo",
"credential_name": "openAIApi",
"plain_data_obj": {
"openAIApiKey": "password"
}
}
}
Flowise doesn’t expose your credential keys and values, and only provides placeholder strings instead. Therefore, we need to use the print result above to generate an updated credentials_schema
that contains the necessary values.
Advanced credentials
Please bear in mind that in this example, we had only one credential implemented in our flow, and that credential was for OpenAI, which requires only one key. Your flow might contain more than one credential, and specific credentials might contain more than one key. The supplied code snippet above will print the exact structure of all your credentials, making it easy for you to follow and insert your specific keys.
In the code snippet below, we will update our credentials_schema
object to contain our real keys, based on our example flow, and then use the SDK to register and deploy it to SUPERWISE®.
# Step 2: Configure your application with the required credentials
# Update your recieived credentials_schema with you crednetials value.
# Example of filled credentials_schema
# credentials_schema:
# {
# "CREDENTIALS_ID": {
# "name": "USER PROVIDED CREDENTIALS NAME",
# "credential_name": "openAIApi",
# "plain_data_obj": {
# "openAIApiKey": <OPENAI-TOKEN>
# }
# }
# }
# After filling your credentials values...
agent_config = FlowiseAppConfig(
url=url,
api_key=flowise_api_key,
flow_id=flow_id,
flowise_credentials=credentials_schema
}
Updated 13 days ago