crashlens


Namecrashlens JSON
Version 1.0.0 PyPI version JSON
download
home_pageNone
SummaryCLI to detect GPT token waste from Langfuse logs
upload_time2025-07-25 09:38:44
maintainerNone
docs_urlNone
authorAditya Singh
requires_python<4.0,>=3.12
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CrashLens

**CrashLens** is a CLI tool for detecting token waste and inefficiencies in GPT API logs. It analyzes your logs for patterns like fallback failures, retry loops, and overkill model usage, and generates a detailed Markdown report (`report.md`) with cost breakdowns and actionable insights.

---

## ๐Ÿš€ Features
- Detects token waste patterns: fallback failures, retry loops, overkill/short completions
- Supports OpenAI, Anthropic, and Langfuse-style logs (JSONL)
- Robust error handling for malformed or incomplete logs
- Configurable model pricing and thresholds via `pricing.yaml`
- Generates a professional Markdown report (`report.md`) after every scan
- 100% local: No data leaves your machine

---

## 1. Clone the Repository

Replace `<repo-link>` with the actual GitHub URL:

```sh
git clone <repo-link>
cd crashlens
```

---

## 2. Install Python & Poetry

CrashLens requires **Python 3.8+** and [Poetry](https://python-poetry.org/) for dependency management.

### MacOS
- Install Python (if not already):
  ```sh
  brew install python@3.12
  ```
- Install Poetry:
  ```sh
  curl -sSL https://install.python-poetry.org | python3 -
  # Or with Homebrew:
  brew install poetry
  ```

### Windows
- Install Python from [python.org](https://www.python.org/downloads/)
- Install Poetry:
  ```sh
  (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing | python -)
  # Or download and run the installer from the Poetry website
  ```
- Add Python and Poetry to your PATH if needed.

---

## 3. Set Up the Environment

```sh
# From the project root:
poetry install
```

This will create a virtual environment and install all dependencies.

To activate the environment (optional, for direct python usage):
- **Mac/Linux:**
  ```sh
  source $(poetry env info --path)/bin/activate
  ```
- **Windows:**
  ```sh
  .venv\Scripts\activate
  # Or
  poetry shell
  ```

---

## 4. Running CrashLens

You can run CrashLens via Poetry or as a Python module:

### Basic Scan (from file)
```sh
poetry run crashlens scan examples/retry-test.jsonl
# Or
python -m crashlens scan examples/retry-test.jsonl
```

### Demo Mode (built-in sample data)
```sh
poetry run crashlens scan --demo
```

### Scan from stdin (pipe or paste)
```sh
cat examples/retry-test.jsonl | poetry run crashlens scan --stdin
```

---

## 5. Output: The Markdown Report

After every scan, CrashLens creates or updates `report.md` in your current directory.

### Example Structure
```
# CrashLens Token Waste Report

๐Ÿงพ **Total AI Spend**: $0.123456
๐Ÿ’ฐ **Total Potential Savings**: $0.045678

| Trace ID | Model | Prompt | Completion Length | Cost | Waste Type |
|----------|-------|--------|------------------|------|------------|
| trace_001 | gpt-4 | ... | 3 | $0.00033 | Overkill |
| ...      | ...   | ...    | ...              | ...  | ...        |

## Overkill Model Usage (5 issues)
- ...

## Retry Loops (3 issues)
- ...

## Fallback Failures (2 issues)
- ...
```

---

## 6. Troubleshooting
- **File not found:** Ensure the path to your log file is correct.
- **No traces found:** Your log file may be empty or malformed.
- **Cost is $0.00:** Check that your `pricing.yaml` matches the model names in your logs.
- **Virtual environment issues:** Use `poetry run` to ensure dependencies are available.

---

## 7. Example Commands

```sh
# Scan a log file
poetry run crashlens scan examples/demo-logs.jsonl

# Use demo data
poetry run crashlens scan --demo

# Scan from stdin
cat examples/demo-logs.jsonl | poetry run crashlens scan --stdin
```

---

## 8. Support
For questions, issues, or feature requests, open an issue on GitHub or contact the maintainer.

---

Enjoy using CrashLens! ๐ŸŽฏ 


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "crashlens",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.12",
    "maintainer_email": null,
    "keywords": null,
    "author": "Aditya Singh",
    "author_email": "coding103856@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a7/e3/be2f61ec011713b3b1b5b03ff1c83e44bd73c6dc1acb639fdf13e7f41628/crashlens-1.0.0.tar.gz",
    "platform": null,
    "description": "# CrashLens\n\n**CrashLens** is a CLI tool for detecting token waste and inefficiencies in GPT API logs. It analyzes your logs for patterns like fallback failures, retry loops, and overkill model usage, and generates a detailed Markdown report (`report.md`) with cost breakdowns and actionable insights.\n\n---\n\n## \ud83d\ude80 Features\n- Detects token waste patterns: fallback failures, retry loops, overkill/short completions\n- Supports OpenAI, Anthropic, and Langfuse-style logs (JSONL)\n- Robust error handling for malformed or incomplete logs\n- Configurable model pricing and thresholds via `pricing.yaml`\n- Generates a professional Markdown report (`report.md`) after every scan\n- 100% local: No data leaves your machine\n\n---\n\n## 1. Clone the Repository\n\nReplace `<repo-link>` with the actual GitHub URL:\n\n```sh\ngit clone <repo-link>\ncd crashlens\n```\n\n---\n\n## 2. Install Python & Poetry\n\nCrashLens requires **Python 3.8+** and [Poetry](https://python-poetry.org/) for dependency management.\n\n### MacOS\n- Install Python (if not already):\n  ```sh\n  brew install python@3.12\n  ```\n- Install Poetry:\n  ```sh\n  curl -sSL https://install.python-poetry.org | python3 -\n  # Or with Homebrew:\n  brew install poetry\n  ```\n\n### Windows\n- Install Python from [python.org](https://www.python.org/downloads/)\n- Install Poetry:\n  ```sh\n  (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing | python -)\n  # Or download and run the installer from the Poetry website\n  ```\n- Add Python and Poetry to your PATH if needed.\n\n---\n\n## 3. Set Up the Environment\n\n```sh\n# From the project root:\npoetry install\n```\n\nThis will create a virtual environment and install all dependencies.\n\nTo activate the environment (optional, for direct python usage):\n- **Mac/Linux:**\n  ```sh\n  source $(poetry env info --path)/bin/activate\n  ```\n- **Windows:**\n  ```sh\n  .venv\\Scripts\\activate\n  # Or\n  poetry shell\n  ```\n\n---\n\n## 4. Running CrashLens\n\nYou can run CrashLens via Poetry or as a Python module:\n\n### Basic Scan (from file)\n```sh\npoetry run crashlens scan examples/retry-test.jsonl\n# Or\npython -m crashlens scan examples/retry-test.jsonl\n```\n\n### Demo Mode (built-in sample data)\n```sh\npoetry run crashlens scan --demo\n```\n\n### Scan from stdin (pipe or paste)\n```sh\ncat examples/retry-test.jsonl | poetry run crashlens scan --stdin\n```\n\n---\n\n## 5. Output: The Markdown Report\n\nAfter every scan, CrashLens creates or updates `report.md` in your current directory.\n\n### Example Structure\n```\n# CrashLens Token Waste Report\n\n\ud83e\uddfe **Total AI Spend**: $0.123456\n\ud83d\udcb0 **Total Potential Savings**: $0.045678\n\n| Trace ID | Model | Prompt | Completion Length | Cost | Waste Type |\n|----------|-------|--------|------------------|------|------------|\n| trace_001 | gpt-4 | ... | 3 | $0.00033 | Overkill |\n| ...      | ...   | ...    | ...              | ...  | ...        |\n\n## Overkill Model Usage (5 issues)\n- ...\n\n## Retry Loops (3 issues)\n- ...\n\n## Fallback Failures (2 issues)\n- ...\n```\n\n---\n\n## 6. Troubleshooting\n- **File not found:** Ensure the path to your log file is correct.\n- **No traces found:** Your log file may be empty or malformed.\n- **Cost is $0.00:** Check that your `pricing.yaml` matches the model names in your logs.\n- **Virtual environment issues:** Use `poetry run` to ensure dependencies are available.\n\n---\n\n## 7. Example Commands\n\n```sh\n# Scan a log file\npoetry run crashlens scan examples/demo-logs.jsonl\n\n# Use demo data\npoetry run crashlens scan --demo\n\n# Scan from stdin\ncat examples/demo-logs.jsonl | poetry run crashlens scan --stdin\n```\n\n---\n\n## 8. Support\nFor questions, issues, or feature requests, open an issue on GitHub or contact the maintainer.\n\n---\n\nEnjoy using CrashLens! \ud83c\udfaf \n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "CLI to detect GPT token waste from Langfuse logs",
    "version": "1.0.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "84e66832d16db422db254a030bc44d2a967bcd0a1f7e8ef6e8e267a2cbe0ed57",
                "md5": "1604adf6fdc70dec3a22370e1c624e50",
                "sha256": "49d163edaae1a5beaac422b1237a9e710cde8f86828d82f75692228779d5d242"
            },
            "downloads": -1,
            "filename": "crashlens-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1604adf6fdc70dec3a22370e1c624e50",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.12",
            "size": 41949,
            "upload_time": "2025-07-25T09:38:42",
            "upload_time_iso_8601": "2025-07-25T09:38:42.316521Z",
            "url": "https://files.pythonhosted.org/packages/84/e6/6832d16db422db254a030bc44d2a967bcd0a1f7e8ef6e8e267a2cbe0ed57/crashlens-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a7e3be2f61ec011713b3b1b5b03ff1c83e44bd73c6dc1acb639fdf13e7f41628",
                "md5": "9995353c6189b2a5301ef734e0e5408d",
                "sha256": "25d5caa93ea1755ae79d3847d3e7ac706cd8d7df512dc02e0ac89aa67ecabbea"
            },
            "downloads": -1,
            "filename": "crashlens-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "9995353c6189b2a5301ef734e0e5408d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.12",
            "size": 30504,
            "upload_time": "2025-07-25T09:38:44",
            "upload_time_iso_8601": "2025-07-25T09:38:44.925385Z",
            "url": "https://files.pythonhosted.org/packages/a7/e3/be2f61ec011713b3b1b5b03ff1c83e44bd73c6dc1acb639fdf13e7f41628/crashlens-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-25 09:38:44",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "crashlens"
}
        
Elapsed time: 1.03125s