Metadata-Version: 2.4
Name: fw-nodes-ai
Version: 0.0.1a1
Summary: AI/LLM nodes for Flowire workflow automation
License-Expression: MIT
Requires-Python: >=3.13
Requires-Dist: flowire-sdk>=0.0.1a1
Requires-Dist: httpx>=0.26.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Description-Content-Type: text/markdown

# Flowire AI Nodes

AI/LLM nodes for Flowire workflow automation. This package provides nodes for sending prompts to LLM providers and getting responses.

## Installation

```bash
cd flowire-app/backend
uv pip install fw-nodes-ai
```

Then enable the package in your `.env` file:

```bash
# .env (comma-separated list)
INSTALLED_NODE_PACKAGES=fw-nodes-core,fw-nodes-ai
```

## Included Nodes

| Node | Description |
|------|-------------|
| `LLM Prompt` | Send a prompt to an LLM and get a response |

## Supported Providers

| Provider | API Style | Auth |
|----------|-----------|------|
| OpenAI | OpenAI | API key |
| Anthropic | Anthropic | API key |
| Google Gemini | OpenAI-compatible | API key |
| Groq | OpenAI-compatible | API key |
| Mistral | OpenAI-compatible | API key |
| Ollama | OpenAI-compatible | None (local) |
| Custom | OpenAI-compatible | API key |

## Usage Example

### LLM Prompt

Send a prompt to any supported LLM provider:

```python
# Node configuration:
{
    "credential_id": "your-llm-credential",
    "model": "gpt-4o",
    "system_prompt": "You are a helpful assistant.",
    "user_message": "Summarize this text: {{previous-node.output}}",
    "temperature": 0.7,
    "response_format": "text"
}

# Outputs:
# - response: LLM response (text string or parsed JSON object)
# - model: Model that was used
# - usage: Token usage statistics (prompt_tokens, completion_tokens, total_tokens)
# - finish_reason: Why the LLM stopped generating
# - rate_limits: Provider rate limit status
```

### JSON Mode

Request structured JSON output:

```python
{
    "credential_id": "your-llm-credential",
    "model": "gpt-4o",
    "user_message": "Extract the name and age from: John is 30 years old",
    "temperature": 0.0,
    "response_format": "json",
    "json_schema": {
        "name": "extraction",
        "strict": true,
        "schema": {
            "type": "object",
            "properties": {
                "name": {"type": "string"},
                "age": {"type": "integer"}
            },
            "required": ["name", "age"]
        }
    }
}

# Output response will be a parsed JSON object:
# {"name": "John", "age": 30}
```

## Development

```bash
# Install with dev dependencies
uv sync --all-extras

# Run linter
just check

# Run tests
just test
```

## Project Structure

```
fw-nodes-ai/
├── fw_nodes_ai/
│   ├── __init__.py
│   ├── credentials.py
│   ├── providers.py
│   └── nodes/
│       ├── __init__.py
│       └── llm_prompt.py
├── tests/
├── pyproject.toml
└── README.md
```

## License

This project is licensed under the [MIT License](LICENSE).
