update
This commit is contained in:
@@ -131,25 +131,29 @@ def compose_verified_answer(payload: AnswerRequest, *, invoke_model=None) -> dic
|
||||
# The model and independent audit already receive the limitation.
|
||||
# Prefixing it again repeats a caveat already explained in context.
|
||||
rendered['verification'] = 'source_bound'
|
||||
if "assistant-capabilities" in payload.skill_ids:
|
||||
rendered['answer'] += "\n\n" + _capabilities(payload)
|
||||
return rendered
|
||||
catalog_read = payload.question_spec.get("catalog_read", False)
|
||||
incomplete = bool(payload.investigation_note) or any(item.status != "ok" for item in payload.evidence)
|
||||
catalog_read = payload.question_spec.get("catalog_read", False) or payload.question_spec.get("direct_evidence_read", False)
|
||||
investigation_note = display_note(payload.investigation_note)
|
||||
incomplete = bool(investigation_note) or any(item.status != "ok" for item in payload.evidence)
|
||||
# A failed synthesis must not trigger another model call just to display
|
||||
# records. Keep a short, clearly labelled partial result under outages.
|
||||
selected = {} if incomplete or catalog_read else select_evidence(payload, invoke_model=invoke_model)
|
||||
definitions = {item["id"]: item for item in payload.available_resources if "id" in item}
|
||||
blocks, citations, facts = [], [], []
|
||||
if incomplete:
|
||||
detail = ("已取得部分资料,下面保留相关记录供核对;可以继续重试当前问题。"
|
||||
if any(item.status == "ok" for item in payload.evidence)
|
||||
else "相关资料尚未取得,暂不能给出可靠结论;可以继续重试当前问题。")
|
||||
blocks.append("**本次回答尚未完成。** " + detail)
|
||||
# Per-query errors below explain what actually happened. Permissions and
|
||||
# unresolved people cannot be fixed by blindly retrying the same question.
|
||||
if investigation_note:
|
||||
blocks.append(investigation_note)
|
||||
blocks.extend(payload.question_spec.get("scope_notes", []))
|
||||
if payload.question_spec.get("response_kind") == "capability_gap":
|
||||
gap = payload.question_spec.get("limitation", "")
|
||||
if gap:
|
||||
blocks.append(gap)
|
||||
indexed = list(enumerate(payload.evidence))
|
||||
if "assistant-capabilities" in payload.skill_ids:
|
||||
blocks.append(_capabilities(payload))
|
||||
indexed.sort(key=lambda pair: 0 if pair[1].purpose == "primary" else 1)
|
||||
for index, item in indexed:
|
||||
if incomplete and not catalog_read and len(item.rows) > 3:
|
||||
@@ -162,8 +166,9 @@ def compose_verified_answer(payload: AnswerRequest, *, invoke_model=None) -> dic
|
||||
continue
|
||||
prefix = "补充资料:" if item.purpose != "primary" else ""
|
||||
if item.status != "ok":
|
||||
status = "当前账号没有读取权限" if item.status == "denied" else "本次读取未完成,暂时无法判断结果"
|
||||
blocks.append(f"{prefix}{item.title}:{status}。" + display_note(item.note, definitions.get(item.resource)))
|
||||
note = display_note(item.note, definitions.get(item.resource))
|
||||
status = "当前账号没有读取权限,尚未查询记录。" if item.status == "denied" else "本次读取未完成,暂时无法判断结果。"
|
||||
blocks.append(f"{prefix}{item.title}:" + (note or status))
|
||||
continue
|
||||
key = _identifier(index, item)
|
||||
conditions = _conditions(item, definitions)
|
||||
@@ -240,4 +245,11 @@ def compose_verified_answer(payload: AnswerRequest, *, invoke_model=None) -> dic
|
||||
append_note(blocks, payload.investigation_note)
|
||||
append_note(blocks, answer_footer(payload))
|
||||
return {"answer": "\n\n".join(blocks), "source_ids": citations[:20], "skill_names": [],
|
||||
"verification": "evidence_bound", "answer_status": "partial" if incomplete else "complete", "facts": facts}
|
||||
"verification": "evidence_bound", "answer_status": "partial" if incomplete or (
|
||||
payload.question_spec.get("response_kind") == "capability_gap" and payload.question_spec.get("limitation")) else "complete", "facts": facts}
|
||||
|
||||
|
||||
def _capabilities(payload):
|
||||
from app.modules.work_assistant.service import compose_answer
|
||||
return compose_answer(payload.model_copy(update={"protocol_version": 1, "evidence": [],
|
||||
"skill_ids": ["assistant-capabilities"], "investigation_answer": "", "investigation_note": ""}))["answer"]
|
||||
|
||||
Reference in New Issue
Block a user