Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

TableFlow

TableFlow is a data-centric agentic system for verifiable end-to-end tabular workflows. It combines four specialized routes behind one natural-language entry point:

  • extraction — query structured data out of datasources with SQL and tools
  • processing — inspect and transform tables/workbooks in a persistent Python/native workspace
  • analysis — answer analytical questions over heterogeneous data with quick, standard, or expanded execution modes
  • visualization — render charts (bar / line / scatter / histogram) from tabular data with an LLM planner

Each route can be used independently. The router selects and chains stages as needed. It can also handle simple tasks and out-of-scope questions directly.

System Architecture

User task (natural language)
  └─ DataFlowSystem  →  router agent (complexity assessment)
       │  ├─ out-of-scope / simple → handle directly with Bash or text reply
       │  └─ complex data task → route to stages:
       ├─ run_extraction     → ExtractionEntry             (SQL and image tools)
       ├─ run_processing     → ProcessingClaudeSDKEntry    (workspace + Python/native tools + validated submission)
       ├─ run_analysis       → InsightEntry                (direct / focused / deep adaptive routes)
       └─ run_visualization  → render_chart / ECharts      (LLM planner + deterministic renderer)

The router holds no sub-agents of its own — each stage tool runs that route's full pipeline. Products flow automatically between stages (an extracted CSV feeds processing; a processed output folder feeds analysis or visualization).

The router classifies tasks into three categories:

  1. Out-of-scope — general questions, greetings, concepts not related to data files → answered directly
  2. Simple data tasks — head, dedup, sort, filter → handled with Bash + pandas directly
  3. Complex data tasks — multi-step transforms, extraction, analysis, visualization → routed to stages

A deep thinking mode (deep_thinking=True in DataFlowSystem.run_async()) forces all data tasks to route through stages, while still allowing direct answers for out-of-scope questions.

Layout

.
├── src/
│   └── tableflow/
│       ├── core/            # shared data loading, profiling, path & config helpers
│       ├── system/          # unified system layer (router agent + stage registry + prompts)
│       ├── extraction/      # SQL extraction route
│       ├── processing/      # table processing route
│       ├── analysis/        # heterogeneous-data insight route
│       └── visualization/   # chart rendering route (matplotlib + ECharts)
├── webapp/                  # chat-style web UI (FastAPI backend + React frontend)
├── examples/                # quickstart, end-to-end smoke check
└── docker/analysis/         # optional Docker image for analysis code execution

The Python distribution is dataflow-table-sdk. Import it as tableflow.

Install

Create a Python 3.11+ environment (conda or venv), then install in editable mode. Core and optional dependencies are declared in pyproject.toml.

git clone https://github.com/OpenDCAI/DataFlow-Table_SDK.git
cd DataFlow-Table_SDK

conda create -n tableflow python=3.11 -y && conda activate tableflow   # or use a venv

pip install -e .                   # core runtime deps
pip install -e ".[vision]"         # optional: image extraction / image analysis

Configure

Set the URL and key for your Anthropic-compatible endpoint.

export DF_API_URL="https://your-gateway.example"
export DF_API_KEY="<YOUR_API_KEY>"

Use DF_MODEL to select a model supported by your provider. Set DF_ROUTER_MODEL if you want a separate model for the router.

export DF_MODEL="<your-model-id>"
# export DF_ROUTER_MODEL="<your-router-model-id>"

You can also set these variables in a private config.local.py at the repository root. Git ignores this file, and import tableflow loads it after the tracked config.py template.

# config.local.py
import os

os.environ["DF_API_URL"] = "https://your-gateway.example"
os.environ["DF_API_KEY"] = "<YOUR_API_KEY>"

For SQL extraction with only an Anthropic-compatible endpoint, set EXTRACTION_PIPELINE_MODE=claude. The default hybrid mode also needs an OpenAI-compatible endpoint and key, configured through EXTRACTION_FAST_API_BASE and EXTRACTION_FAST_API_KEY.

Verify the install

From the repository root, run this query on the included CSV to check the SDK locally without model credentials.

python - <<'PY'
from tempfile import TemporaryDirectory

from tableflow.extraction import ExtractionEntry

with TemporaryDirectory() as work_dir:
    result = ExtractionEntry(base_savedir=work_dir).extract(
        question="List names and scores of users who scored at least 5.",
        datasource_specs=[{
            "name": "input",
            "type": "csv",
            "connection_config": {"file_path": "examples/minimal/input.csv"},
        }],
        declared_sql="SELECT name, score FROM input WHERE score >= 5 ORDER BY score DESC",
        declared_fallback=False,
    )
    assert result["success"], result.get("error")
    assert result["query_result_data"]["row_count"] == 3
    print("TableFlow extracted 3 rows locally.")
PY

The smoke test makes API calls. Complete Configure and Processing setup before running it.

python examples/smoke_all.py

Quickstart (unified system)

Run from the repository root after configuring a model endpoint. The multi-stage example also uses Processing setup.

from pathlib import Path

from tableflow import DataFlowSystem

sample = Path("examples/minimal/input.csv").resolve(strict=True)
system = DataFlowSystem()

result = system.run(
    "Summarize the scores and identify the highest-scoring person.",
    {"data_folder": str(sample.parent)},
)
print(result["final_text"])

# Ask the router to combine extraction, processing, and analysis.
result = system.run(
    "Pull names and scores from the CSV, keep score >= 5, then summarize the result.",
    {
        "question": "name and score for each row",
        "datasource_specs": [
            {
                "name": "input",
                "type": "csv",
                "connection_config": {"file_path": str(sample)},
            }
        ],
    },
)

print(result["final_text"])

Batch (parallel) tasks

import asyncio
from pathlib import Path

from tableflow import DataFlowSystem

data_folder = str(Path("examples/minimal").resolve(strict=True))
system = DataFlowSystem()
tasks = [
    {"task": "Find the highest score.", "inputs": {"data_folder": data_folder}},
    {"task": "Calculate the average score.", "inputs": {"data_folder": data_folder}},
]
results = asyncio.run(system.run_batch(tasks, max_concurrency=4))

run_batch runs independent tasks concurrently with a semaphore cap; a failing task yields an error dict rather than aborting the batch.

Extending with a new stage

Register a StageSpec — no router code changes needed:

from tableflow import DataFlowSystem, default_registry, StageSpec

async def my_runner(inputs, context):
    ...
    return {"success": True}

registry = default_registry()
registry.register(StageSpec(
    name="export", description="Export results to a warehouse.",
    runner=my_runner, produces="export", consumes="insights",
))
system = DataFlowSystem(registry=registry)

Using a single route directly

from tableflow.extraction import ExtractionEntry
from tableflow.processing import ProcessingClaudeSDKEntry, ProcessingTask
from tableflow.analysis import InsightEntry

Processing setup

Processing requires Python 3.11+ and pip install -e ".[processing]". Use pip install -e ".[processing,native]" for native operations on Windows with desktop Excel. Model-backed Processing also requires explicit opt-in, a budget ledger, a positive credit cap, and provider rates. See the Processing guide for the required settings.

Web UI (chat)

A chat-style web frontend in webapp/ for uploading files, describing tasks in natural language, and downloading results.

pip install -e ".[web]"
python -m uvicorn webapp.backend.main:app --host 127.0.0.1 --port 8001

Open http://127.0.0.1:8001 to use the prebuilt frontend. The Web UI is a local single-user tool without authentication. See Frontend development to run Vite in a separate terminal.

Routes

Each route has its own README with pipeline details, agent/tool breakdowns, and configuration knobs:

Contributing

See CONTRIBUTING.md for dev setup, project layout, and how to register a new stage.

License

Apache License 2.0 — see LICENSE.

About

No description, website, or topics provided.

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages