ell - The Language Model Programming Library

raw JSON →
0.0.17 verified Sat May 09 auth: no python

ell is a Python library for programming language models (LMs) with a functional, composable API. It provides decorators for defining LM prompts, supports multiple model providers (OpenAI, Anthropic, etc.), and includes tools for tracing and versioning. Current version 0.0.17, actively developed with weekly releases.

pip install ell-ai
error ImportError: cannot import name 'SimpleModel' from 'ell'
cause Trying to import SimpleModel directly from ell instead of ell.simple.
fix
Use from ell.simple import SimpleModel or access via ell.simple.SimpleModel.
error RuntimeError: ell.init() must be called before using any models
cause Forgetting to call ell.init() before defining prompts.
fix
Add ell.init(api_key='sk-...') at the top of your script, preferably using environment variables.
error TypeError: __call__() missing 1 required positional argument: 'name'
cause Calling a prompt function without the required arguments (the ones defined in the function signature).
fix
Pass the required arguments: hello(name='World').
breaking In version 0.0.15+, the API for initializing ell changed from `ell.init(api_key=...)` to requiring explicit model provider setup. Older code using `ell.init()` without arguments will fail.
fix Use `ell.init(api_key='...')` or configure providers via `ell.config`.
deprecated The `ell.llm` decorator is deprecated and will be removed in 0.1.0. Use `ell.simple` or `ell.complex` instead.
fix Replace `@ell.llm` with `@ell.simple` for single-turn prompts or `@ell.complex` for multi-turn.
gotcha Prompt functions must return a string; returning a dict or list will cause a TypeError. The decorator expects a plain string output.
fix Ensure the decorated function returns a string. Use f-strings or string formatting.

Initialize ell, define a prompt with @ell.simple, and call it.

import ell
import os

# Initialize ell with an API key
api_key = os.environ.get('OPENAI_API_KEY', '')
ell.init(api_key=api_key)

# Define a simple prompt
@ell.simple(model="gpt-4", temperature=0.7)
def hello(name: str):
    """You are a helpful assistant. Say hello to {name}."""
    return f"Hello, {name}!"

# Run the prompt
response = hello("World")
print(response)