fix(reader): include all keep candidates in digest brief
This commit is contained in:
@@ -11,7 +11,7 @@ from pydantic import BaseModel, Field
|
|||||||
|
|
||||||
from .article_candidate import OpenClawCandidateInput
|
from .article_candidate import OpenClawCandidateInput
|
||||||
|
|
||||||
DIGEST_BRIEF_LIMIT = 5
|
DIGEST_BRIEF_LIMIT: int | None = None
|
||||||
DIGEST_BRIEF_HIGHLIGHT_LIMIT = 3
|
DIGEST_BRIEF_HIGHLIGHT_LIMIT = 3
|
||||||
|
|
||||||
|
|
||||||
@@ -81,11 +81,12 @@ def build_openclaw_delivery_payload(
|
|||||||
def build_openclaw_digest_brief(
|
def build_openclaw_digest_brief(
|
||||||
payload: OpenClawDeliveryPayload,
|
payload: OpenClawDeliveryPayload,
|
||||||
*,
|
*,
|
||||||
limit: int = DIGEST_BRIEF_LIMIT,
|
limit: int | None = DIGEST_BRIEF_LIMIT,
|
||||||
highlight_limit: int = DIGEST_BRIEF_HIGHLIGHT_LIMIT,
|
highlight_limit: int = DIGEST_BRIEF_HIGHLIGHT_LIMIT,
|
||||||
) -> OpenClawDigestBrief:
|
) -> OpenClawDigestBrief:
|
||||||
keep_candidates = [candidate for candidate in payload.candidates if candidate.selection_decision == "keep"]
|
keep_candidates = [candidate for candidate in payload.candidates if candidate.selection_decision == "keep"]
|
||||||
sorted_candidates = sorted(keep_candidates, key=lambda candidate: candidate.digest_rank, reverse=True)
|
sorted_candidates = sorted(keep_candidates, key=lambda candidate: candidate.digest_rank, reverse=True)
|
||||||
|
selected_candidates = sorted_candidates if limit is None else sorted_candidates[:limit]
|
||||||
top_candidates = [
|
top_candidates = [
|
||||||
DigestBriefCandidate(
|
DigestBriefCandidate(
|
||||||
title=candidate.title,
|
title=candidate.title,
|
||||||
@@ -97,7 +98,7 @@ def build_openclaw_digest_brief(
|
|||||||
selection_decision=candidate.selection_decision,
|
selection_decision=candidate.selection_decision,
|
||||||
url=str(candidate.url),
|
url=str(candidate.url),
|
||||||
)
|
)
|
||||||
for candidate in sorted_candidates[:limit]
|
for candidate in selected_candidates
|
||||||
]
|
]
|
||||||
return OpenClawDigestBrief(
|
return OpenClawDigestBrief(
|
||||||
schema_version="digest-brief.v1",
|
schema_version="digest-brief.v1",
|
||||||
|
|||||||
Reference in New Issue
Block a user