Unify the export-llm-input and run-llm summary lines with build-db

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-17 22:38:37 +08:00
co-authored by Claude Opus 5
parent bc44d60d18
commit 3aa5c7a432
4 changed files with 20 additions and 13 deletions
@@ -28,6 +28,7 @@ keys, then that song's own keys, each group in its file order.
import argparse
import json
import sys
import time
from pathlib import Path
from typing import Any
@@ -36,6 +37,7 @@ from sqlalchemy.orm import Session
from ..database import ds
from ..models import Song
from ..utils import format_duration
def parse_args(argv: list[str] | None) -> argparse.Namespace:
@@ -231,6 +233,7 @@ def main(argv: list[str] | None = None) -> int:
``sys.argv``.
:return: The exit status: 0 on success, non-zero on failure.
"""
started: float = time.monotonic()
args: argparse.Namespace = parse_args(argv)
session: Session = ds.get_db()
lines: list[str]
@@ -252,5 +255,7 @@ def main(argv: list[str] | None = None) -> int:
line: str
for line in lines:
file.write(line + "\n")
print(f"done: {len(lines)} songs exported", file=sys.stderr)
elapsed: str = format_duration(time.monotonic() - started)
print(f"Done. {len(lines)} songs exported."
f" {elapsed} elapsed.", file=sys.stderr)
return 0
@@ -488,8 +488,9 @@ def main(argv: list[str] | None = None) -> int:
print(json.dumps(
build_request(items[0], prompt_text, args.max_tokens),
ensure_ascii=False, indent=2))
print(f"dry run: archive created at {archive_dir}",
file=sys.stderr)
elapsed: str = format_duration(time.monotonic() - started)
print(f"Done. {len(items)} jobs finished."
f" {elapsed} elapsed.", file=sys.stderr)
return 0
client: anthropic.Anthropic = anthropic.Anthropic(
api_key=get_settings().ANTHROPIC_API_KEY)
@@ -507,7 +508,6 @@ def main(argv: list[str] | None = None) -> int:
file=sys.stderr)
return 1
elapsed: str = format_duration(time.monotonic() - started)
print(f"done: {len(items)} items;"
f" archived to {archive_dir} {elapsed} elapsed.",
file=sys.stderr)
print(f"Done. {len(items)} jobs finished."
f" {elapsed} elapsed.", file=sys.stderr)
return 0