101 lines
4.0 KiB
Python
101 lines
4.0 KiB
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sys
|
|
from datetime import date
|
|
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 import run_freshrss_pipeline
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(
|
|
description="Run the full FreshRSS -> extract -> LLM -> filter -> OpenClaw payload pipeline."
|
|
)
|
|
parser.add_argument("--api-base-url", type=str, default=None, help="FreshRSS greader API base URL")
|
|
parser.add_argument("--username", type=str, default=None, help="FreshRSS API username")
|
|
parser.add_argument("--api-password", type=str, default=None, help="FreshRSS API password")
|
|
parser.add_argument(
|
|
"--stream-id",
|
|
type=str,
|
|
default="user/-/state/com.google/reading-list",
|
|
help="Google Reader API stream id",
|
|
)
|
|
parser.add_argument("--limit", type=int, default=5, help="Maximum number of entries to request")
|
|
parser.add_argument("--continuation", type=str, default=None, help="Continuation token for paging")
|
|
parser.add_argument(
|
|
"--include-read",
|
|
action="store_true",
|
|
help="Do not exclude items already tagged as read.",
|
|
)
|
|
parser.add_argument(
|
|
"--mark-read",
|
|
action="store_true",
|
|
help="Mark only successfully delivered items as read after the final payload is written.",
|
|
)
|
|
parser.add_argument(
|
|
"--debug-artifacts",
|
|
action="store_true",
|
|
help="Persist per-item intermediate files for debugging.",
|
|
)
|
|
parser.add_argument("--prompt", type=Path, default=None, help="LLM prompt template file")
|
|
parser.add_argument("--rules", type=Path, default=None, help="Filter rule config JSON file")
|
|
parser.add_argument("--context", type=Path, default=None, help="Optional filter context JSON file")
|
|
parser.add_argument("--max-retries", type=int, default=2, help="Number of repair retries after the initial attempt")
|
|
parser.add_argument("--timeout", type=float, default=60.0, help="Request timeout in seconds")
|
|
parser.add_argument("--llm-api-key", type=str, default=None, help="LLM API key")
|
|
parser.add_argument("--llm-model", type=str, default=None, help="LLM model name")
|
|
parser.add_argument("--llm-api-url", type=str, default=None, help="LLM chat completions API URL or base URL")
|
|
parser.add_argument("--run-id", type=str, default=None, help="Optional pipeline run id")
|
|
parser.add_argument("--date", type=str, default=None, help="Optional delivery date in YYYY-MM-DD format")
|
|
parser.add_argument(
|
|
"--output-dir",
|
|
type=Path,
|
|
default=None,
|
|
help="Run output directory. Defaults to outputs/freshrss/rerun/<timestamp>",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
result = run_freshrss_pipeline(
|
|
api_base_url=args.api_base_url,
|
|
username=args.username,
|
|
api_password=args.api_password,
|
|
stream_id=args.stream_id,
|
|
limit=args.limit,
|
|
continuation=args.continuation,
|
|
include_read=args.include_read,
|
|
mark_read=args.mark_read,
|
|
debug_artifacts=args.debug_artifacts,
|
|
prompt=args.prompt,
|
|
rules=args.rules,
|
|
context_path=args.context,
|
|
max_retries=args.max_retries,
|
|
timeout_seconds=args.timeout,
|
|
llm_api_key=args.llm_api_key,
|
|
llm_model=args.llm_model,
|
|
llm_api_url=args.llm_api_url,
|
|
run_id=args.run_id,
|
|
delivery_date=date.fromisoformat(args.date) if args.date else None,
|
|
output_dir=args.output_dir,
|
|
)
|
|
|
|
print(f"Saved FreshRSS pipeline run to {result['output_dir']}")
|
|
print(f"Pulled {result['pulled_count']} items, delivered {result['delivered_count']} candidates")
|
|
print(
|
|
"Saved keyword index to "
|
|
f"{result['keyword_index']['daily_output']} and {result['keyword_index']['stats_output']}"
|
|
)
|
|
if args.mark_read:
|
|
print(f"Marked {result['marked_read_count']} FreshRSS entries as read")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|