Sagar Sanghani
updates cache with gemini which seems to be much better
ee7a47a
raw
history blame
1.05 kB
import pandas as pd
import os
class CSVSCache:
def __init__(self, filename="results.csv"):
self.filename = filename
self.df = self._load_cache()
def _load_cache(self):
if os.path.exists(self.filename):
return pd.read_csv(self.filename)
return pd.DataFrame(columns=["task_id", "question", "answer"])
def _save_cache(self):
self.df.to_csv(self.filename, index=False)
def get_all_entries(self):
return self.df
def get_answer(self, question):
match = self.df[self.df['question'] == question].head()
# Check if any matches were found
if not match.empty:
return match['answer'].iloc[0]
else:
return "unknown"
def main():
csv = CSVSCache()
print("done")
q = "Where were the Vietnamese specimens described by Kuznetzov in Nedoshivina's 2010 paper eventually deposited? Just give me the city name without abbreviations."
print(csv.get_answer(q))
if __name__ == "__main__":
main()