refactor: replace vision stub with cf-vision shim (cf-core#36)
circuitforge_core.vision.router now re-exports VisionRouter from the standalone cf-vision repo. Existing imports unchanged; falls back to a helpful ImportError stub if cf-vision is not installed. Closes cf-core#36
This commit is contained in:
parent
48d33a78ef
commit
5766fa82ab
1 changed files with 23 additions and 16 deletions
|
|
@ -1,19 +1,26 @@
|
|||
"""
|
||||
Vision model router — stub until v0.2.
|
||||
Supports: moondream2 (local) and Claude vision API (cloud).
|
||||
"""
|
||||
# circuitforge_core/vision/router.py — shim
|
||||
#
|
||||
# The vision module has been extracted to the standalone cf-vision repo.
|
||||
# This shim re-exports VisionRouter so existing imports continue to work.
|
||||
# New code should import directly from cf_vision:
|
||||
#
|
||||
# from cf_vision.router import VisionRouter
|
||||
# from cf_vision.models import ImageFrame
|
||||
#
|
||||
# Install: pip install -e ../cf-vision
|
||||
from __future__ import annotations
|
||||
|
||||
try:
|
||||
from cf_vision.router import VisionRouter # noqa: F401
|
||||
from cf_vision.models import ImageFrame # noqa: F401
|
||||
except ImportError:
|
||||
# cf-vision not installed — fall back to the stub so products that don't
|
||||
# need vision yet don't hard-fail on import.
|
||||
class VisionRouter: # type: ignore[no-redef]
|
||||
"""Stub — install cf-vision: pip install -e ../cf-vision"""
|
||||
|
||||
class VisionRouter:
|
||||
"""Routes image analysis requests to local or cloud vision models."""
|
||||
|
||||
def analyze(self, image_bytes: bytes, prompt: str) -> str:
|
||||
"""
|
||||
Analyze image_bytes with the given prompt.
|
||||
Raises NotImplementedError until vision backends are wired up.
|
||||
"""
|
||||
raise NotImplementedError(
|
||||
"VisionRouter is not yet implemented. "
|
||||
"Photo analysis requires a Paid tier or local vision model (v0.2+)."
|
||||
def analyze(self, image_bytes: bytes, prompt: str = "", task: str = "document"):
|
||||
raise ImportError(
|
||||
"cf-vision is not installed. "
|
||||
"Run: pip install -e ../cf-vision"
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue