refactor: replace vision stub with cf-vision shim (cf-core#36)
Some checks failed
CI / test (push) Has been cancelled
Mirror / mirror (push) Has been cancelled

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:
pyr0ball 2026-04-06 17:59:05 -07:00
parent 48d33a78ef
commit 5766fa82ab

View file

@ -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"
)