Skip to main content

Ask OpenAI-compatible models about a Python object with runtime metadata and optional help() snippets.

Project description

helpit

help() is great… until it isn’t.

It often dumps a wall of documentation that:

  • isn’t tailored to your object (its current attributes, fields, shapes, dtypes, etc.)
  • isn’t tailored to your question
  • is verbose when you just want the “do this” answer

helpit flips that: it inspects the runtime object you already have, packages up safe, useful metadata (type/module/signature/fields + lightweight hints for things like pandas/torch/pathlib), and asks a small OpenAI model to answer your specific question quickly.

If the object is complex or the answer likely lives in docs, you can turn on:

  • add_documentation=True

…and helpit will grab the object’s help() output, chunk it, and attach only the most relevant snippets (picked via embeddings using intfloat/multilingual-e5-small) so the model can ground its answer.


Install

Option A: venv + editable install

python -m venv .venv
source .venv/bin/activate
pip install -e .

Option B: uv

uv sync

Quickstart

from helpit import aihelp

def scale(x, factor=2):
    return x * factor

print(aihelp(scale, "How do I use this to double a list?"))

When things get tricky: add doc snippets

Use this when you suspect the model might need extra documentation to be correct

from openai import OpenAI
from helpit import aihelp

client = OpenAI()  # expects OPENAI_API_KEY

# Example: a built-in function where you want details grounded in docs
answer = aihelp(
    len,
    "How does len behave on nested lists, and what errors should I expect?",
    model="gpt-5-mini",
    verbosity="low",
    reasoning_effort="minimal",
    max_output_tokens=250,
    add_documentation=True,
    top_k_docs=2,
    openai_client=client,
)

print(answer)

Using local OpenAI-compatible servers (Ollama, vLLM, etc.)

helpit talks to the OpenAI Responses API. Any local server that exposes a compatible /v1/responses endpoint can be used by passing a custom OpenAI client:

from openai import OpenAI
from helpit import aihelp

client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")  # Ollama example

print(
    aihelp(
        len,
        "How does len behave on a list?",
        model="llama3.2",            # whatever your server calls the model
        max_output_tokens=200,
        openai_client=client,
    )
)
  • Ollama: /v1/responses is supported in v0.13.3+ (stateless only). Use any token as api_key, set base_url to your Ollama host, and pick a local model name (e.g., llama3.2, qwen2.5).
  • vLLM: run the OpenAI-compatible server and point base_url to it; use the served model name.
  • If your backend lacks /v1/responses, upgrade or run a thin proxy that maps Responses requests to chat/completions, or fork helpit to call chat/completions directly.

Parameters

  • fn_or_value: object or callable to describe
  • question: text passed to the model
  • model: OpenAI Responses model name
  • verbosity: value for Responses API text.verbosity
  • reasoning_effort: value for Responses API reasoning.effort
  • max_output_tokens: cap for model output tokens
  • add_documentation: when True, include ranked help() passages
  • top_k_docs: maximum doc chunks to attach
  • chunk_chars: maximum characters per help() chunk
  • overlap_chars: overlap size between chunks
  • embedder: EmbeddingBackend implementation; defaults to HF multilingual-e5-small
  • openai_client: OpenAI client or stub; defaults to OpenAI()

Offline demo

python examples_usage.py

Runs two stubbed calls (no network): a basic query and a doc-enriched query using a tiny deterministic embedder.


Tests

python -m unittest -v

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

helpit-0.1.1.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

helpit-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: helpit-0.1.1.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for helpit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 dc602b6363880ef9584a2699433dcfa448af882a277579165c333d999b511f29
MD5 566b976d95d4ebab25a6efbf6d842a37
BLAKE2b-256 5ad4821c4bbde321c9d38910619808b35aeff53bbfab4ba47b099f8add561d7a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: helpit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for helpit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2f5c884654228923aeb6430575be47e00a740b61dd7e5b922ac3bb7f2a49cd82
MD5 d2281ed36d6e73df0cb7be39c712681d
BLAKE2b-256 36395d4ff8ae92155443f19ff11fedf0539655dd438a65b5d3d4020c63665d1d

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