Skip to main content

AnyAI - One-liner AI for everyone. A unified gateway to AI capabilities.

Project description

anyai

The unified gateway to the any* AI ecosystem — every AI task, one import.

PyPI Python License

anyai is the umbrella meta-package for the any* ecosystem. It provides a single import and a unified one-liner API for computer vision, OCR, LLMs, NLP, tabular ML, and deployment. The core package ships with zero heavy dependencies and includes useful rule-based implementations out of the box, while every sister package (anycv, anyocr, anyllm, anynlp, anyml, tableai, traincv, anydeploy, anyrobo) can be unlocked as an optional extra.

Built by Viet-Anh Nguyen at NRL.ai.

Why anyai?

  • One-liner API — Get started in 3 lines of code for any AI task
  • Plugin architecture — Discovers and delegates to installed any* sister packages automatically
  • Local-first — Built-in rule-based methods work offline with no downloads
  • Minimal core deps — Only pillow and pyyaml required; heavy ML is optional
  • Production-ready — Type hints, tests, dataclass result types, graceful degradation

Installation

pip install anyai

For optional features:

pip install anyai[cv]        # + anycv (object detection, classification)
pip install anyai[ocr]       # + anyocr (text extraction from images)
pip install anyai[llm]       # + anyllm (LLM abstraction layer)
pip install anyai[nlp]       # + anynlp (NER, sentiment, summarization)
pip install anyai[ml]        # + anyml (AutoML for tabular data)
pip install anyai[table]     # + tableai (DataFrame profiling & cleaning)
pip install anyai[deploy]    # + anydeploy (ONNX/TFLite export + serving)
pip install anyai[robo]      # + anyrobo (voice agent framework)
pip install anyai[all]       # everything

Python 3.8+ supported (tested on 3.8, 3.9, 3.10, 3.11, 3.12, 3.13)

Quick Start

import anyai

# 1. Text summarization (built-in, zero deps — extractive sentence scoring)
summary = anyai.summarize(
    "Long article text here...",
    max_sentences=3,
)
print(summary)

# 2. Sentiment analysis (built-in AFINN-style lexicon with negation handling)
sentiment = anyai.sentiment("I absolutely love this library!")
print(sentiment.label, sentiment.score)   # "positive" 0.87

# 3. Keyword extraction (built-in TF-IDF-like scoring)
keywords = anyai.keywords("Machine learning is transforming software.", top_k=5)

# 4. Image metadata (built-in via Pillow)
info = anyai.image_info("photo.jpg")
print(info.width, info.height, info.format)

# 5. Delegated tasks (require sister packages)
labels = anyai.detect("photo.jpg")        # needs anyai[cv]
text   = anyai.ocr("scan.png")            # needs anyai[ocr]
reply  = anyai.chat("Explain RAG in 1 line.")  # needs anyai[llm]

Models & Methods

Built-in (zero-dependency) implementations

Task Method Notes
summarize Extractive scoring: sentence position + word-frequency + length penalty Pure Python, no models downloaded
sentiment AFINN-style lexicon lookup with negation windows (not good -> negative) ~2,500 scored English words baked in
keywords TF-IDF-like term weighting with English stopword removal No external corpus required
image_info Pillow Image.open() + EXIF parsing Returns ImageMetadata dataclass
pipeline Chain built-in and sister-package ops into a DAG Lazy evaluation
config YAML + environment variable resolver Respects ANYAI_* env vars

Delegated backends (via optional extras)

When you call a task that requires a sister package, anyai dynamically imports the registered backend:

  • anyai.detect / classify / segment -> anycv (YOLOv8 / MobileNetV2 / DeepLabV3 via ONNX Runtime)
  • anyai.ocr -> anyocr (Surya / EasyOCR / PaddleOCR / Tesseract / Vision-LLM)
  • anyai.chat / embed / tools -> anyllm (Ollama / llama.cpp / OpenAI / Anthropic / HF)
  • anyai.ner / classify_text -> anynlp
  • anyai.automl -> anyml (sklearn + XGBoost/LightGBM)
  • anyai.profile_df / clean_df -> tableai
  • anyai.export / serve -> anydeploy

API Reference

Function Purpose
anyai.summarize(text, max_sentences=3) Extractive summary
anyai.sentiment(text) SentimentResult(label, score)
anyai.keywords(text, top_k=10) Ranked keyword list
anyai.image_info(path) ImageMetadata dataclass
anyai.detect(image, model="yolov8n") Object detection (requires [cv])
anyai.classify(image) Image classification (requires [cv])
anyai.ocr(image) Text extraction (requires [ocr])
anyai.chat(prompt, model="auto") LLM completion (requires [llm])
anyai.Pipeline([...]) Chain tasks across packages
anyai.Config.from_yaml(path) Load project-wide config

CLI Usage

anyai summarize article.txt --sentences 5
anyai sentiment "I really enjoyed the film"
anyai keywords document.txt --top 10
anyai info photo.jpg
anyai version

Examples

Build a pipeline that spans packages

from anyai import Pipeline

# Each step delegates to the right sister package (if installed)
pipe = Pipeline([
    ("ocr",       {"backend": "auto"}),    # anyocr
    ("summarize", {"max_sentences": 3}),   # built-in
    ("sentiment", {}),                     # built-in
])

result = pipe.run("scanned_report.png")
print(result["summary"], result["sentiment"])

Use config-driven defaults

# anyai.yaml
llm:
  provider: ollama
  model: llama3.1:8b
cv:
  model: yolov8n
import anyai

# All subsequent calls inherit these defaults
anyai.Config.load("anyai.yaml")
anyai.chat("Hello")   # routed to ollama/llama3.1:8b

Graceful degradation

import anyai

# If anyllm is not installed, fall back to the built-in extractive summary
try:
    summary = anyai.summarize_llm(long_text)   # abstractive (needs anyai[llm])
except anyai.BackendNotAvailable:
    summary = anyai.summarize(long_text)       # extractive fallback (built-in)

License

MIT (c) Viet-Anh Nguyen

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

anyai-0.2.3.tar.gz (41.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anyai-0.2.3-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file anyai-0.2.3.tar.gz.

File metadata

  • Download URL: anyai-0.2.3.tar.gz
  • Upload date:
  • Size: 41.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for anyai-0.2.3.tar.gz
Algorithm Hash digest
SHA256 d5791e76d08eca10924f814384a15dc0b53d4226beb613c525f5e34e13c26b40
MD5 4f41d600f782d5507c6cbc81a1dd1d86
BLAKE2b-256 65a56ec8641d45db1e39bfb14cb498bd9844bc9022ff851a253e040703d60518

See more details on using hashes here.

File details

Details for the file anyai-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: anyai-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for anyai-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 af4132dccc573698a87f0e4183e4bff8f9a46d02c28493800197cccd677f8ffb
MD5 52823acad9d8a79c4d50333d6ad18fb7
BLAKE2b-256 69db335e078711b13f6332bbd7c1134f63542108d77137160a9e8e8139eca678

See more details on using hashes here.

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