+18


![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)

![autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)




FFXN
GitHub
yyh
盐粒 Yanli
autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Tianle
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Yunlu Wen
zyssyz123
Claude Opus 4.7
chariri
Asuka Minato
Copilot Autofix powered by AI
Nian
非法操作
Carmen Fernández Ruiz
wangxiaolei
QuantumGhost
L1nSn0w
Evan
Escape0707
Jingyi
Amr Sherif
ZHOU ZHICHEN
unknown
JzoNg
Xiyuan Chen
-LAN-
107bba0116
Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: EvanYao826 <155432245+EvanYao826@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> Co-authored-by: 盐粒 Yanli <yanli@dify.ai> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Tianle <40735546+Tianlel@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Yunlu Wen <yunlu.wen@dify.ai> Co-authored-by: zyssyz123 <916125788@qq.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: chariri <w@chariri.moe> Co-authored-by: Asuka Minato <i@asukaminato.eu.org> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Nian <11332799+Lillian68@users.noreply.github.com> Co-authored-by: 非法操作 <hjlarry@163.com> Co-authored-by: Carmen Fernández Ruiz <279459669+zeus1959@users.noreply.github.com> Co-authored-by: wangxiaolei <fatelei@gmail.com> Co-authored-by: QuantumGhost <obelisk.reg+git@gmail.com> Co-authored-by: L1nSn0w <l1nsn0w@qq.com> Co-authored-by: Evan <2869018789@qq.com> Co-authored-by: Escape0707 <tothesong@gmail.com> Co-authored-by: Jingyi <jingyi.qi@dify.ai> Co-authored-by: Amr Sherif <140330826+amr-sheriff@users.noreply.github.com> Co-authored-by: ZHOU ZHICHEN <118870511+zhuiguangzhe2003@users.noreply.github.com> Co-authored-by: unknown <EI05187@apwx.com> Co-authored-by: JzoNg <jzongcode@gmail.com> Co-authored-by: Xiyuan Chen <52963600+GareArc@users.noreply.github.com> Co-authored-by: -LAN- <laipz8200@outlook.com>
97 lines
2.2 KiB
Python
97 lines
2.2 KiB
Python
from datetime import datetime
|
|
from typing import Any
|
|
|
|
from pydantic import field_validator
|
|
|
|
from fields.base import ResponseModel
|
|
from libs.helper import to_timestamp
|
|
|
|
|
|
class HitTestingQuery(ResponseModel):
|
|
content: str
|
|
|
|
|
|
class HitTestingDocument(ResponseModel):
|
|
id: str
|
|
data_source_type: str
|
|
name: str
|
|
doc_type: str | None
|
|
doc_metadata: Any | None
|
|
|
|
@field_validator("data_source_type", "doc_type", mode="before")
|
|
@classmethod
|
|
def _normalize_enum_fields(cls, value: Any) -> Any:
|
|
return _normalize_enum(value)
|
|
|
|
|
|
class HitTestingSegment(ResponseModel):
|
|
id: str
|
|
position: int
|
|
document_id: str
|
|
content: str
|
|
sign_content: str | None
|
|
answer: str | None
|
|
word_count: int
|
|
tokens: int
|
|
keywords: list[str]
|
|
index_node_id: str | None
|
|
index_node_hash: str | None
|
|
hit_count: int
|
|
enabled: bool
|
|
disabled_at: int | None
|
|
disabled_by: str | None
|
|
status: str
|
|
created_by: str
|
|
created_at: int
|
|
indexing_at: int | None
|
|
completed_at: int | None
|
|
error: str | None
|
|
stopped_at: int | None
|
|
document: HitTestingDocument
|
|
|
|
@field_validator("disabled_at", "created_at", "indexing_at", "completed_at", "stopped_at", mode="before")
|
|
@classmethod
|
|
def _normalize_timestamp(cls, value: datetime | int | None) -> int | None:
|
|
return to_timestamp(value)
|
|
|
|
@field_validator("status", mode="before")
|
|
@classmethod
|
|
def _normalize_enum_fields(cls, value: Any) -> Any:
|
|
return _normalize_enum(value)
|
|
|
|
|
|
class HitTestingChildChunk(ResponseModel):
|
|
id: str
|
|
content: str
|
|
position: int
|
|
score: float
|
|
|
|
|
|
class HitTestingFile(ResponseModel):
|
|
id: str
|
|
name: str
|
|
size: int
|
|
extension: str
|
|
mime_type: str
|
|
source_url: str
|
|
|
|
|
|
class HitTestingRecord(ResponseModel):
|
|
segment: HitTestingSegment
|
|
child_chunks: list[HitTestingChildChunk]
|
|
score: float | None
|
|
tsne_position: Any | None
|
|
files: list[HitTestingFile]
|
|
summary: str | None
|
|
|
|
|
|
class HitTestingResponse(ResponseModel):
|
|
query: HitTestingQuery
|
|
records: list[HitTestingRecord]
|
|
|
|
|
|
def _normalize_enum(value: Any) -> Any:
|
|
if isinstance(value, str) or value is None:
|
|
return value
|
|
return getattr(value, "value", value)
|