Spaces:
Sleeping
Sleeping
Commit
·
55dc8e4
1
Parent(s):
a843121
feat: return first abstract sentence if title is empty
Browse files
sorbobotapp/vector_store.py
CHANGED
@@ -222,6 +222,12 @@ class CustomVectorStore(VectorStore):
|
|
222 |
|
223 |
return self._results_to_docs_and_scores(results)
|
224 |
|
|
|
|
|
|
|
|
|
|
|
|
|
225 |
def _results_to_docs_and_scores(self, results: Any) -> List[Tuple[Document, float]]:
|
226 |
"""Return docs and scores from results."""
|
227 |
docs = [
|
@@ -229,7 +235,7 @@ class CustomVectorStore(VectorStore):
|
|
229 |
Document(
|
230 |
page_content=json.dumps(
|
231 |
{
|
232 |
-
"title": result["title"][0],
|
233 |
"authors": result["authors"],
|
234 |
"keywords": result["keywords"],
|
235 |
}
|
|
|
222 |
|
223 |
return self._results_to_docs_and_scores(results)
|
224 |
|
225 |
+
@staticmethod
|
226 |
+
def _fetch_title(title:str, abstract:str):
|
227 |
+
if len(title) > 0:
|
228 |
+
return title
|
229 |
+
return abstract.split(".")[0]
|
230 |
+
|
231 |
def _results_to_docs_and_scores(self, results: Any) -> List[Tuple[Document, float]]:
|
232 |
"""Return docs and scores from results."""
|
233 |
docs = [
|
|
|
235 |
Document(
|
236 |
page_content=json.dumps(
|
237 |
{
|
238 |
+
"title": self._fetch_title(result["title"][0], result["abstract"][0]),
|
239 |
"authors": result["authors"],
|
240 |
"keywords": result["keywords"],
|
241 |
}
|