Introduce 智能评估 as an evaluation paradigm parallel to static evaluation, driven by OpenClaw. The platform supplies storage, lifecycle, and reporting; OpenClaw plans and executes. - Data model: IntelligentEval + Session + Message tables (new, not reusing exploration) - Lifecycle state machine: draft → planning → pending_approval → executing → completed/cancelled/failed - Session API: create/message (channel-forwarded)/close with turn accounting - Report API: pydantic-validated structured report, executing → completed, Markdown export (pure renderer) - Alembic migration for the three tables; domain glossary added to CONTEXT.md
88 lines
2.4 KiB
Python
88 lines
2.4 KiB
Python
"""Domain models for intelligent evaluation (智能评估).
|
|
|
|
Intelligent evaluation is an independent evaluation paradigm parallel to
|
|
static evaluation (v0.8). OpenClaw drives planning and execution; the platform
|
|
provides data storage, lifecycle management, and reporting.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
from enum import Enum
|
|
from typing import Any, Optional
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class IntelligentEvalStatus(str, Enum):
|
|
DRAFT = "draft"
|
|
PLANNING = "planning"
|
|
PENDING_APPROVAL = "pending_approval"
|
|
EXECUTING = "executing"
|
|
COMPLETED = "completed"
|
|
CANCELLED = "cancelled"
|
|
FAILED = "failed"
|
|
|
|
|
|
class IntelligentEvalSessionStatus(str, Enum):
|
|
RUNNING = "running"
|
|
COMPLETED = "completed"
|
|
FAILED = "failed"
|
|
EXPIRED = "expired"
|
|
|
|
|
|
class IntelligentEvalMessage(BaseModel):
|
|
"""One chat message inside an intelligent eval session."""
|
|
|
|
id: Optional[str] = None
|
|
session_id: str
|
|
role: str = "user"
|
|
content: str = ""
|
|
latency_ms: Optional[int] = None
|
|
created_at: Optional[datetime] = None
|
|
|
|
|
|
class IntelligentEvalSession(BaseModel):
|
|
"""A virtual-user session belonging to one intelligent evaluation."""
|
|
|
|
id: Optional[str] = None
|
|
eval_id: str
|
|
target_id: str
|
|
persona: dict[str, Any] = Field(default_factory=dict)
|
|
goal: str = ""
|
|
dimension: Optional[str] = None
|
|
status: IntelligentEvalSessionStatus = IntelligentEvalSessionStatus.RUNNING
|
|
verdict: Optional[dict[str, Any]] = None
|
|
turn_count: int = 0
|
|
created_at: Optional[datetime] = None
|
|
closed_at: Optional[datetime] = None
|
|
|
|
|
|
class IntelligentEval(BaseModel):
|
|
"""An intelligent evaluation instance — independent entity, peer to Campaign."""
|
|
|
|
id: Optional[str] = None
|
|
name: str
|
|
target_id: str
|
|
status: IntelligentEvalStatus = IntelligentEvalStatus.DRAFT
|
|
|
|
# User input (四件套)
|
|
goal: str = ""
|
|
seeds: dict[str, Any] = Field(default_factory=dict)
|
|
intent: str = ""
|
|
role_description: str = ""
|
|
|
|
# Coarse plan (OpenClaw produces)
|
|
plan: Optional[dict[str, Any]] = None
|
|
plan_feedback: Optional[str] = None
|
|
|
|
# Time window
|
|
time_window_hours: int = 24
|
|
|
|
# Report
|
|
report: Optional[dict[str, Any]] = None
|
|
|
|
# Timestamps
|
|
created_at: Optional[datetime] = None
|
|
updated_at: Optional[datetime] = None
|
|
started_at: Optional[datetime] = None
|
|
completed_at: Optional[datetime] = None
|