Skip to main content

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

workflowai-0.5.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

workflowai-0.5.1-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file workflowai-0.5.1.tar.gz.

File metadata

  • Download URL: workflowai-0.5.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for workflowai-0.5.1.tar.gz
Algorithm Hash digest
SHA256 4ddf32691ab61b4bd57149737c21b7abc0762752a03417413cb0a1089044b3cc
MD5 486fde2fb314de4ff1deed781d03084f
BLAKE2b-256 50a00b9172563b7eabafd6989bdeaa5fd774a80467534c0e53b41888286df0ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for workflowai-0.5.1.tar.gz:

Publisher: publish.yml on WorkflowAI/workflowai-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file workflowai-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: workflowai-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for workflowai-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b6724d2cdf3445046e0ead45d4ff1c098a66db1eefba90e110d6a5747e90e76
MD5 5d72657e50ab2c0edb31beda2355c949
BLAKE2b-256 eb44df7a58e4ad76ec0b78ae7e2107926e72e43393a8c1963c7a65931091139c

See more details on using hashes here.

Provenance

The following attestation bundles were made for workflowai-0.5.1-py3-none-any.whl:

Publisher: publish.yml on WorkflowAI/workflowai-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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