69 lines
2.1 KiB
Python
Executable File
69 lines
2.1 KiB
Python
Executable File
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[1]
|
|
SRC_ROOT = REPO_ROOT / "src"
|
|
|
|
if str(SRC_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(SRC_ROOT))
|
|
|
|
from summary_mcp.workflows.article_summary import summarize_selected_articles
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(
|
|
description="Generate Markdown summaries for selected articles from an extracted payload.",
|
|
)
|
|
parser.add_argument(
|
|
"--extracted",
|
|
type=Path,
|
|
required=True,
|
|
help="Path to extracted JSON (e.g. outputs/freshrss/extracted/freshrss.extracted.json)",
|
|
)
|
|
parser.add_argument(
|
|
"--ids",
|
|
nargs="+",
|
|
required=True,
|
|
help="One or more item_ids to summarize",
|
|
)
|
|
parser.add_argument(
|
|
"--output-dir",
|
|
type=Path,
|
|
default=REPO_ROOT / "outputs" / "freshrss" / "single_summaries",
|
|
help="Directory to write per-article Markdown summaries",
|
|
)
|
|
parser.add_argument("--max-retries", type=int, default=2, help="Maximum LLM retry attempts per article")
|
|
parser.add_argument("--timeout", type=float, default=120.0, help="LLM request timeout in seconds")
|
|
parser.add_argument("--api-key", type=str, default=None, help="Override article-summary LLM API key")
|
|
parser.add_argument("--model", type=str, default=None, help="Override article-summary LLM model")
|
|
parser.add_argument("--api-url", type=str, default=None, help="Override article-summary LLM API URL/base URL")
|
|
args = parser.parse_args()
|
|
|
|
from summary_mcp.workflows.article_summary import ArticleSummaryConfig
|
|
|
|
config = ArticleSummaryConfig(
|
|
max_retries=args.max_retries,
|
|
timeout_seconds=args.timeout,
|
|
)
|
|
|
|
paths = summarize_selected_articles(
|
|
extracted_path=args.extracted,
|
|
selected_ids=args.ids,
|
|
output_dir=args.output_dir,
|
|
config=config,
|
|
api_key=args.api_key,
|
|
model=args.model,
|
|
api_url=args.api_url,
|
|
)
|
|
|
|
for path in paths:
|
|
print(path)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|