update
This commit is contained in:
@@ -47,7 +47,7 @@ class BidStep(Strict):
|
||||
action: Literal["extract", "reconcile", "generate", "refine", "review", "analyze", "outline"]
|
||||
project: str = Field(min_length=1, max_length=200)
|
||||
instructions: str = Field(default="", max_length=3000)
|
||||
blocks: list[Block] = Field(max_length=80)
|
||||
blocks: list[Block] = Field(max_length=400)
|
||||
# Original paragraphs for understanding a subdivided extraction window.
|
||||
# Only blocks may be selected as evidence; context is never a new work item.
|
||||
extraction_context: list[Block] = Field(default_factory=list, max_length=80)
|
||||
@@ -67,6 +67,17 @@ class BidStep(Strict):
|
||||
|
||||
@model_validator(mode="after")
|
||||
def boundaries(self):
|
||||
if self.workbench.get('version') == 2:
|
||||
from .bid_studio import validate_request
|
||||
ids = [block.id for block in self.blocks + self.company]
|
||||
if len(ids) != len(set(ids)) or sum(len(block.text) for block in self.blocks + self.company) > 24000:
|
||||
raise ValueError('原文引用编号重复或本次上下文过大')
|
||||
validate_request(self)
|
||||
if self.workbench.get('phase') != 'analysis' and len(self.blocks) > 80:
|
||||
raise ValueError('本步骤原文块数超出范围')
|
||||
return self
|
||||
if len(self.blocks) > 80:
|
||||
raise ValueError('本步骤原文块数超出范围')
|
||||
ids = [b.id for b in self.blocks + self.company]
|
||||
if len(ids) != len(set(ids)):
|
||||
raise ValueError("资料编号重复")
|
||||
@@ -1009,6 +1020,8 @@ def _bid_step(request: BidStep, *, invoke=complete_json):
|
||||
request, extraction_repair, evidence, invoke, deadline, payload.get('validation_feedback'))
|
||||
elif request.action == 'reconcile' and progress is not None and progress.state.get('reconciliation_candidate'):
|
||||
raw = deepcopy(progress.state['reconciliation_candidate'])
|
||||
elif request.action == 'generate' and progress is not None and progress.state.get('generation_candidate'):
|
||||
raw = deepcopy(progress.state['generation_candidate'])
|
||||
elif resume_validation:
|
||||
# A completed candidate survived a later audit interruption.
|
||||
# Revalidate the saved candidate, then continue its audit.
|
||||
@@ -1068,6 +1081,14 @@ def _bid_step(request: BidStep, *, invoke=complete_json):
|
||||
if request.workbench and request.action in {'generate', 'refine'}:
|
||||
from .bid_workbench import normalize_known_fields
|
||||
normalize_known_fields(request, result)
|
||||
if request.action == 'generate':
|
||||
from .bid_draft_quality import guard_generated_draft
|
||||
if progress is not None:
|
||||
progress.state['generation_candidate'] = deepcopy(result)
|
||||
progress.persist(True)
|
||||
guard_generated_draft(request, result, invoke, deadline)
|
||||
if progress is not None:
|
||||
progress.state.pop('generation_candidate', None)
|
||||
if rewriting:
|
||||
from .bid_draft_quality import draft_signature
|
||||
signature = draft_signature(result)
|
||||
@@ -1199,6 +1220,7 @@ def _bid_step(request: BidStep, *, invoke=complete_json):
|
||||
if progress is not None:
|
||||
progress.state['validation_feedback'] = deepcopy(payload['validation_feedback'])
|
||||
progress.state.pop('reconciliation_candidate', None)
|
||||
progress.state.pop('generation_candidate', None)
|
||||
progress.persist(True)
|
||||
if attempt + 1 >= max_attempts:
|
||||
if request.action == 'extract' and progress is not None:
|
||||
@@ -1216,6 +1238,9 @@ def _bid_step(request: BidStep, *, invoke=complete_json):
|
||||
|
||||
|
||||
def bid_step(request: BidStep, *, invoke=complete_json):
|
||||
if request.workbench.get("version") == 2:
|
||||
from .bid_studio import studio_step
|
||||
return studio_step(request, invoke)
|
||||
if request.action == 'refine' and request.workbench:
|
||||
# Compatibility for already queued workspace checks. The generated
|
||||
# draft is retained; optional book review is a separate explicit action.
|
||||
|
||||
Reference in New Issue
Block a user