This commit is contained in:
zyp
2026-11-24 15:38:28 +08:00
parent a6740c4509
commit c27f84cf91
20 changed files with 823 additions and 42 deletions
+6 -4
View File
@@ -11,9 +11,11 @@ from app.modules.work_assistant.decomposition_schedule import assess_schedule
from app.modules.work_assistant.model_gateway import complete_json
from app.modules.work_assistant.review_failure import review_failure
from app.modules.work_assistant.review_commentary import review_commentary
from .confidential_delivery import CONFIDENTIAL_DELIVERY_POLICY
from .task_review_contract import GOAL_RULE, SCHEMA_VERSION
logger = logging.getLogger(__name__)
RULE_VERSION = "goal-review-v7"
RULE_VERSION = GOAL_RULE
class GoalReviewRequest(BaseModel):
@@ -140,7 +142,7 @@ def review_goal(payload: GoalReviewRequest, *, invoke=None) -> dict:
if quotes:
definition_schema['$defs']['PlannedStep']['properties']['goal_quote']['enum'] = quotes
definition_schema['$defs']['GoalSuggestion']['properties']['quote']['enum'] = quotes
definition = GoalDefinition.model_validate(call(DEFINITION, dict(phase="goal_definition",
definition = GoalDefinition.model_validate(call(DEFINITION + CONFIDENTIAL_DELIVERY_POLICY, dict(phase="goal_definition",
goal=goal.model_dump(mode="json"), parent=payload.parent.model_dump(mode="json") if payload.parent else None),
definition_schema, timeout_seconds=remaining(25), max_tokens=2400))
for step in definition.steps:
@@ -152,7 +154,7 @@ def review_goal(payload: GoalReviewRequest, *, invoke=None) -> dict:
schema = GoalMapping.model_json_schema()
schema["properties"]["matches"].update(minItems=len(definition.steps), maxItems=len(definition.steps))
schema["$defs"]["StepMatch"]["properties"]["step"].update(maximum=len(definition.steps), enum=list(range(1, len(definition.steps)+1)))
mapping = GoalMapping.model_validate(call(MAPPING, dict(phase="goal_mapping",goal=goal.model_dump(mode="json"),
mapping = GoalMapping.model_validate(call(MAPPING + CONFIDENTIAL_DELIVERY_POLICY, dict(phase="goal_mapping",goal=goal.model_dump(mode="json"),
goal_plan=definition.model_dump(exclude={"suggestions"}),children=[t.model_dump(mode="json") for t in children.values()]),
schema, timeout_seconds=remaining(25), max_tokens=2200))
if sorted(m.step for m in mapping.matches) != list(range(1, len(definition.steps)+1)):
@@ -221,5 +223,5 @@ def review_goal(payload: GoalReviewRequest, *, invoke=None) -> dict:
return dict(status=status,summary=commentary.get("assessment", "本次具体评价未完成。") if commentary else "本次分析未完成。",review_kind="goal",goal_name=goal.name,
goal_suggestions=suggestions,child_issues=issues,findings=findings,alignment=None,workflow=workflow,
schedule=schedule,limitations=limitations,model_completed=model_ok,analysis_error=analysis_error,
requirements=requirements,commentary=commentary,subject_name=goal.name,rule_version=RULE_VERSION,
requirements=requirements,commentary=commentary,subject_name=goal.name,rule_version=RULE_VERSION,schema_version=SCHEMA_VERSION,
sources=[s.model_dump(mode="json") for s in payload.sources])