Skip to main content

thinking-lever 🧠🔧

Structured thinking framework for LLMs — a multi-layer architecture that enhances model reasoning through pure-rule preprocessing.

pip install thinking-lever

Why?

LLMs think better when you give them a framework. But most "reasoning" systems are proprietary, model-specific, or over-engineered.

thinking-lever is zero-dependency, model-agnostic, and runs in <5ms. You can drop it into any LLM stack and immediately get better-structured reasoning.

The 5 Levers

Lever Layer What it does
L0 ContextLever Input restructuring Extracts entities, actions, constraints; scans directories; walks import graphs
L1 ThinkingLever Intent routing Detects task type (diagnose/design/optimize/predict/execute) and recommends thinking methods
L2 KnowledgeLever External knowledge Retrieves relevant facts from your knowledge base
L3 ExecutionLever Verification Runs code checks, fact validation, config validation
L4 ReflectionLever Self-check Iterative quality refinement

Quick Start

CLI

# Classify a task
thinking-lever classify "Why is my API returning 500 errors?"

# Scan context
thinking-lever scan "Audit the security of ~/myproject/"

# Verify a result
thinking-lever verify "Check syntax" "$(cat myfile.py)"

# Walk dependencies
thinking-lever deps ~/myproject/ --depth 3

# Problem mapping
thinking-lever map "Design a microservice architecture"

# Self-check
thinking-lever reflect "Here is my answer..."

Python API

from thinking_lever import classify_task, format_injection, context_scan

# L1: Classify
result = classify_task("Rewrite this module to be more efficient")
print(result["pattern"])         # "optimize"
print(result["method"])          # "constraint_analysis"

# L0: Scan
ctx = context_scan("Fix the bug in src/handler.py")
print(ctx["entities"])           # ["file:src/handler.py", ...]
print(ctx["actions"])            # ["repair"]
print(ctx["risk_zones"])         # ["Modification: backup first"]

# Inject into prompt
injection = format_injection(result)
enhanced_prompt = f"{injection}\n\n{user_message}"

Middleware Integration

from thinking_lever import LeverMiddleware

middleware = LeverMiddleware(
    enable_l0=True,
    enable_l1=True,
)

# In your kernel's pre_process:
def pre_process(user_message):
    enriched = middleware.process(user_message)
    return enriched  # Use this as your LLM input

A/B Test Results

In a real-world code audit scenario across 4 tasks:

Metric Without With Lever Improvement
Response time baseline 4.7x faster ⚡ structured prep avoids back-and-forth
Tool utilization 0% 91% LLM uses available tools correctly
Qualitative verbose, unfocused concise, precise focused on what matters

Design Philosophy

  1. Pure rules, no LLM overhead — every lever is <5ms
  2. Zero external dependencies — no numpy, no torch, no network calls
  3. Model-agnostic — works with any LLM (GPT, Claude, open-source, local)
  4. Incremental adoption — use 1 lever or all 5, middleware adapter or direct call
  5. Framework-independent — use with LangChain, custom kernels, or CLI

Requirements

  • Python 3.8+

License

MIT

Metadata

Release files for thinking-lever 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for thinking-lever 0.1.0
File Size Uploaded Provenance Actions
thinking_lever-0.1.0.tar.gz 24.0 kB Without provenance Details for thinking_lever-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thinking-lever 0.1.0
File Interpreter ABI Platform Actions
thinking_lever-0.1.0-py3-none-any.whl Python 3 none any Details for thinking_lever-0.1.0-py3-none-any.whl

Total release size: 47.9 kB

Release files / thinking_lever-0.1.0.tar.gz

Download URL thinking_lever-0.1.0.tar.gz
Size 24.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2196753291806577cc7a2051dcbffafdb5392337ad68e26c95e8a64895c95de4
BLAKE2b-256 checksum
How to use checksums
ee5f7b971dacad31736695362aeb2844e720969a3878ca809e38ce7daae805a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / thinking_lever-0.1.0-py3-none-any.whl

Download URL thinking_lever-0.1.0-py3-none-any.whl
Size 23.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8184d4900e8ab8b86577cfd4bc3b944c1e3f3cd14c59382273ecc9114187a20
BLAKE2b-256 checksum
How to use checksums
b28f989a2b33c623176832fc13db5d74592526fc62bdaee1d2523bacc1181080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Security for thinking-lever 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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