responses.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from typing import Any, Optional, TypeVar
  2. from uuid import UUID
  3. from pydantic import BaseModel, Field
  4. from shared.api.models.base import PaginatedR2RResult, R2RResults
  5. T = TypeVar("T")
  6. class IngestionResponse(BaseModel):
  7. message: str = Field(
  8. ...,
  9. description="A message describing the result of the ingestion request.",
  10. )
  11. task_id: Optional[UUID] = Field(
  12. None,
  13. description="The task ID of the ingestion request.",
  14. )
  15. document_id: UUID = Field(
  16. ...,
  17. description="The ID of the document that was ingested.",
  18. )
  19. class Config:
  20. json_schema_extra = {
  21. "example": {
  22. "message": "Ingestion task queued successfully.",
  23. "task_id": "c68dc72e-fc23-5452-8f49-d7bd46088a96",
  24. "document_id": "9fbe403b-c11c-5aae-8ade-ef22980c3ad1",
  25. }
  26. }
  27. class UpdateResponse(BaseModel):
  28. message: str = Field(
  29. ...,
  30. description="A message describing the result of the ingestion request.",
  31. )
  32. task_id: Optional[UUID] = Field(
  33. None,
  34. description="The task ID of the ingestion request.",
  35. )
  36. document_ids: list[UUID] = Field(
  37. ...,
  38. description="The ID of the document that was ingested.",
  39. )
  40. class Config:
  41. json_schema_extra = {
  42. "example": {
  43. "message": "Update task queued successfully.",
  44. "task_id": "c68dc72e-fc23-5452-8f49-d7bd46088a96",
  45. "document_ids": ["9fbe403b-c11c-5aae-8ade-ef22980c3ad1"],
  46. }
  47. }
  48. class VectorIndexResponse(BaseModel):
  49. index: dict[str, Any]
  50. class VectorIndicesResponse(BaseModel):
  51. indices: list[VectorIndexResponse]
  52. WrappedIngestionResponse = R2RResults[IngestionResponse]
  53. WrappedMetadataUpdateResponse = R2RResults[IngestionResponse]
  54. WrappedUpdateResponse = R2RResults[UpdateResponse]
  55. WrappedVectorIndexResponse = R2RResults[VectorIndexResponse]
  56. WrappedVectorIndicesResponse = PaginatedR2RResult[VectorIndicesResponse]