Skip to content

Building Your Own Flow

Ensure your profile is complete and a username is saved to start building a flow on Mira Flows.

Setting Up Flow Configuration

To create a basic flow, you need to define its configuration in a YAML file:

  1. Create a new file named flow.yaml
  2. Use the following structure to define your flow:
yaml
# version format ex. "0.0.1"
version: "your.version.here"

# Basic metadata for the agent
metadata:
  name: "your-flow-name"
  description: "A brief description of your flow"
  author: "your-username" # This username should match your account username
  tags: [tag1, tag2, tag3, ...] # Tags are keywords used to categorize your flow
  private: false # Access control for your flows (true/false)


# Define the input variables required
inputs:
  input1:
    type: string #Currently we only support String format
    description: "Description of input1"
    required: true
    example: "Example value for input1"
  input2:
    type: string
    description: "Description of input2"
    required: true
    example: "Example value for input2"

# LLM configuration
model:
  provider: "provider-name" # e.g., anthropic, openai, meta, etc.
  name: "model-name"

# Dataset configuration (Optional)
dataset:
  source: "author_name/dataset_name" # Make sure this data set exists

# Prompt template configuration
prompt: |
  Your flow's primary instruction or role...
  You can use {input1} and {input2} placeholders to reference inputs.

# ReadME configuration
readme: |
  Your flow's readme...
  You can use raw text or markdown here.

You may refer to the LLMs section in Core Concepts to view all the available LLMs

Testing and Deploying Your Flow

Local Testing

Before deploying, it's important to test your flow locally to ensure it functions as expected:

python
from mira_sdk import MiraClient, Flow

client = MiraClient(config={"API_KEY": "YOUR_API_KEY"})

# Basic test
flow = Flow(source="/path/to/your.yaml")
input_dict = {"key": "value"}
response = client.flow.test(flow, input_dict)

Deploying Your Flow

Once you're satisfied with your flow's performance, you can deploy it to the Mira Flows marketplace:

python
from mira_sdk import MiraClient, Flow
from mira_sdk.exceptions import FlowError

client = MiraClient(config={"API_KEY": "YOUR_API_KEY"})

# Test the flow locally
flow = Flow(source="/path/to/your.yaml")
try:
	client.flow.deploy(flow)
except FlowError as e:
	print(f"Error occured: {str(e)}")

Using Your Deployed Flow

Once you've deployed your flow, you can use it just like any other marketplace flow. You have the flexibility to use either the latest version or a specific version of your flow.

python
from mira_sdk import MiraClient, Flow

client = MiraClient(config={"API_KEY": "YOUR_API_KEY"})

version = "1.0.0"
input_data = {"key": "value"}

# If no version is provided it'll use latest version by default
if version:
	flow_name = f"author/your-flow-name/{version}"
else:
	flow_name = "author/your-flow-name"

result = client.flow.execute(flow_name, input_data)
print(result)

Listing Available Versions

If you need to see what versions are available for your flow:

python
from mira_sdk import MiraClient

client = MiraClient(config={"API_KEY": "YOUR_API_KEY"})
client.flow.get_all_versions("author/flow_name")

Updating and deploying again

You can edit various aspects of your flow, including its configuration, prompt, and parameters:

python
from mira_sdk import Flow, MiraClient
from mira_sdk.exceptions import FlowError

client = MiraClient(config={"API_KEY": "YOUR_API_KEY"})

# Load your existing flo
flow = client.flow.get("author/flow_name")

# Save your flow to a local yaml file
flow.save("/path/to/flow.yaml")

# You may then edit your flow.yaml file

# Deploy updated flow
try:
	client.flow.deploy(flow)
except FlowError as e:
	print(f"Error occured: {str(e)}")

# Incase you forget to bump the flow version, it will get bumped by default every time you deploy the dame flow.

By following these steps, you can create, test, deploy, and manage your own custom flows on the Mira Flows platform. This process allows you to contribute to the marketplace and continuously improve your flows over time.