feat(ocr): add LiteLLM provider for vision LLM-based OCR#21
Merged
willgriffin merged 1 commit intomainfrom Dec 19, 2025
Merged
Conversation
Add a new OCR provider that uses vision-capable LLMs (like DeepSeek, GPT-4o) via LiteLLM-compatible API endpoints. This enables OCR through any OpenAI-compatible vision model API. Features: - Support for both simple (text-only) and structured (JSON with confidence) output modes - Environment variable configuration (HAVE_OCR_LITELLM_*) - Constructor options with precedence over environment variables - Automatic image format detection (PNG, JPEG, GIF, WebP, BMP) - Base64 encoding for API transmission - Comprehensive language support via vision LLM capabilities Configuration: - HAVE_OCR_LITELLM_BASE_URL: API endpoint (default: http://localhost:4000/v1) - HAVE_OCR_LITELLM_API_KEY: API key for authentication - HAVE_OCR_LITELLM_MODEL: Model name (default: deepseek-chat) - HAVE_OCR_LITELLM_OUTPUT_MODE: Output mode (simple|structured) Provider priority: onnx > tesseract > litellm (API-based providers last) Note: Requires @happyvertical/ai vision support. Uses local ContentPart type definitions until the updated AI package is published.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add a new OCR provider that uses vision-capable LLMs (like DeepSeek, GPT-4o) via LiteLLM-compatible API endpoints. This enables OCR through any OpenAI-compatible vision model API.
Features:
HAVE_OCR_LITELLM_*)Configuration:
HAVE_OCR_LITELLM_BASE_URL: API endpoint (default:http://localhost:4000/v1)HAVE_OCR_LITELLM_API_KEY: API key for authenticationHAVE_OCR_LITELLM_MODEL: Model name (default:deepseek-chat)HAVE_OCR_LITELLM_OUTPUT_MODE: Output mode (simple|structured)Provider priority:
onnx > tesseract > litellm(API-based providers last)Changes
src/node/litellm.ts- LiteLLM provider implementation (~500 lines)src/node/litellm.spec.ts- Comprehensive unit tests (25 tests)src/shared/factory.ts- Added provider loading and prioritysrc/shared/types.ts- AddedLiteLLMProviderOptionsinterfacesrc/index.ts- Added exports for new providerpackage.json- Added@happyvertical/aidependencyNotes
ContentParttype definitions since@happyvertical/aidoesn't export vision types yetcontentParts as any) for compatibility until AI package is updatedTest plan