feat(US2): image quad extraction — POST /api/v1/image/extract

- app/models/image_models.py: BBox, QuadrupleItem, ImageExtract{Request,Response}
- app/services/image_service.py: download → base64 LLM → bbox clamp → crop upload
- app/routers/image.py: POST /image/extract handler
- tests: 4 service + 3 router tests, 7/7 passing
This commit is contained in:
wh
2026-04-10 15:40:56 +08:00
parent dd8da386f4
commit 2876c179ac
10 changed files with 299 additions and 1 deletions

View File

@@ -0,0 +1,28 @@
from pydantic import BaseModel
class BBox(BaseModel):
x: int
y: int
w: int
h: int
class QuadrupleItem(BaseModel):
subject: str
predicate: str
object: str
qualifier: str | None = None
bbox: BBox
cropped_image_path: str
class ImageExtractRequest(BaseModel):
file_path: str
task_id: int
model: str | None = None
prompt_template: str | None = None
class ImageExtractResponse(BaseModel):
items: list[QuadrupleItem]