schemas.py 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. from pydantic import BaseModel
  2. def to_lower_camel(string: str) -> str:
  3. tokens = [
  4. token.capitalize() if i > 0 else token
  5. for i, token in enumerate(string.split("_"))
  6. ]
  7. return "".join(tokens)
  8. class TextModelRequest(BaseModel):
  9. text: str
  10. class TextResponse(BaseModel):
  11. __root__: str
  12. class MessageResponse(BaseModel):
  13. message: str
  14. class TagResponse(BaseModel):
  15. __root__: list[str]
  16. class Embedding(BaseModel):
  17. __root__: list[float]
  18. class EmbeddingResponse(BaseModel):
  19. __root__: Embedding
  20. class BoundingBox(BaseModel):
  21. x1: int
  22. y1: int
  23. x2: int
  24. y2: int
  25. class Face(BaseModel):
  26. image_width: int
  27. image_height: int
  28. bounding_box: BoundingBox
  29. score: float
  30. embedding: Embedding
  31. class Config:
  32. alias_generator = to_lower_camel
  33. allow_population_by_field_name = True
  34. class FaceResponse(BaseModel):
  35. __root__: list[Face]