Reduce LLM rewrite calls and add report intro conclusion

This commit is contained in:
Mimikko-zeus
2026-06-04 16:41:05 +08:00
parent f7e4c9722b
commit 6eca615f42
7 changed files with 104 additions and 18 deletions

View File

@@ -83,8 +83,9 @@ def rewrite_items(
items: list[NewsItem],
*,
llm_call: RewriteLlmCall,
batch_size: int = 10,
batch_size: int = 30,
max_fallback_ratio: float = 0.2,
retry_single_items: bool = False,
) -> tuple[list[NewsItem], dict[str, Any]]:
rewritten_count = 0
fallback_count = 0
@@ -100,6 +101,11 @@ def rewrite_items(
_fallback(item)
fallback_count += 1
continue
if not retry_single_items:
for item in batch:
_fallback(item)
fallback_count += 1
continue
for item in batch:
try:
rewritten_count += _apply_rewrite_batch([item], llm_call)