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:
-
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
- List available templates:
-
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
-
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>
- List all prompts:
-
Deploy a flow:
pdm run python -m src.mira.cli.mira_cli deploy --flow <path_to_yaml_config> --name <flow_name>
-
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_stg.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_stg.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
Built Distribution
File details
Details for the file mira_sdk_stg-0.1.1.tar.gz
.
File metadata
- Download URL: mira_sdk_stg-0.1.1.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d5c892c0c2084afb325b0ce1ca25d2bc17c10307944be8ca3ac58bd75e3d898 |
|
MD5 | 0028cd5ab6f6e4d216ce1848d8cf0f03 |
|
BLAKE2b-256 | d5817a70411ea202d098d161dd4f06e097d0c9a3fe88c4fd2be72482a7a7d11a |
File details
Details for the file mira_sdk_stg-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: mira_sdk_stg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fad0d396cb73a0ba21144c80141d9c7fa2702619c26f3eada0590767fc81d0e7 |
|
MD5 | 161b595dc027292bd665e518798137b9 |
|
BLAKE2b-256 | 3fc328027c51905d4043a4ceeb1e3fe0812890c8886976ae718777d8f00ade3e |