Quintino Fernandes
commited on
Commit
·
9cb6544
1
Parent(s):
2abbbca
More entities fixes
Browse files- database/query.py +3 -4
- database/query_processor.py +1 -2
database/query.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import os
|
| 2 |
-
from typing import List, Dict, Optional
|
| 3 |
from datetime import datetime
|
| 4 |
import psycopg2
|
| 5 |
from psycopg2 import sql
|
|
@@ -19,7 +19,7 @@ class DatabaseService:
|
|
| 19 |
start_date: Optional[datetime] = None,
|
| 20 |
end_date: Optional[datetime] = None,
|
| 21 |
topic: Optional[str] = None,
|
| 22 |
-
entities: Optional[List[
|
| 23 |
limit: int = 10
|
| 24 |
) -> List[Dict[str, any]]:
|
| 25 |
|
|
@@ -152,8 +152,7 @@ class DatabaseService:
|
|
| 152 |
}
|
| 153 |
for content, distance, art_date, art_topic,url in articles
|
| 154 |
]
|
| 155 |
-
|
| 156 |
-
conn.close()
|
| 157 |
return formatted_results
|
| 158 |
|
| 159 |
except Exception as e:
|
|
|
|
| 1 |
import os
|
| 2 |
+
from typing import List, Dict, Optional,Tuple
|
| 3 |
from datetime import datetime
|
| 4 |
import psycopg2
|
| 5 |
from psycopg2 import sql
|
|
|
|
| 19 |
start_date: Optional[datetime] = None,
|
| 20 |
end_date: Optional[datetime] = None,
|
| 21 |
topic: Optional[str] = None,
|
| 22 |
+
entities: Optional[List[Tuple[str,str]]] = None,
|
| 23 |
limit: int = 10
|
| 24 |
) -> List[Dict[str, any]]:
|
| 25 |
|
|
|
|
| 152 |
}
|
| 153 |
for content, distance, art_date, art_topic,url in articles
|
| 154 |
]
|
| 155 |
+
|
|
|
|
| 156 |
return formatted_results
|
| 157 |
|
| 158 |
except Exception as e:
|
database/query_processor.py
CHANGED
|
@@ -87,13 +87,12 @@ class QueryProcessor:
|
|
| 87 |
) -> List[Dict[str, Any]]:
|
| 88 |
"""Execute search with proper error handling"""
|
| 89 |
try:
|
| 90 |
-
entity_texts = [ent[0] for ent in entities]
|
| 91 |
return await self.db_service.semantic_search(
|
| 92 |
query_embedding=query_embedding,
|
| 93 |
start_date=start_date,
|
| 94 |
end_date=end_date,
|
| 95 |
topic=topic,
|
| 96 |
-
entities=
|
| 97 |
)
|
| 98 |
except Exception as e:
|
| 99 |
logger.error(f"Semantic search failed: {str(e)}")
|
|
|
|
| 87 |
) -> List[Dict[str, Any]]:
|
| 88 |
"""Execute search with proper error handling"""
|
| 89 |
try:
|
|
|
|
| 90 |
return await self.db_service.semantic_search(
|
| 91 |
query_embedding=query_embedding,
|
| 92 |
start_date=start_date,
|
| 93 |
end_date=end_date,
|
| 94 |
topic=topic,
|
| 95 |
+
entities=entities
|
| 96 |
)
|
| 97 |
except Exception as e:
|
| 98 |
logger.error(f"Semantic search failed: {str(e)}")
|