2026-02-03 10:59:00 +09:00
|
|
|
from __future__ import annotations
|
2024-02-06 13:21:13 +08:00
|
|
|
|
2026-02-03 10:59:00 +09:00
|
|
|
from datetime import datetime
|
2026-08-25 10:54:14 +00:00
|
|
|
from typing import Annotated
|
2023-12-18 13:10:05 +08:00
|
|
|
|
2026-08-25 10:54:14 +00:00
|
|
|
from pydantic import Field, WithJsonSchema, field_validator
|
2026-04-07 16:05:38 +03:00
|
|
|
|
|
|
|
|
from fields.base import ResponseModel
|
2026-05-14 19:34:31 +09:00
|
|
|
from libs.helper import to_timestamp
|
2025-08-25 09:26:54 +08:00
|
|
|
|
2026-08-25 10:54:14 +00:00
|
|
|
UUIDString = Annotated[str, WithJsonSchema({"format": "uuid", "type": "string"})]
|
|
|
|
|
Int64 = Annotated[int, WithJsonSchema({"format": "int64", "type": "integer"})]
|
|
|
|
|
|
2025-08-25 09:26:54 +08:00
|
|
|
|
2026-02-03 10:59:00 +09:00
|
|
|
class Annotation(ResponseModel):
|
2026-08-25 10:54:14 +00:00
|
|
|
id: UUIDString
|
2026-02-03 10:59:00 +09:00
|
|
|
question: str | None = None
|
|
|
|
|
answer: str | None = Field(default=None, validation_alias="content")
|
|
|
|
|
hit_count: int | None = None
|
2026-08-25 10:54:14 +00:00
|
|
|
created_at: Int64 | None = None
|
2026-02-03 10:59:00 +09:00
|
|
|
|
|
|
|
|
@field_validator("created_at", mode="before")
|
|
|
|
|
@classmethod
|
|
|
|
|
def _normalize_created_at(cls, value: datetime | int | None) -> int | None:
|
2026-05-14 19:34:31 +09:00
|
|
|
return to_timestamp(value)
|
2026-02-03 10:59:00 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnnotationList(ResponseModel):
|
|
|
|
|
data: list[Annotation]
|
|
|
|
|
has_more: bool
|
|
|
|
|
limit: int
|
|
|
|
|
total: int
|
|
|
|
|
page: int
|
|
|
|
|
|
|
|
|
|
|
2026-07-02 13:43:58 +09:00
|
|
|
class AnnotationJobStatusResponse(ResponseModel):
|
2026-08-25 10:54:14 +00:00
|
|
|
job_id: UUIDString
|
|
|
|
|
job_status: str
|
2026-07-02 13:43:58 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnnotationJobStatusDetailResponse(AnnotationJobStatusResponse):
|
|
|
|
|
error_msg: str = ""
|
|
|
|
|
|
|
|
|
|
|
2026-02-03 10:59:00 +09:00
|
|
|
class AnnotationExportList(ResponseModel):
|
|
|
|
|
data: list[Annotation]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnnotationHitHistory(ResponseModel):
|
|
|
|
|
id: str
|
|
|
|
|
source: str | None = None
|
|
|
|
|
score: float | None = None
|
|
|
|
|
question: str | None = None
|
|
|
|
|
created_at: int | None = None
|
|
|
|
|
match: str | None = Field(default=None, validation_alias="annotation_question")
|
|
|
|
|
response: str | None = Field(default=None, validation_alias="annotation_content")
|
|
|
|
|
|
|
|
|
|
@field_validator("created_at", mode="before")
|
|
|
|
|
@classmethod
|
|
|
|
|
def _normalize_created_at(cls, value: datetime | int | None) -> int | None:
|
2026-05-14 19:34:31 +09:00
|
|
|
return to_timestamp(value)
|
2026-02-03 10:59:00 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class AnnotationHitHistoryList(ResponseModel):
|
|
|
|
|
data: list[AnnotationHitHistory]
|
|
|
|
|
has_more: bool
|
|
|
|
|
limit: int
|
|
|
|
|
total: int
|
|
|
|
|
page: int
|