# Example Projects Explore sample projects built with Mira Flows Discover practical implementations of Mira Flows through our curated collection of example projects. Each example includes complete source code and demonstrates different aspects of the platform. Complete implementation showing how to integrate and use pre-built flows from the Mira Flows marketplace. Step-by-step example of creating and deploying custom flows using the Mira Flows SDK. Example project demonstrating dataset creation, management, and RAG integration with flows. # Video Tutorials Learn Mira Flows through step-by-step video guides Get started with Mira Flows through our comprehensive video tutorials. Each tutorial provides a detailed walkthrough of key platform features and implementation steps. Learn how to discover, integrate, and use pre-built flows from the Mira Flows marketplace in your applications. Follow along to create your first custom flow using the Mira Flows SDK and deploy it to the marketplace. Step-by-step guide to creating and configuring datasets for enhanced RAG capabilities. # Compound Flows Step-by-step guide to installing and setting up Mira Flows SDK for your project A Compound Flow is an advanced flow type designed for complex, multi-stage processing pipelines. Unlike Elemental Flows which perform single, focused tasks, Compound Flows can create sophisticated decision trees, implement custom processing logic, and orchestrate multiple processing stages. 🎯 ## Compound Flow Attributes ### Version ⚡ | Component | Description | Required | Example | | --------- | ---------------------------------------------------- | -------- | --------- | | version | Flow specification version using semantic versioning | Yes | `"0.1.0"` | ### Metadata | Component | Description | Required | Example | | ----------- | --------------------------------- | -------- | ------------------------------------ | | flow\_type | Type of flow (must be "compound") | Yes | `"compound"` | | name | Unique identifier for the flow | Yes | `"your-flow-name"` | | description | Explanation of flow's purpose | Yes | `"A brief description of your flow"` | | author | Creator's username | Yes | `"your-username"` | | tags | Keywords for categorization | No | `[tag1, tag2, tag3]` | | private | Access control setting | Yes | `false` | ### Input Configuration | Component | Description | Required | Example | | ----------- | ------------------------------------------ | -------- | ------------------------------- | | inputs | Map of input parameters | Yes | Collection of input definitions | | type | Data type of input (currently only string) | Yes | `"string"` | | description | Purpose of the input | Yes | `"Description of input1"` | | required | Whether input is mandatory | Yes | `true` or `false` | | example | Sample input value | No | `"Example value for input1"` | ### Workflow Configuration Each Compound Flow must define a workflow consisting of multiple processing stages. There are two types of workflow stages: #### Elemental Stage Configuration | Component | Description | Required | Example | | ----------- | ------------------------------------ | -------- | ---------------------- | | type | Must be "elemental" | Yes | `"elemental"` | | flow\_name | Reference to existing Elemental Flow | Yes | `"author/flow-name"` | | inputs | Mapping to flow inputs | Yes | Input mapping object | | depends\_on | List of dependent stages | No | `["stage1", "stage2"]` | #### Custom Stage Configuration | Component | Description | Required | Example | | ----------- | ------------------------- | -------- | ---------------------------------- | | type | Must be "custom" | Yes | `"custom"` | | model | LLM configuration | Yes | Model settings object | | prompt | Processing instructions | Yes | Template with {input} placeholders | | inputs | Stage input parameters | Yes | Input mapping object | | dataset | RAG dataset configuration | No | `"author_name/dataset_name"` | | depends\_on | List of dependent stages | No | `["stage1", "stage2"]` | ### Dependency Configuration | Component | Description | Required | Example | | ----------- | -------------------------------------------------- | -------- | ---------------------- | | depends\_on | List of stages that must complete before execution | No | `["stage1", "stage2"]` | #### Execution Behavior * Stages without depends\_on can execute in parallel * Stages with depends\_on will wait for specified stages to complete * Multiple stages can depend on the same previous stage ### Output Configuration | Component | Description | Required | Example | | ------------ | -------------------------------- | -------- | ---------------------------------------- | | output.value | List of stage outputs to combine | Yes | `[${stage1.outputs}, ${stage2.outputs}]` | ## Basic Flow Structure ```yaml .yaml # Flow specification version version: "0.1.0" # Flow metadata and configuration metadata: flow_type: "compound" name: "your-flow-name" description: "Describe what this compound flow accomplishes" author: "your-username" tags: [tag1, tag2, tag3] private: true # Primary input definitions inputs: prime_input_1: type: string description: "What this input is used for" required: true example: "Example value" prime_input_2: type: string description: "Description of this input" required: false example: "Example" # Workflow definition workflow: # Elemental Flow stage - starts immediately first_flow: type: "elemental" flow_name: "john_doe/first_elemental_flow" inputs: abc: ${inputs.prime_input_1} xyz: ${inputs.prime_input_2} # Custom processing stage - starts immediately (parallel to first_flow) second_flow: type: "custom" inputs: input1: ${inputs.input_name} model: provider: "provider-name" name: "model-name" prompt: | Your flow's primary instruction or role... You can use {input1} placeholders to reference inputs. # Waits for both first_flow and second_flow to complete third_flow: type: "custom" depends_on: [first_flow, second_flow] inputs: input1: ${first_flow.output} input2: ${second_flow.output} model: provider: "provider-name" name: "model-name" dataset: source: "author_name/dataset_name" prompt: | Your flow's primary instruction or role... You can use {input1} and {input2} placeholders to reference inputs. # Output configuration output: value: - ${first_flow.output} - ${second_flow.output} - ${third_flow.output} # Flow documentation readme: | This is a detailed explanation of what your flow does. ### Workflow Overview: 1. **First Flow**: Executes `john_doe/first_elemental_flow` with the provided inputs. 2. **Second Flow**: Runs in parallel with first flow 3. **Third Flow**: Depends on both previous flows, executes after they complete ### Outputs: - Combined outputs from all flows are returned in order. ``` ## Implementation Structure 🛠️ Compound Flows can either define custom processing logic within their workflow or integrate existing Elemental Flows, providing maximum flexibility for solving complex challenges. The workflow allows for: 1. Advanced Decision Making with conditional processing paths 🧠 2. Custom Processing stages with direct model and prompt configurations ⚙️ 3. Integration of existing Elemental Flows for reusability 🔄 4. Parallel execution of independent stages ⚡ 5. Sequential execution through depends\_on configurations 🔗 6. Flexible input/output mapping between stages 🔀 # Datasets and RAG Step-by-step guide to installing and setting up Mira Flows SDK for your project Datasets in **Mira Flows** support **Retrieval-Augmented Generation (RAG)** to enhance flows with specific knowledge. This capability allows flows to leverage custom knowledge bases for improved accuracy and contextual awareness in their responses. 🤖📈 *** ## Dataset Attributes
| **Component** | **Description** | **Required** | **Example** | | --------------- | ----------------------------- | ------------ | ----------------------------------- | | **Name** | Unique identifier for dataset | Yes | `"author/dataset_name"` | | **Description** | Purpose and content overview | Yes | `"Optional description"` | | **Source Type** | Type of data being added | Yes | `"url"` or `"file_path"` | | **Source Path** | Location of source data | Yes | `"example.com"` or `"path/to/file"` | | **Author** | Creator's username | Yes | `"your-username"` | *** ## Supported File Formats
| **Format** | **Description** | **Processing Method** | | ------------------ | --------------- | ----------------------------------- | | **PDF (.pdf)** | Document files | Text extraction from document | | **Markdown (.md)** | Formatted text | Text extraction from document | | **URL** | Web content | Web content scraping | | **CSV (.csv)** | URL listings | URL extraction and content scraping | | **Text (.txt)** | Plain text | Direct text extraction | *** ## Creating and Configuring Datasets ### Creating a Dataset ```python Python from mira_sdk import MiraClient client = MiraClient(config={"API_KEY": "YOUR_API_KEY"}) # Create dataset client.dataset.create("author/dataset_name", "Optional description") ``` ### Adding Data Sources ```python Python # Add URL to your dataset client.dataset.add_source("author/dataset_name", url="example.com") # Add file to your dataset client.dataset.add_source("author/dataset_name", file_path="path/to/my/file.csv") ``` ### Linking Dataset with Flow Add the following configuration to your `flow.yaml` file: ```yaml .yaml dataset: source: "author/dataset_name" ``` *** # Elemental Flows Understanding the fundamental building blocks of Mira Flows An Elemental Flow is a self-contained, autonomous unit designed to perform specific, unique actions. These flows serve as the foundational building blocks within the Mira Flows ecosystem, enabling precise and reliable AI-powered operations. ## Elemental Flow Attributes ### Version | Component | Description | Required | Example | | --------- | ---------------------------------------------------- | -------- | --------- | | version | Flow specification version using semantic versioning | Yes | `"0.0.1"` | ### Metadata | Component | Description | Required | Example | | ----------- | ------------------------------ | -------- | ------------------------------------ | | name | Unique identifier for the flow | Yes | `"your-flow-name"` | | description | Explanation of flow's purpose | Yes | `"A brief description of your flow"` | | author | Creator's username | Yes | `"your-username"` | | tags | Keywords for categorization | No | `[tag1, tag2, tag3]` | | private | Access control setting | Yes | `false` | ### Input Configuration Supported Input Types: | Type | Description | | ------ | ----------------------- | | string | Text-based input values | Input Structure: | Component | Description | Required | Example | | ----------- | ------------------------------------------ | -------- | ------------------------------- | | inputs | Map of input parameters | Yes | Collection of input definitions | | type | Data type of input (currently only string) | Yes | `"string"` | | description | Purpose of the input | Yes | `"Description of input1"` | | required | Whether input is mandatory | Yes | `true` or `false` | | example | Sample input value | No | `"Example value for input1"` | ### Model Configuration | Component | Description | Required | Example | | --------- | ------------------------- | -------- | ----------------- | | provider | AI service provider | Yes | `"provider-name"` | | name | Specific model identifier | Yes | `"model-name"` | ### Dataset Configuration (Optional) | Component | Description | Required | Example | | --------- | -------------------- | -------- | ---------------------------- | | source | Reference to dataset | No | `"author_name/dataset_name"` | ### Prompt and Readme Configuration | Component | Description | Required | Example | | --------- | ------------------------------- | -------- | ---------------------------------------------- | | prompt | Instructions for model behavior | Yes | "Generate a tweet on the given topic: {topic}" | | readme | Usage documentation | Yes | Markdown-formatted guide | ## Basic Flow Structure The official YAML structure for a basic Mira Flow: ```yaml .yaml version: "your.version.here" metadata: name: "your-flow-name" description: "A brief description of your flow" author: "your-username" tags: [tag1, tag2, tag3] private: false inputs: input1: type: string 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" model: provider: "provider-name" name: "model-name" prompt: | Your flow's primary instruction or role... You can use {input1} and {input2} placeholders to reference inputs. readme: | Your flow's readme... You can use raw text or markdown here. ``` ## RAG Integration 🔍 To integrate RAG capabilities, you'll need to: 1. Create a dataset 2. Add data sources to your dataset 3. Link the dataset to your flow The following file formats are supported for datasets: | File Type | Processing Method | | -------------- | --------------------------------------- | | PDF (.pdf) | Text extraction from document | | Markdown (.md) | Text extraction from document | | URL | Web content scraping | | CSV (.csv) | URL extraction and content scraping | | Text (.txt) | Direct text extraction | | Zip (.zip) | Processing of contained supported files | ### Creating a Dataset 🗃️ ```python from mira_sdk import MiraClient client = MiraClient(config={"API_KEY": "YOUR_API_KEY"}) # Create dataset client.dataset.create("author/dataset_name", "Optional description") ``` ### Adding Data Sources ```python # Add URL to your dataset client.dataset.add_source("author/dataset_name", url="example.com") # Add file to your dataset client.dataset.add_source("author/dataset_name", file_path="path/to/my/file.csv") ``` ### Linking Dataset with Flow Add the following configuration to your flow\.yaml file: ```yaml dataset: source: "author/dataset_name" ``` ### Flow Structure with RAG The official YAML structure for a flow with RAG capabilities: ```yaml version: "your.version.here" metadata: name: "your-flow-name" description: "A brief description of your flow" author: "your-username" tags: [tag1, tag2, tag3] private: false inputs: input1: type: string description: "Description of input1" required: true example: "Example value for input1" model: provider: "provider-name" name: "model-name" dataset: source: "author_name/dataset_name" prompt: | Your flow's primary instruction or role... You can use {input1} placeholders to reference inputs. readme: | Your flow's readme... You can use raw text or markdown here. ``` # Installation Step-by-step guide to installing and setting up Mira Flows SDK for your project ## Account Setup Sign up for your free Mira Flows account and begin your AI development journey. Generate your API key from the API section - you'll need this to access Mira Flows features. ## Prerequisites Mira flows requires **`Python >=3.9, <=3.13`** ```bash # Check your Python version python3 --version ``` Need to update? Visit [python.org/downloads](https://python.org/downloads) ## Installation Steps 1. Install the SDK using pip: ```bash pip install mira-sdk ``` 1. Initialize the client: ```python from mira_sdk import MiraClient client = MiraClient(config={"API_KEY": "YOUR_API_KEY"}) ``` ### Using Environment Variables (Recommended) Install python-dotenv ```bash pip install python-dotenv ``` Create a `.env` file in your project root and add: ```plaintext MIRA_API_KEY=your_api_key_here ``` Then initialize the client using the environment variable: ```python from dotenv import load_dotenv from mira_sdk import MiraClient import os load_dotenv() client = MiraClient(config={"API_KEY": os.getenv("MIRA_API_KEY")}) ``` ## Next Steps Browse available flows to understand the platform's capabilities and start using pre-built solutions. Follow our guide to build your own custom flow and unlock the full potential of Mira Flows. # Introduction Introduction to Mira Flows SDK ## What is Mira Flows SDK? Mira Flows SDK is a powerful Python toolkit that enables developers to programmatically create, manage, and deploy AI-powered flows. From simple chat interfaces to complex multi-stage AI pipelines, the SDK provides a seamless interface to build sophisticated AI applications by combining Large Language Models (LLMs) with custom knowledge bases and configurable workflows. ## Key Features Create, test, and deploy AI flows with minimal setup using straightforward YAML configurations - from basic chatbots to complex multi-stage pipelines Enhance your flows with custom knowledge through easy integration of PDFs, markdown files, URLs, and more for context-aware AI solutions Discover, use, and customize pre-built flows from our growing marketplace of AI solutions to accelerate development ## SDK Capabilities * **Simple to Complex**: Build everything from basic Q\&A flows to sophisticated multi-stage processing pipelines * **Actionable Flows**: Transform your flows into autonomous agents that can interact with external tools and APIs * **Custom Knowledge Integration**: Enhance flows with domain-specific knowledge through RAG capabilities * **Flow Composition**: Combine multiple flows to create complex AI workflows and processing chains * **Extensible Design**: Add custom tools and integrations to expand your flows' capabilities * **Scalable Architecture**: Handle increasing workloads with built-in scaling capabilities ## Getting Started Sign up for a Mira Flows account to begin your AI development journey. Set up the Mira Flows SDK in your development environment. Discover available flows and explore the possibilities in our marketplace of AI solutions. Connect with developers, and stay updated through our vibrant Discord community. Start building powerful AI applications with Mira Flows SDK today! Follow our [installation guide](./installation.md) to begin your journey. # Models Step-by-step guide to installing and setting up Mira Flows SDK for your project **Mira Flows** provides access to a selection of **Large Language Models (LLMs)** that serve as the computational engine for flows. Each model offers specific capabilities and performance characteristics suitable for different use cases. 🚀✨ *** ## Model Attributes
| **Component** | **Description** | **Required** | **Example** | | -------------- | ------------------------- | ------------ | -------------------------- | | **Provider** | AI service provider | Yes | `"meta"` | | **Model Name** | Specific model identifier | Yes | `"llama-3.3-70b-instruct"` | *** ## Available Models
| **Provider** | **Model Name** | | ------------- | ------------------------ | | **openai** | `gpt-4o` | | **anthropic** | `claude-3.5-sonnet` | | **meta** | `llama-3.3-70b-instruct` | # Build Compound Flows Learn how to build your own compound flow using Mira Flows SDK This guide explains how to **create, test, and deploy compound flows** that implement complex, multi-stage processing pipelines. **Compound flows** provide sophisticated capabilities for implementing business logic, custom processing stages, and integration with existing **elemental flows**. 🔄💡 ## Development Lifecycle Creating a **compound flow** follows a systematic process: Let's explore each step in detail. *** Use **OpenAI (gpt-4o)** or **Anthropic (claude-3.5-sonnet)** models when building complex workflows to ensure optimal performance. Checkout [Available Models](documentation/get-started/models) ## Step 1: YAML Configuration ```yaml .yaml # Flow specification version version: "0.1.0" # Flow specification version metadata: flow_type: "compound" # Specifies this as a compound flow name: "your-flow-name" # Unique identifier description: "Describe what this compound flow accomplishes" author: "your-username" # Your Mira Flows username tags: [tag1, tag2, tag3] # Discovery keywords private: true # Access control setting inputs: prime_input_1: # Primary input parameter type: string description: "What is this input used for" required: true example: "Example value" prime_input_2: # Secondary input parameter type: string description: "Description of this input" required: false example: "Example" workflow: # Elemental Flow stage - starts immediately first_flow: # First processing stage type: "elemental" flow_name: "john_doe/first_elemental_flow" inputs: abc: ${inputs.prime_input_1} xyz: ${inputs.prime_input_2} # Custom processing stage - starts immediately (parallel to first_flow) second_flow: # Parallel processing stage type: "custom" inputs: input1: ${inputs.prime_input_1} model: provider: "provider-name" # e.g., anthropic, openai, meta, etc. name: "model-name" # Specific model identifier prompt: | Your flow's primary instruction or role... You can use {input1} placeholders to reference inputs. # Waits for both first_flow and second_flow to complete third_flow: type: "custom" depends_on: [first_flow, second_flow] # Dependent on fist_flow and second_flow inputs: input1: ${first_flow.output} # uses output of first_flow as input input2: ${second_flow.output} # uses output of second_flow as input model: provider: "provider-name" name: "model-name" dataset: source: "author_name/dataset_name" prompt: | Your flow's primary instruction or role... You can use {input1} and {input2} placeholders to reference inputs. output: value: # Combine & customise outputs in order - ${first_flow.output} - ${second_flow.output} - ${third_flow.output} readme: | This is a detailed explanation of what your flow does. ### Workflow Overview: 1. **First Flow**: Executes `john_doe/first_elemental_flow` with the provided inputs 2. **Second Flow**: Runs in parallel with first flow 3. **Third Flow**: Depends on both previous flows, executes after they complete ### Outputs: - Combined outputs from all flows are returned in order ``` *** ## Step 2: Testing **Test your compound flow** to ensure all stages work correctly: ```python Python from mira_sdk import MiraClient, CompoundFlow from mira_sdk.exceptions import FlowError client = MiraClient(config={"API_KEY": "YOUR_API_KEY"}) # Initialize Mira Client flow = CompoundFlow(source="/path/to/compound_flow.yaml") # Load flow configuration test_input = { # Prepare test inputs "prime_input_1": "test data", "prime_input_2": "test parameters" } try: response = client.flow.test(flow, test_input) # Test entire pipeline print("Test response:", response) except FlowError as e: print("Test failed:", str(e)) # Handle test failure ``` *** ## Step 3: Deployment **Deploy your compound flow** to make it available: ```python Python from mira_sdk import MiraClient, CompoundFlow from mira_sdk.exceptions import FlowError flow = CompoundFlow(source="/path/to/compound_flow.yaml") # Load flow configuration try: client.flow.deploy(flow) # Deploy to platform print("Compound flow deployed successfully!") # Success message except FlowError as e: print(f"Deployment error: {str(e)}") # Handle deployment error ``` *** ## Step 4: Execution After deployment, **execute your compound flow**: ```python Python from mira_sdk import MiraClient from mira_sdk.exceptions import FlowError flow_name = "your-username/your-flow-name" # Flow identifier input_data = { # Execution inputs "prime_input_1": "production data", "prime_input_2": "production parameters" } try: result = client.flow.execute(flow_name, input_data) # Execute workflow print("Execution result:", result) # Display result except FlowError as e: print("Execution error:", str(e)) # Handle execution error ``` *** ## Step 5: Updates When you need to **modify your compound flow**: ```python Python from mira_sdk import MiraClient from mira_sdk.exceptions import FlowError flow = client.flow.get("your-username/your-flow-name") # Retrieve existing flow flow.save("/path/to/compound_flow.yaml") # Save for editing try: client.flow.deploy(flow) # Deploy updated version print("Updated flow deployed successfully!") # Success message except FlowError as e: print(f"Update error: {str(e)}") # Handle update error # In case you forget to bump the flow version, it will get bumped by default every time you deploy the same flow. ``` By following these steps, you can **create, test, deploy, and manage** your own **custom compound flows** on the **Mira Flows** platform. 🌟🔧 # Build Elemental Flows Learn how to build your own elemental flow using Mira Flows SDK ## Video Tutorial