54 lines
1.2 KiB
Python
54 lines
1.2 KiB
Python
|
|
"""LLM JSON 边界契约(Memoir agents)。"""
|
|||
|
|
|
|||
|
|
from __future__ import annotations
|
|||
|
|
|
|||
|
|
from pydantic import AliasChoices, BaseModel, ConfigDict, Field
|
|||
|
|
|
|||
|
|
|
|||
|
|
class ClassificationOutput(BaseModel):
|
|||
|
|
category: str = ""
|
|||
|
|
|
|||
|
|
|
|||
|
|
class MemoirTitleOutput(BaseModel):
|
|||
|
|
title: str = ""
|
|||
|
|
|
|||
|
|
|
|||
|
|
class FidelityOutput(BaseModel):
|
|||
|
|
model_config = ConfigDict(populate_by_name=True)
|
|||
|
|
|
|||
|
|
pass_: bool = Field(default=True, alias="pass")
|
|||
|
|
reason: str | None = None
|
|||
|
|
|
|||
|
|
|
|||
|
|
class StateExtractionOutput(BaseModel):
|
|||
|
|
detected_stage: str = ""
|
|||
|
|
slots: dict[str, str] = Field(default_factory=dict)
|
|||
|
|
emotion: str | None = None
|
|||
|
|
is_new_chapter: bool | None = None
|
|||
|
|
|
|||
|
|
|
|||
|
|
class BatchPhase1SegmentRowOut(BaseModel):
|
|||
|
|
id: str
|
|||
|
|
detected_stage: str = ""
|
|||
|
|
slots: dict[str, str] = Field(default_factory=dict)
|
|||
|
|
chapter_category: str = Field(
|
|||
|
|
default="",
|
|||
|
|
validation_alias=AliasChoices("chapter_category", "category"),
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
model_config = ConfigDict(extra="ignore", populate_by_name=True)
|
|||
|
|
|
|||
|
|
|
|||
|
|
class BatchPhase1LLMOutput(BaseModel):
|
|||
|
|
segments: list[BatchPhase1SegmentRowOut]
|
|||
|
|
|
|||
|
|
|
|||
|
|
__all__ = [
|
|||
|
|
"BatchPhase1LLMOutput",
|
|||
|
|
"BatchPhase1SegmentRowOut",
|
|||
|
|
"ClassificationOutput",
|
|||
|
|
"FidelityOutput",
|
|||
|
|
"MemoirTitleOutput",
|
|||
|
|
"StateExtractionOutput",
|
|||
|
|
]
|