43 lines
1.0 KiB
Python
43 lines
1.0 KiB
Python
from abc import ABC, abstractmethod
|
|
from typing import Optional
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class VisionResult(BaseModel):
|
|
generic_name: Optional[str] = None
|
|
brand_name: Optional[str] = None
|
|
manufacturer: Optional[str] = None
|
|
specification: Optional[str] = None
|
|
|
|
|
|
class DateResult(BaseModel):
|
|
production_date: Optional[str] = None
|
|
expiry_date: Optional[str] = None
|
|
|
|
|
|
class LeafletResult(BaseModel):
|
|
indications: str
|
|
adult_dose: str
|
|
child_dose: Optional[str] = None
|
|
contraindications: str
|
|
notes: Optional[str] = None
|
|
|
|
|
|
class VisionProvider(ABC):
|
|
@abstractmethod
|
|
async def recognize_medicine(self, image_bytes: bytes) -> VisionResult:
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def recognize_dates(self, image_bytes: bytes) -> DateResult:
|
|
pass
|
|
|
|
|
|
class TextProvider(ABC):
|
|
@abstractmethod
|
|
async def summarize_leaflet(self, text: str) -> LeafletResult:
|
|
pass
|
|
|
|
@abstractmethod
|
|
async def natural_language_search(self, query: str, medicines: list) -> list:
|
|
pass |