<div align="center">
<img src="static/logo.png" width="250px"></img>
<h1>Autoflows</h1>
<i>Automated Flyte Workflows using LLMs</i>
</div>
The `autoflows` package allows you to run Flyte workflows that are powered by
LLMs. These workflows use LLMs to determine which task to run in a suite of
user-defined, trusted Flyte tasks.
## Installation
```bash
pip install autoflows
```
## Usage
First we can define some Flyte tasks as usual:
```python
# example.py
from flytekit import task
from autoflows import autoflow
image_spec = ImageSpec(
"auto-workflows",
registry="ghcr.io/unionai-oss",
requirements="requirements.txt",
python_version="3.10",
)
@task(container_image=image_spec)
def add_numbers(x: float, y: float) -> FlyteFile: ...
@task(container_image=image_spec)
def concat_strings(strings: List[str]) -> FlyteFile: ...
@task(container_image=image_spec)
def train_classifier(data: List[dict], target_column: str) -> FlyteFile:
...
```
Then, in the same file, we define a `FlyteRemote` object that we want to use to
run our autoflow.
```python
# example.py
remote = FlyteRemote(
config=Config(
platform=PlatformConfig(
endpoint="<my_endpoitn>",
client_id="<my_client_id>",
),
),
default_project="flytesnacks",
default_domain="development",
)
```
Finally, we define the `autoflow` function:
```python
# example.py
@autoflow(
tasks=[add_numbers, concat_strings, train_classifier],
model="gpt-3.5-turbo-1106",
remote=remote,
openai_secret_group="<OPENAI_API_SECRET_GROUP>",
openai_secret_key="<OPENAI_API_SECRET_KEY>",
client_secret_group="<CLIENT_SECRET_GROUP>",
client_secret_key="<CLIENT_SECRET_KEY>",
container_image=image_spec,
)
async def main(prompt: str, inputs: dict) -> FlyteFile:
"""You are a helpful bot that picks functions based on a prompt and a set of inputs.
What tool should I use for completing the task '{prompt}' using the following inputs?
{inputs}
"""
```
## Running on Flyte or Union
Then, you can register the workflow along with all of the tasks:
```bash
pyflyte --config config.yaml register example.py
```
Where `config.yaml` is the Flyte configuration file pointing to your Flyte or
Union cluster.
Finally, you can run the workflow, and let the `autoflow` function decide which
task to run based on the prompt and inputs. For example, to add two numbers, you
would do:
```bash
pyflyte --config config.yaml run example.py main \
--prompt "Add these two numbers" \
--inputs '{"x": 1, "y": 2}'
```
To concatenate two strings, you would do:
```bash
pyflyte run \
test_auto_workflow.py auto_wf \
--prompt "Combine these two strings together" \
--inputs '{"strings": ["hello", " ", "world"]}'
```
And to train a classifier based on data:
```bash
pyflyte run \
test_auto_workflow.py auto_wf \
--prompt "Train a classifier on this small dataset" \
--inputs "{\"target_column\": \"y\", \"training_data\": $(cat data.json)}"
```
Where `data.json` contains json objects that looks something like:
```
[
{"x": 5, "y": 10},
{"x": 3, "y": 5},
{"x": 10, "y": 19},
]
```
Raw data
{
"_id": null,
"home_page": "https://github.com/unionai-oss/autoflows/",
"name": "autoflows",
"maintainer": "",
"docs_url": null,
"requires_python": ">3.7",
"maintainer_email": "",
"keywords": "machine-learning,artificial-intelligence,orchestration",
"author": "unionai-oss",
"author_email": "info@union.ai",
"download_url": "https://files.pythonhosted.org/packages/12/fa/4349928c9d5fc8c19004fe19cf78a2bc524886a865dcce8e8ac4e0e7e07d/autoflows-0.0.1.tar.gz",
"platform": "any",
"description": "<div align=\"center\">\n<img src=\"static/logo.png\" width=\"250px\"></img>\n\n<h1>Autoflows</h1>\n\n<i>Automated Flyte Workflows using LLMs</i>\n</div>\n\nThe `autoflows` package allows you to run Flyte workflows that are powered by\nLLMs. These workflows use LLMs to determine which task to run in a suite of\nuser-defined, trusted Flyte tasks.\n\n## Installation\n\n```bash\npip install autoflows\n```\n\n## Usage\n\nFirst we can define some Flyte tasks as usual:\n\n```python\n# example.py\n\nfrom flytekit import task\nfrom autoflows import autoflow\n\n\nimage_spec = ImageSpec(\n \"auto-workflows\",\n registry=\"ghcr.io/unionai-oss\",\n requirements=\"requirements.txt\",\n python_version=\"3.10\",\n)\n\n\n@task(container_image=image_spec)\ndef add_numbers(x: float, y: float) -> FlyteFile: ...\n\n\n@task(container_image=image_spec)\ndef concat_strings(strings: List[str]) -> FlyteFile: ...\n\n\n@task(container_image=image_spec)\ndef train_classifier(data: List[dict], target_column: str) -> FlyteFile:\n ...\n```\n\nThen, in the same file, we define a `FlyteRemote` object that we want to use to\nrun our autoflow.\n\n```python\n# example.py\n\nremote = FlyteRemote(\n config=Config(\n platform=PlatformConfig(\n endpoint=\"<my_endpoitn>\",\n client_id=\"<my_client_id>\",\n ),\n ),\n default_project=\"flytesnacks\",\n default_domain=\"development\",\n)\n```\n\nFinally, we define the `autoflow` function:\n\n```python\n# example.py\n\n@autoflow(\n tasks=[add_numbers, concat_strings, train_classifier],\n model=\"gpt-3.5-turbo-1106\",\n remote=remote,\n openai_secret_group=\"<OPENAI_API_SECRET_GROUP>\",\n openai_secret_key=\"<OPENAI_API_SECRET_KEY>\",\n client_secret_group=\"<CLIENT_SECRET_GROUP>\",\n client_secret_key=\"<CLIENT_SECRET_KEY>\",\n container_image=image_spec,\n)\nasync def main(prompt: str, inputs: dict) -> FlyteFile:\n \"\"\"You are a helpful bot that picks functions based on a prompt and a set of inputs.\n\n What tool should I use for completing the task '{prompt}' using the following inputs?\n {inputs}\n \"\"\"\n\n```\n\n## Running on Flyte or Union\n\nThen, you can register the workflow along with all of the tasks:\n\n```bash\npyflyte --config config.yaml register example.py\n```\n\nWhere `config.yaml` is the Flyte configuration file pointing to your Flyte or\nUnion cluster.\n\nFinally, you can run the workflow, and let the `autoflow` function decide which\ntask to run based on the prompt and inputs. For example, to add two numbers, you\nwould do:\n\n```bash\npyflyte --config config.yaml run example.py main \\\n --prompt \"Add these two numbers\" \\\n --inputs '{\"x\": 1, \"y\": 2}'\n```\n\nTo concatenate two strings, you would do:\n\n```bash\npyflyte run \\\n test_auto_workflow.py auto_wf \\\n --prompt \"Combine these two strings together\" \\\n --inputs '{\"strings\": [\"hello\", \" \", \"world\"]}'\n```\n\nAnd to train a classifier based on data:\n\n```bash\npyflyte run \\\n test_auto_workflow.py auto_wf \\\n --prompt \"Train a classifier on this small dataset\" \\\n --inputs \"{\\\"target_column\\\": \\\"y\\\", \\\"training_data\\\": $(cat data.json)}\"\n```\n\nWhere `data.json` contains json objects that looks something like:\n\n```\n[\n {\"x\": 5, \"y\": 10},\n {\"x\": 3, \"y\": 5},\n {\"x\": 10, \"y\": 19},\n]\n```\n",
"bugtrack_url": null,
"license": "Apache",
"summary": "Automated Flyte workflows, powered by GPTs.",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/unionai-oss/autoflows/",
"Issue Tracker": "https://github.com/unionai-oss/autoflows/issues",
"Source Code": "https://github.com/unionai-oss/autoflows/"
},
"split_keywords": [
"machine-learning",
"artificial-intelligence",
"orchestration"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c62f9ff7b662adc2c54e47d1bd4e68becfb01eaab894bf6251924c71ce5424f8",
"md5": "f0343b8a52d9e005833b85a784ec2c83",
"sha256": "994c450749d98d98ac456e72cd645fd99e672bdb8f43995bc4a0d936f5535ec6"
},
"downloads": -1,
"filename": "autoflows-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f0343b8a52d9e005833b85a784ec2c83",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">3.7",
"size": 12872,
"upload_time": "2023-12-05T20:29:43",
"upload_time_iso_8601": "2023-12-05T20:29:43.954429Z",
"url": "https://files.pythonhosted.org/packages/c6/2f/9ff7b662adc2c54e47d1bd4e68becfb01eaab894bf6251924c71ce5424f8/autoflows-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "12fa4349928c9d5fc8c19004fe19cf78a2bc524886a865dcce8e8ac4e0e7e07d",
"md5": "ec7cd747d13833542a72d9694ed3efc3",
"sha256": "253c149e08358d44a912c23c8c72c5b7bc257e8823383bb713b9de04d52d9111"
},
"downloads": -1,
"filename": "autoflows-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "ec7cd747d13833542a72d9694ed3efc3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">3.7",
"size": 9484,
"upload_time": "2023-12-05T20:29:46",
"upload_time_iso_8601": "2023-12-05T20:29:46.037057Z",
"url": "https://files.pythonhosted.org/packages/12/fa/4349928c9d5fc8c19004fe19cf78a2bc524886a865dcce8e8ac4e0e7e07d/autoflows-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-05 20:29:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "unionai-oss",
"github_project": "autoflows",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "autoflows"
}