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 @@
|
||||||
"""
|
# circuitforge_core/vision/router.py — shim
|
||||||
Vision model router — stub until v0.2.
|
#
|
||||||
Supports: moondream2 (local) and Claude vision API (cloud).
|
# 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
|
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:
|
def analyze(self, image_bytes: bytes, prompt: str = "", task: str = "document"):
|
||||||
"""Routes image analysis requests to local or cloud vision models."""
|
raise ImportError(
|
||||||
|
"cf-vision is not installed. "
|
||||||
def analyze(self, image_bytes: bytes, prompt: str) -> str:
|
"Run: pip install -e ../cf-vision"
|
||||||
"""
|
)
|
||||||
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+)."
|
|
||||||
)
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue