Metadata-Version: 2.4
Name: kanoa
Version: 0.1.0
Summary: AI-powered interpretation of data science outputs with multi-backend support
Home-page: https://github.com/lhzn-io/kanoa
Author: Daniel Fry
Author-email: dfry@lhzn.io
Keywords: ai llm data-science analytics gemini claude openai jupyter
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
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.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib>=3.5.0
Requires-Dist: pandas>=1.3.0
Requires-Dist: pydantic>=2.0.0
Provides-Extra: gemini
Requires-Dist: google-genai>=1.0.0; extra == "gemini"
Provides-Extra: claude
Requires-Dist: anthropic>=0.40.0; extra == "claude"
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == "openai"
Provides-Extra: gcloud
Requires-Dist: google-cloud-storage>=2.0.0; extra == "gcloud"
Provides-Extra: notebook
Requires-Dist: ipython>=7.0.0; extra == "notebook"
Provides-Extra: all
Requires-Dist: google-genai>=1.0.0; extra == "all"
Requires-Dist: anthropic>=0.40.0; extra == "all"
Requires-Dist: openai>=1.0.0; extra == "all"
Requires-Dist: ipython>=7.0.0; extra == "all"
Requires-Dist: google-cloud-storage>=2.0.0; extra == "all"
Provides-Extra: backends
Requires-Dist: google-genai>=1.0.0; extra == "backends"
Requires-Dist: anthropic>=0.40.0; extra == "backends"
Requires-Dist: openai>=1.0.0; extra == "backends"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.8.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
Requires-Dist: types-setuptools; extra == "dev"
Requires-Dist: detect-secrets>=1.4.0; extra == "dev"
Requires-Dist: google-genai>=1.0.0; extra == "dev"
Requires-Dist: anthropic>=0.40.0; extra == "dev"
Requires-Dist: openai>=1.0.0; extra == "dev"
Requires-Dist: ipython>=7.0.0; extra == "dev"
Requires-Dist: google-cloud-storage>=2.0.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=7.0.0; extra == "docs"
Requires-Dist: myst-parser>=2.0.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=2.0.0; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=1.20.0; extra == "docs"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# kanoa

> **In-notebook AI interpretation of data science outputs, grounded in your project's knowledge base.**

[![Tests](https://github.com/lhzn-io/kanoa/actions/workflows/tests.yml/badge.svg)](https://github.com/lhzn-io/kanoa/actions/workflows/tests.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)

**kanoa** brings the power of a dedicated AI research assistant directly into your **Python workflows—whether in Jupyter notebooks, Streamlit apps, or automated scripts**. It programmatically interprets visualizations, tables, and results using multimodal LLMs (Gemini, Claude, OpenAI, Molmo), grounded in your project's documentation and literature. It is designed to be dropped into any data science project to provide instant, context-aware analysis.

## Features

- **Multi-Backend Support**: Seamlessly switch between Gemini, Claude, and OpenAI (including local vLLM).
- **Provider-Native Grounding**: Offloads knowledge retrieval to best-in-breed provider solutions.
- **Native Vision**: Uses multimodal capabilities to "see" complex plots and diagrams.
- **Cost Optimized**: Intelligent context caching and token usage tracking.
- **Knowledge Base**: Support for text (Markdown) and PDF knowledge bases.

## Installation

```bash
pip install kanoa
```

Or for development:

```bash
git clone https://github.com/lhzn-io/kanoa.git
cd kanoa
pip install -e .
```

## Quick Start

Check out [10 Minutes to kanoa](./examples/quickstart_10min.ipynb) for a comprehensive introduction, including local inference with Gemma 3.

### Basic Usage

```python
import matplotlib.pyplot as plt
from kanoa import AnalyticsInterpreter

# 1. Create your plot
plt.plot([1, 2, 3], [1, 4, 9])
plt.title("Growth Curve")

# 2. Initialize Interpreter (defaults to Gemini)
# Ensure GOOGLE_API_KEY is set in your environment
interpreter = AnalyticsInterpreter(backend='gemini-3')

# 3. Interpret it
result = interpreter.interpret(
    fig=plt.gcf(),
    context="Bacterial growth experiment",
    focus="Exponential phase"
)

# 4. View results (auto-displays in Jupyter)
print(result.text)
```

### Using Claude

```python
# Ensure ANTHROPIC_API_KEY is set
interpreter = AnalyticsInterpreter(backend='claude')

result = interpreter.interpret(
    fig=plt.gcf(),
    context="Sales analysis"
)
```

### Using a Knowledge Base

```python
# Point to a directory of Markdown or PDF files
interpreter = AnalyticsInterpreter(
    backend='gemini-3',
    kb_path='./docs/literature',
    kb_type='auto'  # Detects if PDFs are present
)

# The interpreter will now use the knowledge base to ground its analysis
result = interpreter.interpret(
    fig=plt.gcf(),
    context="Compare with Smith et al. 2023 results"
)
```

### Local Inference (vLLM / Gemma 3)

Use `kanoa-mlops` to host local models like Gemma 3 or Molmo:

```python
# Connect to local vLLM server (see kanoa-mlops repo)
interpreter = AnalyticsInterpreter(
    backend='openai',
    api_base='http://localhost:8000/v1',
    model='google/gemma-3-12b-it'
)

result = interpreter.interpret(
    fig=plt.gcf(),
    context="Local analysis"
)
```

## Supported Backends

| Backend | Key Features | Best For |
| :--- | :--- | :--- |
| `gemini-3` | Native PDF support, 1M context, caching | Complex analysis with PDF references |
| `claude` | Strong reasoning, vision support | General analysis, text-heavy KBs |
| `openai` | Generic OpenAI support (GPT-5.1, vLLM) | Local inference (Gemma 3), Azure OpenAI |

## API Keys

kanoa requires API keys for cloud backends. **Recommended**: Store in `~/.config/kanoa/.env`:

```bash
mkdir -p ~/.config/kanoa
echo "GOOGLE_API_KEY=your-key" > ~/.config/kanoa/.env
echo "ANTHROPIC_API_KEY=your-key" >> ~/.config/kanoa/.env
```

⚠️ **Security Note**: API keys generate costs. We recommend `keeping secrets outside of your kanoa-dev workspace,
and we include detect-secrets in our pre-commit hooks for defense-in-depth.

**For detailed setup instructions**, see:

- [Authentication Guide](./docs/source/user_guide/authentication.md) - Complete setup, security best practices
- [Get Gemini API Key](https://aistudio.google.com/apikey)
- [Get Claude API Key](https://console.anthropic.com/)

## Documentation

Full API documentation is available and built using Sphinx:

```bash
cd docs
pip install -r requirements-docs.txt
make html
```

Then open `docs/build/html/index.html` in your browser.

The API reference is auto-generated from docstrings in the source code.

## License

MIT © 2025 Long Horizon Observatory
