Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/scripts/verify_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
schema Verify YAML files match their JSON schemas
"""

import yaml
import requests
import sys
import json
import sys
from pathlib import Path

import requests
import yaml

try:
from jsonschema import validate, ValidationError
from jsonschema import ValidationError, validate

HAS_JSONSCHEMA = True
except ImportError:
Expand Down Expand Up @@ -172,7 +173,7 @@ def verify_schemas(repo_root, authors, registry):
if authors_schema_path.exists():
print("Checking authors.yaml against schema...")
try:
with open(authors_schema_path, "r") as f:
with open(authors_schema_path) as f:
authors_schema = json.load(f)
validate(instance=authors, schema=authors_schema)
print(" ✓ authors.yaml matches schema")
Expand All @@ -190,7 +191,7 @@ def verify_schemas(repo_root, authors, registry):
if registry_schema_path.exists():
print("\nChecking registry.yaml against schema...")
try:
with open(registry_schema_path, "r") as f:
with open(registry_schema_path) as f:
registry_schema = json.load(f)
validate(instance=registry, schema=registry_schema)
print(" ✓ registry.yaml matches schema")
Expand Down Expand Up @@ -227,11 +228,11 @@ def main():
registry = None

if command in ["all", "authors", "registry", "schema"]:
with open(authors_path, "r") as f:
with open(authors_path) as f:
authors = yaml.safe_load(f)

if command in ["all", "paths", "registry", "schema"]:
with open(registry_path, "r") as f:
with open(registry_path) as f:
registry = yaml.safe_load(f)

# Run verifications based on command
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.12
rev: v0.14.6
hooks:
- id: ruff
- id: ruff-check
types_or: [python, pyi, jupyter]
args: ['--fix']
- id: ruff-format
Expand Down
102 changes: 102 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Claude Cookbooks

A collection of Jupyter notebooks and Python examples for building with the Claude API.

## Quick Start

```bash
# Install dependencies
uv sync --all-extras

# Install pre-commit hooks
uv run pre-commit install

# Set up API key
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY
```

## Development Commands

```bash
make format # Format code with ruff
make lint # Run linting
make check # Run format-check + lint
make fix # Auto-fix issues + format
make test # Run pytest
```

Or directly with uv:

```bash
uv run ruff format . # Format
uv run ruff check . # Lint
uv run ruff check --fix . # Auto-fix
uv run pre-commit run --all-files
```

## Code Style

- **Line length:** 100 characters
- **Quotes:** Double quotes
- **Formatter:** Ruff

Notebooks have relaxed rules for mid-file imports (E402), redefinitions (F811), and variable naming (N803, N806).

## Git Workflow

**Branch naming:** `<username>/<feature-description>`

**Commit format (conventional commits):**
```
feat(scope): add new feature
fix(scope): fix bug
docs(scope): update documentation
style: lint/format
```

## Key Rules

1. **API Keys:** Never commit `.env` files. Always use `os.environ.get("ANTHROPIC_API_KEY")`

2. **Dependencies:** Use `uv add <package>` or `uv add --dev <package>`. Never edit pyproject.toml directly.

3. **Models:** Use current Claude models. Check docs.anthropic.com for latest versions.
- Sonnet: `claude-sonnet-4-5-20250929`
- Haiku: `claude-haiku-4-5-20251001`

4. **Notebooks:**
- Keep outputs in notebooks (intentional for demonstration)
- One concept per notebook
- Test that notebooks run top-to-bottom without errors

5. **Quality checks:** Run `make check` before committing. Pre-commit hooks validate formatting and notebook structure.

## Slash Commands

These commands are available in Claude Code and CI:

- `/notebook-review` - Review notebook quality
- `/model-check` - Validate Claude model references
- `/link-review` - Check links in changed files

## Project Structure

```
capabilities/ # Core Claude capabilities (RAG, classification, etc.)
skills/ # Advanced skill-based notebooks
tool_use/ # Tool use and integration patterns
multimodal/ # Vision and image processing
misc/ # Batch processing, caching, utilities
third_party/ # Pinecone, Voyage, Wikipedia integrations
extended_thinking/ # Extended reasoning patterns
scripts/ # Validation scripts
.claude/ # Claude Code commands and skills
```

## Adding a New Cookbook

1. Create notebook in the appropriate directory
2. Add entry to `registry.yaml` with title, description, path, authors, categories
3. Add author info to `authors.yaml` if new contributor
4. Run quality checks and submit PR
99 changes: 50 additions & 49 deletions capabilities/classification/evaluation/prompts.py
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
from vectordb import VectorDB
import textwrap

from vectordb import VectorDB

vectordb = VectorDB()
# Load the vector database
vectordb.load_db()

categories = """<category>
categories = """<category>
<label>Billing Inquiries</label>
<content> Questions about invoices, charges, fees, and premiums Requests for clarification on billing statements Inquiries about payment methods and due dates
</content>
</category>
<category>
<content> Questions about invoices, charges, fees, and premiums Requests for clarification on billing statements Inquiries about payment methods and due dates
</content>
</category>
<category>
<label>Policy Administration</label>
<content> Requests for policy changes, updates, or cancellations Questions about policy renewals and reinstatements Inquiries about adding or removing coverage options
</content>
</category>
<category>
<label>Claims Assistance</label>
<content> Questions about the claims process and filing procedures Requests for help with submitting claim documentation Inquiries about claim status and payout timelines
</content>
</category>
<category>
<label>Coverage Explanations</label>
<content> Questions about what is covered under specific policy types Requests for clarification on coverage limits and exclusions Inquiries about deductibles and out-of-pocket expenses
</content>
</category>
<category>
<label>Quotes and Proposals</label>
<content> Requests for new policy quotes and price comparisons Questions about available discounts and bundling options Inquiries about switching from another insurer
</content>
</category>
<category>
<label>Account Management</label>
<content> Requests for login credentials or password resets Questions about online account features and functionality Inquiries about updating contact or personal information
</content>
</category>
<category>
<label>Billing Disputes</label>
<content> Complaints about unexpected or incorrect charges Requests for refunds or premium adjustments Inquiries about late fees or collection notices
</content>
</category>
<category>
<label>Claims Disputes</label>
<content> Complaints about denied or underpaid claims Requests for reconsideration of claim decisions Inquiries about appealing a claim outcome
</content>
</category>
<category>
<label>Policy Comparisons</label>
<content> Questions about the differences between policy options Requests for help deciding between coverage levels Inquiries about how policies compare to competitors' offerings
</content>
</category>
<category>
<label>General Inquiries</label>
<content> Questions about company contact information or hours of operation Requests for general information about products or services Inquiries that don't fit neatly into other categories
</content>
<content> Requests for policy changes, updates, or cancellations Questions about policy renewals and reinstatements Inquiries about adding or removing coverage options
</content>
</category>
<category>
<label>Claims Assistance</label>
<content> Questions about the claims process and filing procedures Requests for help with submitting claim documentation Inquiries about claim status and payout timelines
</content>
</category>
<category>
<label>Coverage Explanations</label>
<content> Questions about what is covered under specific policy types Requests for clarification on coverage limits and exclusions Inquiries about deductibles and out-of-pocket expenses
</content>
</category>
<category>
<label>Quotes and Proposals</label>
<content> Requests for new policy quotes and price comparisons Questions about available discounts and bundling options Inquiries about switching from another insurer
</content>
</category>
<category>
<label>Account Management</label>
<content> Requests for login credentials or password resets Questions about online account features and functionality Inquiries about updating contact or personal information
</content>
</category>
<category>
<label>Billing Disputes</label>
<content> Complaints about unexpected or incorrect charges Requests for refunds or premium adjustments Inquiries about late fees or collection notices
</content>
</category>
<category>
<label>Claims Disputes</label>
<content> Complaints about denied or underpaid claims Requests for reconsideration of claim decisions Inquiries about appealing a claim outcome
</content>
</category>
<category>
<label>Policy Comparisons</label>
<content> Questions about the differences between policy options Requests for help deciding between coverage levels Inquiries about how policies compare to competitors' offerings
</content>
</category>
<category>
<label>General Inquiries</label>
<content> Questions about company contact information or hours of operation Requests for general information about products or services Inquiries that don't fit neatly into other categories
</content>
</category>"""


Expand Down Expand Up @@ -154,7 +155,7 @@ def rag_chain_of_thought_classify(context: dict):

First you will think step-by-step about the problem in scratchpad tags.
You should consider all the information provided and create a concrete argument for your classification.

Respond using this format:
<response>
<scratchpad>Your thoughts and analysis go here</scratchpad>
Expand Down
5 changes: 3 additions & 2 deletions capabilities/classification/evaluation/vectordb.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import json
import os
import pickle

import numpy as np
import voyageai
import pickle
import json


class VectorDB:
Expand Down
Loading
Loading