Skip to main content

A Python SDK for the Mira API

Project description

mira-sdk / mira-cli

Prerequisites

  • Python 3.10.*
  • pip
  • pdm

Setup

pdm sync

Usage

CLI Commands

The mira-cli provides several commands for managing flows, prompts, and executing operations. Here's a brief overview of the available commands:

  1. Initialize a flow:

    pdm run python -m src.mira.cli.mira_cli init --flow <flow_name> --template <template_name>
    
    • List available templates:
      pdm run python -m src.mira.cli.mira_cli init --list
      
  2. Execute a flow: - #TODO - lets call this as local testing or local run

    pdm run python -m src.mira.cli.mira_cli execute --config <path_to_config_file> --input key1=value1 key2=value2
    
  3. Manage prompts: - we have to start with prompts

    • List all prompts:
      pdm run python -m src.mira.cli.mira_cli prompts --lists
      
    • Show details of a specific prompt:
      pdm run python -m src.mira.cli.mira_cli prompts --show --prompt-name <author/prompt_name>
      
  4. Deploy a flow:

    pdm run python -m src.mira.cli.mira_cli deploy --flow <path_to_yaml_config> --name <flow_name>
    
  5. Execute a deployed flow:

    pdm run python -m src.mira.cli.mira_cli execute-flow --flow-name <flow_name> --input-data '{"key": "value"}'
    

For more detailed information on each command and its options, use the --help flag:

SDK Usage

The Mira SDK provides a simple way to execute flows and build custom flows programmatically. Here are examples of how to use the SDK:

Executing a Flow

To execute a flow using the MiraClient:

from mira_sdk.mira.client.mira_client import MiraClient

client = MiraClient("flows/person.yaml")
result = client.execute({"coin": "Solana"})
print(result)

This script loads a flow from a YAML file and executes it with the given input.

Building a Custom Flow

#TODO - lets skip this piece for now

To create a custom flow using the FlowBuilder:

from mira_sdk.mira.builder.flow_builder import FlowBuilder

builder = FlowBuilder()

# Set flow name and description
builder.set_name("SimpleTextGenerator")
builder.set_description("Persona Impersonator")

# Add resources
builder.add_prompt([{"second_prompt": "Generate a short story about {person} at {club}", "type": "local"},
                    {"main_prompt": "@aroha-labs/klok/1.0.0", "type": "mira"}])
builder.add_resource("knowledge", "writing_tips", {"file": "writing_tips.txt"})
builder.add_resource("models", "story_generator", {"type": "gpt-3.5-turbo"})

# Add component
builder.add_component(
    "story_generator",
    "Generator",
    {
        "prompt": "{resources.prompts.main_prompt}",
        "models": "{resources.models.story_generator}",
    },
)

# Add flow step
builder.add_flow_step(
    "story_generator",
    inputs=[{"person": "request", "club": "request"}],
    outputs=[{"target": "response"}]
)

# Save the flow
builder.save("flows/person.yaml")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mira_sdk-0.1.12.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mira_sdk-0.1.12-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file mira_sdk-0.1.12.tar.gz.

File metadata

  • Download URL: mira_sdk-0.1.12.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for mira_sdk-0.1.12.tar.gz
Algorithm Hash digest
SHA256 6719381c3f7966fedbea242535e9dcebcdbc23b67b41893e3864d7be0b799b76
MD5 1a1f6b61c67144a164415cec4ccbe1d8
BLAKE2b-256 1e3d82f26866e33bdea1f87a0663f2eb1b2fa20f8dc577a6a1fb8da51e21eb88

See more details on using hashes here.

File details

Details for the file mira_sdk-0.1.12-py3-none-any.whl.

File metadata

  • Download URL: mira_sdk-0.1.12-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for mira_sdk-0.1.12-py3-none-any.whl
Algorithm Hash digest
SHA256 898abdaff953e85c6b9637c5029c964a10b2539dcdb239348ce5d23e978fe028
MD5 23c76eb62a473f656efeea1010b571fd
BLAKE2b-256 6d70e8a65090adea525810ef9c5980bd49820948c1f25505036eef36f65d6a98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page