Skip to main content

render-lab-tasks-llm

Provider-agnostic LLM tasks for Render Workflows. Version 0.1.1 implements all 13 registered tasks. Version 0.1.0 contained only classification and summarization.

Install from PyPI with Python 3.12+:

pip install render-lab-tasks-llm==0.1.1

Import app, classify, classify_impl, summarize, and summarize_impl from render_lab_tasks_llm.tasks. Combine pack apps with Workflows.from_workflows. Run wrapped tasks with await ctx.run(classify, input); inject LlmDeps(chat=...) into the raw implementations for tests or custom task wrappers.

Contracts

classify accepts text, labels (objects with name and optional description), optional maxLabels (default 3), model, and ledger. It returns labels, optional reasoning, resolved model, and optional usage. Unknown/non-string labels are removed, duplicates are removed before capping, and malformed model JSON yields an empty label list, matching TypeScript. This is prompt-based classification, not a guarantee of semantic correctness.

summarize accepts text, optional instructions, maxWords (default 120), model, and ledger. It returns trimmed summary, resolved model, and optional usage. The word limit is a prompt target, not hard truncation.

Missing or null optional defaults behave like the TS implementation. Python additionally rejects negative, boolean, and nonintegral maxLabels/maxWords before calling a provider. Zero is valid. Optional result keys are omitted when unavailable. Unknown model prices do not become zero-dollar estimates.

Providers and environment

Credentials and configuration are read when a task runs, never during imports.

Variable Purpose
LLM_MODEL Default provider-prefixed model; otherwise anthropic/claude-opus-4-8, matching the TS snapshot
OPENAI_API_KEY Direct openai/ models, such as openai/gpt-4o-mini
ANTHROPIC_API_KEY Direct anthropic/ models
GEMINI_API_KEY Direct google/ or gemini/ models through Google's OpenAI-compatible endpoint
GOOGLE_GENERATIVE_AI_API_KEY Fallback Google key; OpenAI keys are never used for direct Google requests
LLM_BASE_URL Explicit OpenAI-compatible gateway; preserves the full model identifier
LLM_API_KEY Preferred key for gateways and direct OpenAI; falls back to OPENAI_API_KEY
REDIS_URL Required only for a nonempty ledger without an injected cost-ledger port
LLM_PRICING JSON price overrides keyed by provider-prefixed model; values contain inputUsdPerMTok and optional outputUsdPerMTok
LLM_COST_LEDGER_TTL_SECONDS TTL of at least one second; default 172800, rounded down

The default model and estimated pricing table are copied from the pinned TS snapshot, not a claim of current pricing or availability. Override LLM_MODEL for your account. The example explicitly uses openai/gpt-4o-mini.

Retries, usage, and cost tracking

Provider calls stream internally and assemble their text before returning JSON. Direct OpenAI uses max_completion_tokens; gateways/Google use max_tokens. Official SDK and HTTP retries are disabled; Render owns five retries with a 2000 ms base delay and 2x backoff. Clients close after each call.

Usage includes available input/output token counts and an estimated dollar cost when known. Output accounting preserves the TS max(completion, total-prompt) rule. Estimates ignore caching discounts and price tiers; they are not invoices.

A nonempty ledger appends a JSON cost record to Redis list llm:cost:<ledger> with TTL, compatible with the TS format. Invalid ledger configuration fails before provider spend. Pricing failures without a ledger and append/cleanup failures after spend warn without failing the task, avoiding rebilling solely to repair observability. Inject CostLedgerPort to use another store. The default Redis adapter also disables client retries.

Complete task surface

The pack also exports chat_turn (llm.chat), complete, extract, extract_strict, translate, moderate, rerank, embed, load_skill, open_cost_ledger, and cost_report, with their injectable raw implementations. with_ledger(ctx, ledger) binds the ledger while dispatching durable child runs. Chat/completion preserve stopReason so callers can detect truncated output.

LLM_EMBED_MODEL overrides the embedding default. SKILLS_PATH changes installed skill search directories. Skills load text only from GitHub, URLs, vendored files, or installed names; they never execute scripts. REDIS_URL is required only for cost-ledger IO; LLM_COST_LEDGER_TTL_SECONDS controls record expiry. Structured output uses forced tools; OpenAI-compatible calls use a non-streaming request so Gemini tool calls survive its different finish-reason behavior. Google embeddings use Google credentials, fixing the TS adapter's accidental OpenAI-key selection (tracked as a deliberate difference in ADR-0019).

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

render_lab_tasks_llm-0.1.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

render_lab_tasks_llm-0.1.1-py3-none-any.whl (30.2 kB view details)

Uploaded Python 3

File details

Details for the file render_lab_tasks_llm-0.1.1.tar.gz.

File metadata

  • Download URL: render_lab_tasks_llm-0.1.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for render_lab_tasks_llm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c23632b8652f816aad86f7ee60e94457e3f38d5a4058ba95ee3091ea000e20af
MD5 b712e4cf7bbfe08f415f2bd1ca375d8c
BLAKE2b-256 32dca4b968ea6d27968932a6a865a9a2c280420ce8134aec66220b37ff8f47e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for render_lab_tasks_llm-0.1.1.tar.gz:

Publisher: publish.yml on render-lab/render-tasks-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file render_lab_tasks_llm-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for render_lab_tasks_llm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2001ee4381e211c55fd729d22d933ca1d71838134b1c081566cbfbb8fbc98e38
MD5 08b9d7557544b3266a9a7579fbcac6d2
BLAKE2b-256 366bb7f470dd2870363f2d9ce2be5ef6fe13498a453c3e395230f055087c8e9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for render_lab_tasks_llm-0.1.1-py3-none-any.whl:

Publisher: publish.yml on render-lab/render-tasks-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page