Skip to main content

Tangy 1-line Hugging Face & OpenRouter inference wrapper

Project description

🍋 Zest (zst1)

The Tangiest 1-Line AI Inference Wrapper for Python.

Why write 20 lines of boilerplate when you can just squeeze a model into one? zest provides a unified interface for local Hugging Face pipelines and cloud-based OpenRouter LLMs.

🚀 Quick Start

import zest

# Local Hugging Face (Sentiment Analysis)
print(zest.run("hf/distilbert-base-uncased-finetuned-sst-2-english", "I love this!"))

# Cloud OpenRouter (GPT-4o)
# Requires os.environ['OPENROUTER_API_KEY']
print(zest.run("or/openai/gpt-4o", "Explain quantum physics in one sentence."))

🛠 Available Routes

1. Hugging Face (hf/ prefix)

Uses the transformers library to run models locally on your CPU/GPU.

  • Usage: zest.run("hf/your-model-id", "input")
  • Restricted Models: If you need to access gated models (like Llama), set your token:
    import os
    os.environ['HUGGINGFACE_TOKEN'] = 'your_token'
    # OR pass it directly:
    zest.run("hf/meta-llama/Llama-2-7b", "Hi", hf_token="your_token")
    

2. OpenRouter (or/ prefix)

Access 200+ LLMs via the OpenRouter API.

  • Usage: zest.run("or/google/gemini-pro-1.5", "Hello world")
  • Requirement: Set os.environ['OPENROUTER_API_KEY'].

🛡️ Error Handling (The 'Damn' Level)

zest doesn't just crash. It catches:

  • Prefix Errors: Forgot hf/ or or/? It'll tell you.
  • Auth Errors: Missing API keys for cloud or restricted models are clearly reported.
  • Network Errors: Timeouts and HTTP errors from OpenRouter are intercepted.
  • Model Errors: Invalid Hugging Face model IDs return specific config errors.

🧪 Snippets

Multi-turn Logic (Simplified):

model = "or/anthropic/claude-3-opus"
prompt = "Tell me a joke."
result = zest.run(model, prompt)
print(f"AI: {result}")

Batch Processing (Local):

inputs = ["Bad product", "Best ever! "]
results = [zest.run("hf/distilbert-base-uncased-finetuned-sst-2-english", x) for x in inputs]

Stay Tangy. 🍋

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

zst1-0.0.4.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

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

zst1-0.0.4-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file zst1-0.0.4.tar.gz.

File metadata

  • Download URL: zst1-0.0.4.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for zst1-0.0.4.tar.gz
Algorithm Hash digest
SHA256 27004fc2af434442fb89bd84ff130d4beaeb382c14e8850876f0718bb4aab6fa
MD5 641c1fdac908a4f90c8b6bccf5311e8f
BLAKE2b-256 e601ce04e14768f84ccd4fe53a3b79743694215e4e20dbc3fd11124737892c07

See more details on using hashes here.

File details

Details for the file zst1-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: zst1-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for zst1-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c61d48b2a67e04c4561b470b6dd3603a2632b78cfa83cf6473b274866a748bf1
MD5 180c877efad492cf482d1d197169b2b7
BLAKE2b-256 521fd334fd7293205b811ab8a346980ff316ab8db6f1c666712a9cf26a683906

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