Skip to main content

External workflow adapters for FFAI — load workflows from Airtable, Google Sheets, and other tabular sources

Project description

ffai-workflow-adapters

External workflow adapters for ffai — define and execute LLM workflows from Airtable, Excel, and other tabular sources. Each row in a spreadsheet becomes a workflow step (name, prompt, model, temperature, etc.).

Installation

pip install ffai-workflow-adapters

# With Airtable support
pip install ffai-workflow-adapters[airtable]

# With Excel support
pip install ffai-workflow-adapters[excel]

# With both
pip install ffai-workflow-adapters[all]

Quick Start

import asyncio
import os

from dotenv import load_dotenv
from ffai import FFAI
from ffai.Clients.AsyncFFLiteLLMClient import AsyncFFLiteLLMClient
from ffai_workflow_adapters import load_workflow_airtable, write_workflow_results

load_dotenv()


async def main():
    from ffai_workflow_adapters import get_config

    config = get_config()
    client_cfg = config.clients.get_client_type(config.clients.default_client)
    client = AsyncFFLiteLLMClient(
        model_string=f"{client_cfg.provider_prefix}{client_cfg.default_model}",
        api_key=os.environ.get(client_cfg.api_key_env, ""),
    )
    ffai = FFAI(client)

    base_id = os.environ["AIRTABLE_BASE_ID"]
    spec = load_workflow_airtable(base_id, "Workflow Steps", view="basic", name="my_workflow")

    result = await ffai.execute_workflow(spec)

    write_workflow_results(base_id, "_results", result)


asyncio.run(main())

How It Works

  1. Define your workflow as rows in Airtable or Excel — each row is a step with a name, prompt, model, and optional parameters
  2. Load the table into a WorkflowSpec using the adapter for your data source
  3. Execute with ffai — steps run sequentially, with {{step.response}} interpolation chaining outputs between steps
  4. Write back results (response, tokens, cost, duration) to your data source

Example Workflow Table

name prompt client history temperature
topic Name a famous scientific discovery and explain it in one sentence. litellm-mistral-small 0.7
explain Given this discovery: {{topic.response}} — write a paragraph about its impact. litellm-gpt-4o-mini topic 0.5

Adapters

Adapter Install Documentation
Airtable pip install ffai-workflow-adapters[airtable] Airtable adapter guide
Excel pip install ffai-workflow-adapters[excel] Excel adapter guide

Configuration

Uses pydantic-settings with YAML files and environment variable overrides.

Config Files

File Purpose
config/main.yaml Retry and resilience settings
config/adapters.yaml Per-adapter field maps, passthrough columns, named variants
config/clients.yaml LLM client definitions (LiteLLM providers)
config/logging.yaml Logging configuration

Priority (highest to lowest)

  1. Explicit constructor kwargs
  2. Environment variables (nested delimiter __, e.g., RETRY__MAX_ATTEMPTS=5)
  3. Merged YAML files from config/

Clients

Define named clients in config/clients.yaml and reference them by name in your data source's client column:

default_client: litellm-mistral-small

client_types:
  litellm-mistral-small:
    type: litellm
    api_key_env: MISTRAL_API_KEY
    provider_prefix: "mistral/"
    default_model: mistral-small-latest

  litellm-gpt-4o-mini:
    type: litellm
    api_key_env: OPENAI_API_KEY
    provider_prefix: "openai/"
    default_model: gpt-4o-mini
    fallbacks:
      - mistral/mistral-small-latest

Resilience

Airtable operations are protected by rate limiting, circuit breakers, and retries with exponential backoff. All settings are in config/main.yaml and tunable via environment variables:

resilience:
  rate_limit:
    requests_per_second: 5.0
    burst: 10
  circuit_breaker:
    failure_threshold: 5
    recovery_timeout_seconds: 30
    half_open_max_calls: 3
  batch:
    chunk_size: 10
    max_concurrency: 3

Environment Variables

Variable Required Description
MISTRAL_API_KEY Yes Mistral API key (default model)
OPENAI_API_KEY For GPT models OpenAI API key
AIRTABLE_API_KEY For Airtable Airtable personal access token
AIRTABLE_BASE_ID For Airtable Airtable base ID

API Reference

load_workflow_airtable(base_id, table_name, *, ...)

Load a workflow spec from an Airtable table. Supports view, adapter (named variant), name, defaults, clients, tools, and more.

write_workflow_results(base_id, table_name, result, *, ...)

Write workflow execution results back to an Airtable table. Creates one record per step.

load_workflow_excel(path, *, ...)

Load a workflow spec from an Excel .xlsx file. Supports sheet, adapter, name, defaults, clients, tools.

write_workflow_results_excel(result, path=None, *, sheet=None, adapter=None, spec=None, run_id=None)

Write results to an Excel file. path and sheet default to values from config/adapters.yaml. Pass spec= to include passthrough columns. Pass run_id= for a custom run ID (auto-generated if omitted).

get_config()

Get the global configuration singleton.

reload_config()

Reload configuration from YAML files.

License

MIT

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

ffai_workflow_adapters-0.1.0.tar.gz (28.9 kB view details)

Uploaded Source

Built Distribution

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

ffai_workflow_adapters-0.1.0-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file ffai_workflow_adapters-0.1.0.tar.gz.

File metadata

  • Download URL: ffai_workflow_adapters-0.1.0.tar.gz
  • Upload date:
  • Size: 28.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ffai_workflow_adapters-0.1.0.tar.gz
Algorithm Hash digest
SHA256 930ed9d9d1ac6b473a2a138bfae61599e6ac705a95bddbd98e12d47c283592a4
MD5 3ae22029fc8ff505bb611cc66c59bfda
BLAKE2b-256 cffce5e9de3f8a125232ded915f6ac2a85b1945ec3b8733a9de20b73ffa9a266

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffai_workflow_adapters-0.1.0.tar.gz:

Publisher: publish.yml on antquinonez/ffai-workflow-adapters

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

File details

Details for the file ffai_workflow_adapters-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ffai_workflow_adapters-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86ca8ea141f50630a806c04b83aade2d379c3dc1011237e5ceefc9922a16c265
MD5 d7566de4fc51b9e72a172bed06ead55a
BLAKE2b-256 08c2d693a8e83234202bbbd0a9ab7e014205b7759df13a33b4c7fa758bfefa9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffai_workflow_adapters-0.1.0-py3-none-any.whl:

Publisher: publish.yml on antquinonez/ffai-workflow-adapters

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