Skip to main content

Call-site harvester: scan OpenAI call sites, record real traffic, emit site profiles

Project description

nabla — OpenAI call-site harvester

nabla finds the OpenAI call sites in a Python repo, records real (prompt, completion) traffic for one of them, and emits a single self-contained site profile (site_profile.json) describing that call site: prompt template + slots, resolved output JSON Schema, sampling parameters, recorded examples, an inferred goal with difficulty dimensions, and a cost/latency baseline.

The profile is the handoff artifact for training a small, cheap replacement model for that one call site — everything downstream codes against the profile, never against your repo.

Install

pip install nabla-cli
# or, isolated:
pipx install nabla-cli

Requires Python ≥ 3.11.

Quickstart

# 1. Find call sites (pure static analysis — no network, no API key)
nabla scan path/to/repo

# 2. Record real traffic for one site, driven by sample inputs
#    (JSONL lines of {"input_slots": {...}} matching the site's function kwargs)
nabla record path/to/repo --site my_function --samples samples.jsonl --out recorded.jsonl

# 3. Assemble + validate the profile (one LLM call for goal inference)
nabla profile path/to/repo --site my_function --examples recorded.jsonl --out site_profile.json

What gets detected

scan classifies every chat.completions.create / beta...parse call by verifiability: json_schema and pydantic_parse sites are supported harvest targets; tool_call, json_object_no_schema, and free_text sites are detected and reported but not harvested. Streaming, multi-turn, vision, and n>1 sites are flagged unsupported. Generic wrapper functions are expanded to their callers; functions that own their prompt template are kept as the site.

Environment variables

Variable Purpose
OPENAI_API_KEY Default upstream for record (auth passthrough).
NABLA_UPSTREAM_BASE_URL Record through any OpenAI-compatible stand-in oracle instead.
NABLA_UPSTREAM_API_KEY Key for the stand-in oracle.
NABLA_UPSTREAM_MODEL Rewrite the model for the stand-in only (the target repo's own model still lands in the profile).
NABLA_RECORD_DELAY_MS Pacing between samples for rate-limited upstreams (default 0).
NABLA_SAMPLE_TIMEOUT Per-sample subprocess timeout in seconds (default 300).
GEMINI_API_KEY Key for the default goal-inference provider (Gemini free tier).
NABLA_INDUCE_BASE_URL / NABLA_INDUCE_API_KEY_ENV / NABLA_INDUCE_MODEL Swap the goal-inference provider/model.

Notes

  • record runs the site's enclosing function in a subprocess per sample, with OPENAI_BASE_URL pointed at a local recording proxy. If the target's tests mock the SDK, the proxy path reports zero traffic explicitly instead of writing an empty profile.
  • Recorded prompts/completions are real data from your repo and leave the machine only via the goal-inference call. Review before sharing profiles.

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

nabla_cli-0.1.0.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

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

nabla_cli-0.1.0-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file nabla_cli-0.1.0.tar.gz.

File metadata

  • Download URL: nabla_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for nabla_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d118e086cf07a0433102c4d26ef64a8d0a84d2445a9dbf8d5d274b25327dbb84
MD5 c2e99086562954eb8c227932a8b4cae8
BLAKE2b-256 29a0b1b56e2f7264981d6fb35c6756702973b9ab255377782ab36ebfe394a134

See more details on using hashes here.

File details

Details for the file nabla_cli-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nabla_cli-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.6

File hashes

Hashes for nabla_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d34bfd2c2c5b4f609c7cd41adcdf7cf5983779c07558079372482caaafddba09
MD5 2601e87726ce3b903c1b27b5048484d4
BLAKE2b-256 5f7db37b8af0cc0c000c0001812c024237704b7163dfdb46ecc134dfc99d89da

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