2026-04-02 16:36:35 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from enum import Enum
|
2026-04-03 16:56:47 +08:00
|
|
|
from typing import Any, Literal
|
2026-04-02 16:36:35 +08:00
|
|
|
|
2026-04-07 18:43:34 +08:00
|
|
|
from pydantic import BaseModel, ConfigDict, Field
|
2026-04-02 16:36:35 +08:00
|
|
|
|
|
|
|
|
from schemas.agent.ui_hints import UiHintsPayload
|
2026-04-06 01:28:10 +08:00
|
|
|
from schemas.domain.divination import DerivedDivinationData
|
2026-04-02 16:36:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class RunStatus(str, Enum):
|
|
|
|
|
SUCCESS = "success"
|
|
|
|
|
FAILED = "failed"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ToolStatus(str, Enum):
|
|
|
|
|
SUCCESS = "success"
|
|
|
|
|
FAILURE = "failure"
|
|
|
|
|
PARTIAL = "partial"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ErrorInfo(BaseModel):
|
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
|
|
|
|
|
|
code: str
|
|
|
|
|
message: str
|
|
|
|
|
retryable: bool = False
|
|
|
|
|
details: dict[str, Any] | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ToolAgentOutput(BaseModel):
|
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
|
|
|
|
|
|
tool_name: str
|
|
|
|
|
tool_call_id: str
|
|
|
|
|
tool_call_args: dict[str, Any] | None = None
|
|
|
|
|
status: ToolStatus
|
|
|
|
|
result: str
|
|
|
|
|
error: ErrorInfo | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WorkerAgentOutputLite(BaseModel):
|
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
|
|
|
|
|
|
status: RunStatus = RunStatus.SUCCESS
|
2026-04-06 01:28:10 +08:00
|
|
|
sign_level: Literal["上上签", "中上签", "中下签", "下下签"]
|
2026-04-03 16:56:47 +08:00
|
|
|
conclusion: list[str] = Field(min_length=1, max_length=6)
|
|
|
|
|
focus_points: list[str] = Field(default_factory=list, max_length=6)
|
|
|
|
|
advice: list[str] = Field(min_length=1, max_length=6)
|
|
|
|
|
keywords: list[str] = Field(min_length=3, max_length=8)
|
|
|
|
|
answer: str = Field(min_length=1, max_length=4000)
|
2026-04-02 16:36:35 +08:00
|
|
|
error: ErrorInfo | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class WorkerAgentOutputRich(WorkerAgentOutputLite):
|
|
|
|
|
ui_hints: UiHintsPayload | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AgentOutput(WorkerAgentOutputRich):
|
|
|
|
|
model_config = ConfigDict(extra="forbid")
|
|
|
|
|
|
2026-04-07 18:43:34 +08:00
|
|
|
divination_derived: DerivedDivinationData | None = None
|
|
|
|
|
|
2026-04-02 16:36:35 +08:00
|
|
|
|
|
|
|
|
WorkerAgentOutput = WorkerAgentOutputLite | WorkerAgentOutputRich
|
|
|
|
|
|
|
|
|
|
|
2026-04-03 16:56:47 +08:00
|
|
|
def resolve_worker_output_model() -> type[WorkerAgentOutputLite]:
|
|
|
|
|
return WorkerAgentOutputLite
|