Metadata-Version: 2.4
Name: fleetfluid
Version: 0.1.1
Summary: AI Agent Functions for ETL Processing
Home-page: https://github.com/vossmoos/fleetfluid
Author: Andrey Olishchuk
Author-email: Your Name <bobroe.web@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/vossmoos/fleetfluid
Project-URL: Repository, https://github.com/vossmoos/fleetfluid
Project-URL: Issues, https://github.com/vossmoos/fleetfluid/issues
Keywords: ai,etl,data-processing,text-processing,pydantic-ai,llm
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Text Processing
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pydantic-ai
Requires-Dist: pydantic
Requires-Dist: httpx
Provides-Extra: dev
Requires-Dist: pytest>=6.0; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# FleetFluid

**AI Agent Functions for Data Processing**

FleetFluid is a Python library that simplifies data transformation by letting you use AI-powered functions without writing them from scratch. Instead of building functions, you invoke ready-made, agent-based functions that handle tasks like text cleaning, information extraction, translation, and more—just by specifying what you need in natural language.

Powered by PydanticAI, FleetFluid offers a streamlined interface for embedding intelligent data processing into your ETL workflows, without the overhead of managing complex AI infrastructure.

## Installation

```bash
pip install fleetfluid
```

## Quick Start

```python
import fleetfluid

# Initialize with your preferred model
fleetfluid.init(model="openai:gpt-4")

# Use AI agent functions in your ETL pipeline
text = "this is sample text with bad grammar"
corrected = fleetfluid.ai("write it grammatically correct", text)
print(corrected)  # "This is sample text with correct grammar."

# Translate text
spanish = fleetfluid.ai("translate to Spanish", "Hello, how are you?")
print(spanish)  # "Hola, ¿cómo estás?"

# Extract information
data = "John Smith, Software Engineer, works at Tech Corp since 2020"
structured = fleetfluid.ai("extract as JSON with name, role, company, year", data)
print(structured)  # {"name": "John Smith", "role": "Software Engineer", ...}

# Label text with structured output
text = "The new iPhone 15 Pro Max features advanced camera capabilities"
labels = ["technology", "business", "sports", "entertainment", "health"]
result = fleetfluid.label(text, labels)
print(result.label)  # "technology"
print(result.confidence)  # 0.95
print(result.reasoning)  # "The text discusses iPhone features, which is clearly technology-related"

# Multi-label classification
text = "Apple's quarterly earnings show strong growth in services and hardware sales"
result = fleetfluid.label(text, labels, multiple=True)
print(result.labels)  # ["technology", "business"]
print(result.confidence_scores)  # {"technology": 0.9, "business": 0.85}
```

## Configuration

```python
import fleetfluid

# Basic initialization
fleetfluid.init(model="openai:gpt-4")

# With additional PydanticAI configuration
fleetfluid.init(
    model="anthropic:claude-sonnet-4-20250514",
    temperature=0.7,
    max_tokens=1000
)
```

## API Reference

### `fleetfluid.init(model, **kwargs)`

Initialize FleetFluid with model configuration.

- **model** (str): Model identifier (e.g., "openai:gpt-4")
- **kwargs**: Additional configuration passed to PydanticAI agents

### `fleetfluid.ai(prompt, data)`

Apply AI transformation to data using the given prompt.

- **prompt** (str): Instruction for the AI
- **data** (str): Input data to transform
- **Returns** (str): Transformed data

### `fleetfluid.label(text, labels, multiple=False)`

Label text using AI agent with structured output.

- **text** (str): Input text to label
- **labels** (list[str]): List of possible labels to choose from
- **multiple** (bool): If True, select multiple labels; if False, select single best label (default: False)
- **Returns**: 
  - `SingleLabelResult` (when `multiple=False`): Contains `label`, `confidence`, and `reasoning`
  - `MultipleLabelResult` (when `multiple=True`): Contains `labels`, `confidence_scores`, and `reasoning`

## Use Cases

### Data Cleaning & Standardization
```python
# Fix inconsistent formatting
clean_data = fleetfluid.ai("standardize this address format", "123 main st apt 4b")

# Normalize names
normalized = fleetfluid.ai("convert to proper case", "JOHN SMITH")
```

### Text Processing
```python
# Summarize content
summary = fleetfluid.ai("summarize in 2 sentences", long_text)

# Extract entities
entities = fleetfluid.ai("extract all company names as a list", business_text)
```

### Data Enrichment
```python
# Categorize data
category = fleetfluid.ai("categorize this product: electronics, clothing, books", product_name)

# Generate missing data
description = fleetfluid.ai("write a product description", product_title)

# Structured labeling
text = "Customer complaint about delayed delivery"
labels = ["positive", "negative", "neutral", "urgent"]
result = fleetfluid.label(text, labels)
print(f"Sentiment: {result.label} (confidence: {result.confidence})")

# Multi-label classification
text = "Product review: Great quality but expensive"
result = fleetfluid.label(text, ["positive", "negative", "price", "quality"], multiple=True)
print(f"Labels: {result.labels}")
```

## Error Handling

```python
try:
    result = fleetfluid.ai("translate to French", text)
except RuntimeError as e:
    print(f"AI processing failed: {e}")
```

## API Token Configuration

FleetFluid uses PydanticAI for AI model interactions and relies on standard environment variables for API authentication. You need to set up API tokens for your chosen model provider before using FleetFluid.

### Setting Up API Tokens

#### OpenAI Models
For OpenAI models like `"openai:gpt-4"` or `"openai:gpt-3.5-turbo"`:

```bash
export OPENAI_API_KEY="your-openai-api-key-here"
```

#### Anthropic Models
For Anthropic models like `"anthropic:claude-sonnet-4-20250514"`:

```bash
export ANTHROPIC_API_KEY="your-anthropic-api-key-here"
```

#### Google Models
For Google models like `"gemini-2.5-pro"`:

```bash
export GOOGLE_API_KEY="your-google-api-key-here"
```

#### Groq Models
For Groq models like `"groq:llama-70b"`:

```bash
export GROQ_API_KEY="your-groq-api-key-here"
```

#### Google VertexAI Models
For Google VertexAI models like `"vertexai:gemini-2.5-pro"`:

```bash
# Set Google Cloud credentials
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/your/service-account-key.json"

# Or set project ID and use Application Default Credentials
export GOOGLE_CLOUD_PROJECT="your-project-id"
```

### Environment Variable Setup

You can set environment variables in several ways:

#### 1. Terminal/Shell
```bash
# For current session
export OPENAI_API_KEY="sk-your-key-here"

# For permanent setup (add to ~/.bashrc, ~/.zshrc, etc.)
echo 'export OPENAI_API_KEY="sk-your-key-here"' >> ~/.bashrc
source ~/.bashrc
```

#### 2. Python Environment
```python
import os
os.environ["OPENAI_API_KEY"] = "sk-your-key-here"

import fleetfluid
fleetfluid.init(model="openai:gpt-4")
```

#### 3. .env File (if supported by your setup)
Create a `.env` file in your project root:
```
OPENAI_API_KEY=sk-your-key-here
ANTHROPIC_API_KEY=sk-ant-your-key-here
```

## Requirements

- Python 3.8+
- PydanticAI
- An API key for your chosen model provider (see API Token Configuration above)

## License

MIT License. See LICENSE file for details.
