GradioDemo / example.py
eigentom
Initial Update
90c099b
"""
Example script for running a single-paper review.
This example is intentionally thin and delegates to the reusable
`review_single_paper_from_text` helper, which is what a Hugging Face
Space backend would call after performing PDF-to-text conversion.
"""
import json
import sys
from pathlib import Path
import logging
# Add project root to path for imports
project_root = Path(__file__).parent.parent
if str(project_root) not in sys.path:
sys.path.insert(0, str(project_root))
from src.reviewer_agent.single_paper_inference import review_single_paper_from_text
logging.basicConfig(level=logging.INFO)
logging.getLogger("httpx").setLevel(logging.WARNING)
logger = logging.getLogger(__name__)
def main() -> None:
"""Run a minimal single-paper review using the first example paper."""
json_path = project_root / "examples" / "example_papers.json"
with open(json_path, "r") as f:
data = json.load(f)
# For demonstration we take only the first paper
first_paper = data[0]
paper_text = first_paper.get("paper_context", "")
logger.info("Running single-paper review from example_papers.json...")
review = review_single_paper_from_text(
paper_text,
keywords=first_paper.get("keywords"),
# Use config defaults for review_format and verbosity
enable_logging=True,
verbose=False,
)
# Save the review content to a JSON file
with open("review_content.json", "w") as f:
json.dump([review], f, indent=2)
logger.info("Review saved to review_content.json")
if __name__ == "__main__":
main()