Update services/pdf_service.py
Browse files- services/pdf_service.py +9 -1
services/pdf_service.py
CHANGED
@@ -58,7 +58,9 @@ class PDFService:
|
|
58 |
'metadata': metadata,
|
59 |
'timestamp': datetime.now().isoformat()
|
60 |
})
|
61 |
-
|
|
|
|
|
62 |
return chunks
|
63 |
|
64 |
except Exception as e:
|
@@ -120,6 +122,8 @@ class PDFService:
|
|
120 |
min_score: float = 0.5
|
121 |
) -> List[Dict[str, Any]]:
|
122 |
"""Search indexed PDFs"""
|
|
|
|
|
123 |
if not self.index or not self.chunks:
|
124 |
await self.index_pdfs()
|
125 |
|
@@ -149,6 +153,10 @@ class PDFService:
|
|
149 |
|
150 |
# Sort by score and take top_k
|
151 |
results.sort(key=lambda x: x['score'], reverse=True)
|
|
|
|
|
|
|
|
|
152 |
return results[:top_k]
|
153 |
|
154 |
except Exception as e:
|
|
|
58 |
'metadata': metadata,
|
59 |
'timestamp': datetime.now().isoformat()
|
60 |
})
|
61 |
+
print("--------------------------- chunks ----------------------------------")
|
62 |
+
print("--------------------------- chunks ----------------------------------")
|
63 |
+
print(chunks)
|
64 |
return chunks
|
65 |
|
66 |
except Exception as e:
|
|
|
122 |
min_score: float = 0.5
|
123 |
) -> List[Dict[str, Any]]:
|
124 |
"""Search indexed PDFs"""
|
125 |
+
print("--------------------------- query ----------------------------------")
|
126 |
+
print(query)
|
127 |
if not self.index or not self.chunks:
|
128 |
await self.index_pdfs()
|
129 |
|
|
|
153 |
|
154 |
# Sort by score and take top_k
|
155 |
results.sort(key=lambda x: x['score'], reverse=True)
|
156 |
+
|
157 |
+
print("--------------------------- results ----------------------------------")
|
158 |
+
print(results)
|
159 |
+
|
160 |
return results[:top_k]
|
161 |
|
162 |
except Exception as e:
|