Skip to main content

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

Project description

ffai-workflow-adapters

PyPI Docs CI

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

Documentation: https://ffai-workflow-adapters.readthedocs.io/en/latest/

Installation

pip install ffai-workflow-adapters

With optional adapters:

pip install ffai-workflow-adapters[airtable]
pip install ffai-workflow-adapters[excel]
pip install ffai-workflow-adapters[google_sheets]
pip install ffai-workflow-adapters[ods]
pip install ffai-workflow-adapters[all]

Or with uv:

uv pip install ffai-workflow-adapters
uv pip install ffai-workflow-adapters[airtable]

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_excel, write_workflow_results_excel

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)

    spec = load_workflow_excel("workflow.xlsx", name="my_workflow")

    result = await ffai.execute_workflow(spec)

    write_workflow_results_excel(result, path="results.xlsx")


asyncio.run(main())

How It Works

  1. Define your workflow as rows in a spreadsheet — 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 Format Install Documentation
Airtable Cloud pip install ffai-workflow-adapters[airtable] Airtable adapter guide
CSV File Included (stdlib csv) CSV adapter guide
Excel File pip install ffai-workflow-adapters[excel] Excel adapter guide
Google Sheets Cloud pip install ffai-workflow-adapters[google_sheets] Google Sheets adapter guide
ODS File pip install ffai-workflow-adapters[ods] ODS 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

Cloud adapter operations (Airtable, Google Sheets) 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 Adapter Description
MISTRAL_API_KEY Mistral API key (default model)
OPENAI_API_KEY OpenAI API key
AIRTABLE_API_KEY Airtable Airtable personal access token
AIRTABLE_BASE_ID Airtable Airtable base ID
GOOGLE_SHEETS_CREDENTIALS Google Sheets Path to service account JSON file
GOOGLE_SHEETS_AUTHORIZED_USER Google Sheets Path to authorized user JSON file (OAuth)
GOOGLE_SHEETS_API_KEY Google Sheets API key string (public sheets only)
OBSERVABILITY__ENABLED Enable OpenTelemetry span emission (true/false, default false)
OBSERVABILITY__OTEL__ENDPOINT OTLP gRPC endpoint (default http://localhost:4317)

Observability

Adapter operations emit OpenTelemetry spans when FFAI's observability is enabled. Set OBSERVABILITY__ENABLED=true to activate. Requires pip install ffai[otel]. When disabled (the default), spans are no-ops with zero overhead.

Span Operation
ffai.adapters.airtable.load Load workflow from Airtable table
ffai.adapters.airtable.write Write results to Airtable table
ffai.adapters.excel.load Load workflow from Excel file
ffai.adapters.excel.write Write results to Excel file
ffai.adapters.csv.load Load workflow from CSV/TSV file
ffai.adapters.csv.write Write results to CSV/TSV file
ffai.adapters.ods.load Load workflow from ODS file
ffai.adapters.ods.write Write results to ODS file
ffai.adapters.google_sheets.load Load workflow from Google Sheets
ffai.adapters.google_sheets.write Write results to Google Sheets
ffai.adapters.resilience.call External API call (rate limited, retried)
ffai.adapters.resilience.retry Retry attempt on transient failure

API Reference

Airtable

load_workflow_airtable(base_id, table_name, *, view=None, adapter=None, name="unnamed", ...)

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, *, adapter=None, spec=None, run_id=None)

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

CSV / TSV

load_workflow_csv(path, *, delimiter=",", adapter=None, name="unnamed", ...)

Load a workflow spec from a CSV file. Use delimiter="\t" for TSV.

load_workflow_tsv(path, *, adapter=None, name="unnamed", ...)

Load a workflow spec from a TSV file. Equivalent to load_workflow_csv with tab delimiter.

write_workflow_results_csv(result, path=None, *, delimiter=",", adapter=None, spec=None, run_id=None)

Write results to a CSV file. Appends to existing files. Falls back to output_path from config.

write_workflow_results_tsv(result, path=None, *, adapter=None, spec=None, run_id=None)

Write results to a TSV file.

Excel

load_workflow_excel(path, *, sheet=None, adapter=None, name="unnamed", ...)

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).

Google Sheets

load_workflow_google_sheets(spreadsheet_id, *, worksheet=None, auth_method=None, credentials_file=None, ...)

Load a workflow spec from a Google Sheets spreadsheet. Supports three auth methods: service_account (default), oauth, and api_key. Includes rate limiting and retry.

write_workflow_results_google_sheets(spreadsheet_id, result, *, worksheet=None, auth_method=None, ...)

Write results to a Google Sheets worksheet. Creates the worksheet if it doesn't exist.

ODS

load_workflow_ods(path, *, sheet=None, adapter=None, name="unnamed", ...)

Load a workflow spec from an OpenDocument .ods file.

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

Write results to an ODS file. Always creates a new file.

Configuration

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.2.1.tar.gz (63.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.2.1-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ffai_workflow_adapters-0.2.1.tar.gz
  • Upload date:
  • Size: 63.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.2.1.tar.gz
Algorithm Hash digest
SHA256 f6389148448cd6b5ac9b625da353e8161b18b1dc176c8b385e6ca72bd646180a
MD5 c211478e420ce01316cc817f30aae63f
BLAKE2b-256 24f2bb79c4420ed6f149500eb384d4d737aad0294ec3ae77f9b79f120151d7f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffai_workflow_adapters-0.2.1.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.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for ffai_workflow_adapters-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a041fc82f33e77cae75986824c43f1a8cfa7edf491c7eedb8d7266fea45cac7
MD5 156627e66070b2567419d75b01b47c78
BLAKE2b-256 000f43dd460374fc066950221ab1bfd572c4651cc4fc9f22e215ece04e237f14

See more details on using hashes here.

Provenance

The following attestation bundles were made for ffai_workflow_adapters-0.2.1-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