64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
import asyncio
|
|
import logging
|
|
from dotenv import load_dotenv
|
|
from src.storage.paper_store import PaperStore
|
|
|
|
def get_score_color(score: int) -> tuple[str, str]:
|
|
"""Get color codes for a score."""
|
|
if score <= 25:
|
|
return '\033[92m', '(Excellent: Highly original research)' # Green
|
|
elif score <= 50:
|
|
return '\033[94m', '(Good: Solid research)' # Blue
|
|
elif score <= 75:
|
|
return '\033[93m', '(Fair: Some fluff present)' # Yellow
|
|
else:
|
|
return '\033[91m', '(Poor: Heavy on fluff)' # Red
|
|
|
|
async def view_papers():
|
|
"""View all papers in the database."""
|
|
# Load environment variables
|
|
load_dotenv()
|
|
|
|
store = PaperStore()
|
|
try:
|
|
await store.initialize()
|
|
papers = await store.get_all_paper_ids()
|
|
|
|
if not papers:
|
|
print("\nNo papers found in database.")
|
|
return
|
|
|
|
print(f"\nFound {len(papers)} papers in database:")
|
|
|
|
# Get full details for each paper
|
|
for paper_id in papers:
|
|
paper = await store.get_paper(paper_id)
|
|
if paper:
|
|
print("\n" + "="*80)
|
|
print(f"Title: {paper['title']}")
|
|
print(f"Authors: {', '.join(paper['authors']) if isinstance(paper['authors'], list) else paper['authors']}")
|
|
print("\nSummary:")
|
|
print(paper['summary'] if paper['summary'] else "No summary available")
|
|
print("\nTechnical Concepts:")
|
|
print(paper['technical_concepts'] if paper['technical_concepts'] else "No technical concepts available")
|
|
|
|
# Display fluff score with color coding
|
|
score = paper.get('fluff_score')
|
|
if score is not None:
|
|
color, description = get_score_color(score)
|
|
reset = '\033[0m'
|
|
print(f"\nFluff Score: {color}{score}/100 {description}{reset}")
|
|
print("\nAnalysis:")
|
|
print(paper['fluff_explanation'] if paper['fluff_explanation'] else "No analysis available")
|
|
else:
|
|
print("\nFluff Analysis: Not available")
|
|
|
|
print("\n" + "="*80)
|
|
|
|
finally:
|
|
await store.close()
|
|
|
|
if __name__ == "__main__":
|
|
logging.basicConfig(level=logging.WARNING) # Suppress debug logs
|
|
asyncio.run(view_papers())
|