luciagomez commited on
Commit
aee999b
·
verified ·
1 Parent(s): 21ed7a6

Update retriever_m3.py

Browse files
Files changed (1) hide show
  1. retriever_m3.py +5 -2
retriever_m3.py CHANGED
@@ -36,6 +36,9 @@ df = pd.read_parquet(parquet_path,engine="pyarrow")
36
  # inference client is defined at app.py, here just the function
37
 
38
  def find_similar_foundations_api(query: str, client, top_k: int = 5):
 
 
 
39
  # Compute similarity against all missions
40
  results = client.sentence_similarity(
41
  {
@@ -53,8 +56,8 @@ def find_similar_foundations_api(query: str, client, top_k: int = 5):
53
  )
54
 
55
  return [
56
- {"score": float(score), "Title": foundation, "Purpose": mission}
57
- for score, foundation, mission in scored[:top_k]
58
  ]
59
 
60
 
 
36
  # inference client is defined at app.py, here just the function
37
 
38
  def find_similar_foundations_api(query: str, client, top_k: int = 5):
39
+ if "Title" not in df.columns or "Purpose" not in df.columns:
40
+ raise ValueError("Dataset must contain 'Title' and 'Purpose' columns.")
41
+
42
  # Compute similarity against all missions
43
  results = client.sentence_similarity(
44
  {
 
56
  )
57
 
58
  return [
59
+ {"score": float(score), "Title": title, "Purpose": purpose}
60
+ for score, title, purpose in scored[:top_k]
61
  ]
62
 
63