feat(ai-service): introduce Provider Interface for LLM + OCR (Issue #…#685
Open
Richardkingz2019 wants to merge 1 commit into
Open
feat(ai-service): introduce Provider Interface for LLM + OCR (Issue #…#685Richardkingz2019 wants to merge 1 commit into
Richardkingz2019 wants to merge 1 commit into
Conversation
…ulsefy#615) Introduces a clean abstract contract and reference implementations for swapping LLM and OCR backends without changing route logic. New package app/ai-service/services/providers/ with: * Abstract contracts: LLMProvider, OCRProvider and supporting dataclasses (LLMRequest/LLMResponse/OCRRequest/OCRProviderOutput) plus a hierarchy of ProviderError exceptions. * Reference implementations: OpenAIProvider, GroqProvider, FixtureLLMProvider (LLM side); TesseractOCRProvider, FixtureOCRProvider (OCR side). * LLMProviderRegistry and OCRProviderSelector helpers that resolve the right provider(s) for a request based on settings. * build_default_llm_registry / build_default_ocr_selector factory functions used by the verification services. Refactored consumers: * services/humanitarian_verification.py routes all LLM calls through the registry. Circuit-breaker logic, prompt fallback and JSON parsing stay in the service because they are part of the verification policy. Legacy string-dispatch hooks (_provider_attempt_order / _call_provider / _get_model_for_provider / _call_openai / _call_groq / _call_test) are preserved so the existing test suite continues to work without modifications. * services/ocr.py keeps preprocessing + field detection in the service (these are policy decisions) and delegates the actual OCR engine call to the selected OCRProvider through _run_tesseract (which now routes to TesseractOCRProvider or FixtureOCRProvider). Tests: * New tests/test_provider_interface.py pins the contract end-to-end: abstract type checks, exception hierarchy, reference providers, registry attempt order, selector logic, and a full route integration via /v1/ai/humanitarian/verify with a swapped registry.
|
Someone is attempting to deploy a commit to the Cedarich's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@Richardkingz2019 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
@Richardkingz2019 fix workflow |
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.
…615)
Introduces a clean abstract contract and reference implementations for swapping LLM and OCR backends without changing route logic.
New package app/ai-service/services/providers/ with:
Refactored consumers:
Tests:
closes #615