No project description provided
Project description
WorkflowAI Python
A library to use WorkflowAI with Python
Installation
workflowai
requires a python >= 3.9.
pip install workflowai
Usage
Usage examples are available in the examples directory.
Set up the workflowai client
import workflowai
wai = workflowai.start(
url=..., # defaults to WORKFLOWAI_API_URL env var or https://api.workflowai.com
api_key=..., # defaults to WORKFLOWAI_API_KEY env var
)
Define a task
We use pydantic for type definitions.
from pydantic import BaseModel, Field
from workflowai import Task, TaskVersionReference
class CityToCapitalTaskInput(BaseModel):
city: str
class CityToCapitalTaskOutput(BaseModel):
capital: str
class CityToCapitalTask(Task[CityToCapitalTaskInput, CityToCapitalTaskOutput]):
id: str = "citytocapital"
schema_id: int = 1
input_class: type[CityToCapitalTaskInput] = CityToCapitalTaskInput
output_class: type[CityToCapitalTaskOutput] = CityToCapitalTaskOutput
# The default version that should be used when running the task
version: TaskVersionReference = TaskVersionReference(
iteration=4,
)
Run a task
task = CityToCapitalTask()
task_input = CityToCapitalTaskInput(city=city)
task_run = await wai.run(task, task_input)
print(task_run.task_output)
It is also possible to stream a task output
task = CityToCapitalTask()
task_input = CityToCapitalTaskInput(city=city)
iterator = await wai.run(task, task_input, stream=True)
async for chunk in iterator:
print(chunk) # chunk is a partial (non validated) CityToCapitalTaskOutput
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 workflowai-0.4.1.tar.gz
.
File metadata
- Download URL: workflowai-0.4.1.tar.gz
- Upload date:
- Size: 12.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7431055f315413fa1c405512121bb30ded468c55b74a3527a4db021e4e706ff7 |
|
MD5 | c73c2524b235c845717951af2c7eaafb |
|
BLAKE2b-256 | 64c4b9c28f8c0109f43eef6ce9fc8889ba50e1bec9ad3670d7b6b54e6ed76c16 |
Provenance
The following attestation bundles were made for workflowai-0.4.1.tar.gz
:
Publisher:
publish.yml
on workflowai/workflowai-py
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
workflowai-0.4.1.tar.gz
- Subject digest:
7431055f315413fa1c405512121bb30ded468c55b74a3527a4db021e4e706ff7
- Sigstore transparency entry: 150808861
- Sigstore integration time:
- Predicate type:
File details
Details for the file workflowai-0.4.1-py3-none-any.whl
.
File metadata
- Download URL: workflowai-0.4.1-py3-none-any.whl
- Upload date:
- Size: 20.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 743369cbafe091451819e03bfa3e9e4f450e5daa9f09638d58cf8abd1eef2e30 |
|
MD5 | 97bb6b3fbad70257257ca4c79aff1c4c |
|
BLAKE2b-256 | 1c7359728752f4b4ce388836a95eccd94f5505126e6dccbbfbd88487490fc9d8 |
Provenance
The following attestation bundles were made for workflowai-0.4.1-py3-none-any.whl
:
Publisher:
publish.yml
on workflowai/workflowai-py
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
workflowai-0.4.1-py3-none-any.whl
- Subject digest:
743369cbafe091451819e03bfa3e9e4f450e5daa9f09638d58cf8abd1eef2e30
- Sigstore transparency entry: 150808862
- Sigstore integration time:
- Predicate type: