abdoh-alkhateeb commited on
Commit
ad7bff9
1 Parent(s): 529f708

Narrow the size of the dataframe returned by DatasetSemanticSearchAgent

Browse files
agents/dataset_semantic_search_agent.py CHANGED
@@ -7,7 +7,7 @@ class DatasetSemanticSearchAgent:
7
  def __init__(self, vector_store_path: str) -> None:
8
  self._vector_store = FAISS.load_local(vector_store_path, HuggingFaceEmbeddings(), allow_dangerous_deserialization=True)
9
 
10
- def run(self, query: str, limit: int = 10, score_threshold: int = 1.2) -> pd.DataFrame:
11
  docs_with_scores = self._vector_store.similarity_search_with_score(query, k=limit)
12
 
13
  results = []
@@ -24,4 +24,6 @@ class DatasetSemanticSearchAgent:
24
  df = pd.DataFrame(results)
25
  df.rename(columns={"_id": "id", "full_text": "content"}, inplace=True)
26
 
27
- return df
 
 
 
7
  def __init__(self, vector_store_path: str) -> None:
8
  self._vector_store = FAISS.load_local(vector_store_path, HuggingFaceEmbeddings(), allow_dangerous_deserialization=True)
9
 
10
+ def run(self, query: str, limit: int = 10, score_threshold: int = 1.2) -> tuple[pd.DataFrame, dict[str, float]]:
11
  docs_with_scores = self._vector_store.similarity_search_with_score(query, k=limit)
12
 
13
  results = []
 
24
  df = pd.DataFrame(results)
25
  df.rename(columns={"_id": "id", "full_text": "content"}, inplace=True)
26
 
27
+ df = df[["title", "author", "date", "url", "content"]]
28
+
29
+ return df, {"cost": 0}