Automated Flyte workflows, powered by GPTs.
Project description
Autoflows
Automated Flyte Workflows using LLMs
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
pip install autoflows
Usage
First we can define some Flyte tasks as usual:
# 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.
# 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:
# 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:
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:
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:
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:
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},
]
Project details
Release history Release notifications | RSS feed
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 autoflows-0.0.1.tar.gz
.
File metadata
- Download URL: autoflows-0.0.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 253c149e08358d44a912c23c8c72c5b7bc257e8823383bb713b9de04d52d9111 |
|
MD5 | ec7cd747d13833542a72d9694ed3efc3 |
|
BLAKE2b-256 | 12fa4349928c9d5fc8c19004fe19cf78a2bc524886a865dcce8e8ac4e0e7e07d |
File details
Details for the file autoflows-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: autoflows-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 994c450749d98d98ac456e72cd645fd99e672bdb8f43995bc4a0d936f5535ec6 |
|
MD5 | f0343b8a52d9e005833b85a784ec2c83 |
|
BLAKE2b-256 | c62f9ff7b662adc2c54e47d1bd4e68becfb01eaab894bf6251924c71ce5424f8 |