Dama12 commited on
Commit
9035689
·
1 Parent(s): 2593ebc

fix: validate ScientificDocument schema with authors and document_type

Browse files
Files changed (1) hide show
  1. app/services/analysis_service.py +12 -0
app/services/analysis_service.py CHANGED
@@ -115,11 +115,23 @@ class AnalysisService:
115
  logger.error(f"Failed to fetch/save remote paper {pid}: {fetch_err}")
116
 
117
  if paper:
 
 
 
 
 
 
 
 
 
 
118
  docs.append(ScientificDocument(
119
  id=str(paper.id),
120
  title=paper.title,
 
121
  abstract=paper.summary or "",
122
  content=paper.summary or "",
 
123
  url=paper.pdf_path or ""
124
  ))
125
 
 
115
  logger.error(f"Failed to fetch/save remote paper {pid}: {fetch_err}")
116
 
117
  if paper:
118
+ # Convert authors string to list
119
+ author_list = [a.strip() for a in paper.authors.split(",")] if paper.authors else ["Unknown"]
120
+
121
+ # Determine document type based on remote_id prefix
122
+ dtype = "custom"
123
+ if paper.remote_id:
124
+ if "pubmed_" in paper.remote_id: dtype = "pubmed"
125
+ elif "arxiv_" in paper.remote_id or "." in paper.remote_id: dtype = "arxiv"
126
+ else: dtype = "arxiv" # default for most research platforms
127
+
128
  docs.append(ScientificDocument(
129
  id=str(paper.id),
130
  title=paper.title,
131
+ authors=author_list,
132
  abstract=paper.summary or "",
133
  content=paper.summary or "",
134
+ document_type=dtype,
135
  url=paper.pdf_path or ""
136
  ))
137