-
Notifications
You must be signed in to change notification settings - Fork 2
feat(docs): add CLAUDE.md for project guidance and development instru… #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # CLAUDE.md | ||
|
|
||
| This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. | ||
|
|
||
| ## Project Overview | ||
|
|
||
| VLM Run Python SDK - Official Python SDK for the VLM Run API platform. Provides structured data extraction from images, documents, videos, and audio using vision-language models. | ||
|
|
||
| ## Development Commands | ||
|
|
||
| ```bash | ||
| # Install for development | ||
| pip install -e ".[test]" | ||
|
|
||
| # Run all tests | ||
| pytest -sv tests | ||
|
|
||
| # Run a single test file | ||
| pytest -sv tests/test_client.py | ||
|
|
||
| # Run a specific test | ||
| pytest -sv tests/test_client.py::test_client_init | ||
|
|
||
| # Lint and format code | ||
| make lint | ||
| # Or directly: pre-commit run --all-files | ||
|
|
||
| # Build package | ||
| make dist | ||
| ``` | ||
|
|
||
| ## Architecture | ||
|
|
||
| ### Client Structure (`vlmrun/client/`) | ||
|
|
||
| The SDK uses a resource-based pattern where `VLMRun` is the main client that exposes specialized resources: | ||
|
|
||
| - **VLMRun** (`client.py`) - Main entry point, initializes all resources on construction after validating the API key via `/health` endpoint | ||
| - **APIRequestor** (`base_requestor.py`) - Handles HTTP requests with retry logic (tenacity), timeout handling, and error mapping to custom exception types | ||
| - **Resource Classes** - Each API domain has its own resource class: | ||
| - `ImagePredictions`, `DocumentPredictions`, `VideoPredictions`, `AudioPredictions` (`predictions.py`) | ||
| - `Agent` (`agent.py`) - Also provides OpenAI-compatible completions interface via `client.agent.completions` | ||
| - `Files`, `Hub`, `Models`, `Datasets`, `Finetuning`, `Feedback`, `Executions`, `Artifacts` | ||
|
|
||
| ### Predictions Pattern | ||
|
|
||
| `FilePredictions(route)` is a factory function that creates prediction classes for document/audio/video. These inherit from `SchemaCastMixin` which handles automatic type casting of responses to Pydantic models based on domain schemas. | ||
|
|
||
| Key methods: `generate()` (use domain), `execute()` (use named model), `schema()` (auto-generate schema). | ||
|
|
||
| ### CLI Structure (`vlmrun/cli/`) | ||
|
|
||
| Built with Typer. Entry point is `vlmrun/cli/cli.py`. Subcommands are in `vlmrun/cli/_cli/`: | ||
| - `chat.py` - Interactive chat with Orion agent | ||
| - `config.py` - API key and base URL configuration | ||
| - `generate.py`, `files.py`, `predictions.py`, `hub.py`, `models.py` | ||
|
|
||
| ### Type System (`vlmrun/client/types.py`) | ||
|
|
||
| All API responses are typed with Pydantic models. Key types: | ||
| - `PredictionResponse` - Standard response for all predictions | ||
| - `GenerationConfig` - Configuration for generation (prompt, response_model, json_schema, temperature, etc.) | ||
| - `MarkdownDocument/MarkdownPage/MarkdownTable` - Structured document extraction results | ||
|
|
||
| ### Common Utilities (`vlmrun/common/`) | ||
|
|
||
| - `image.py` - Image encoding, EXIF handling | ||
| - `video.py` - Video frame extraction | ||
| - `pdf.py` - PDF processing | ||
| - `utils.py` - Helper functions like `remote_image()` | ||
|
|
||
| ## Configuration | ||
|
|
||
| Environment variables: | ||
| - `VLMRUN_API_KEY` - API key (required) | ||
| - `VLMRUN_BASE_URL` - Override default API URL (default: `https://api.vlm.run/v1`) | ||
| - `VLMRUN_CACHE_DIR` - Override cache directory (default: `~/.vlmrun/cache`) | ||
|
|
||
| ## Optional Dependencies | ||
|
|
||
| Install based on needed functionality: | ||
| - `pip install vlmrun[cli]` - CLI with Typer/Rich | ||
| - `pip install vlmrun[video]` - Video processing (numpy) | ||
| - `pip install vlmrun[doc]` - PDF processing (pypdfium2) | ||
| - `pip install vlmrun[openai]` - OpenAI SDK for chat completions API | ||
| - `pip install vlmrun[all]` - All optional dependencies | ||
|
|
||
| ## Testing | ||
|
|
||
| Tests use pytest with fixtures in `tests/conftest.py`. Tests require `VLMRUN_API_KEY` environment variable. Test files mirror the client structure (e.g., `test_predictions.py`, `test_agent.py`). | ||
|
|
||
| ## Code Style | ||
|
|
||
| Uses ruff for linting and black for formatting. Pre-commit hooks enforce style on commit. Configuration is in `pyproject.toml` and `.pre-commit-config.yaml`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| __version__ = "0.5.2" | ||
| __version__ = "0.5.3" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better clarity and consistency with the client's properties, it would be helpful to list the resource properties using their actual
snake_casenames as they are accessed on theVLMRunclient instance (e.g.,client.fine_tuning). The current list usesPascalCase, which are the class names, andFinetuningis inconsistent with the property namefine_tuning.Using property names will make it clearer for anyone (including an AI assistant) how to access these resources.