Skip to content

Conversation

PrinceSajjadHussain
Copy link

The VectorDB class's load_db method loads the query_cache as a JSON string and converts it to a dictionary using json.loads, but save_db uses json.dumps to store the query_cache dictionary back into a string format. This can be avoided for simplicity.

Applied fixes:
--- a/skills\text_to_sql\evaluation\vectordb.py
+++ b/skills\text_to_sql\evaluation\vectordb.py
@@ -13,7 +13,7 @@
if os.path.exists(self.db_path):
with open(self.db_path, "rb") as file:
data = pickle.load(file)

  •        self.embeddings, self.metadata, self.query_cache = data['embeddings'], data['metadata'], json.loads(data['query_cache'])
    
  •        self.embeddings, self.metadata, self.query_cache = data['embeddings'], data['metadata'], data['query_cache']
       else:
           self.embeddings, self.metadata, self.query_cache = [], [], {}
    

@@ -37,4 +37,4 @@

 def save_db(self):
     with open(self.db_path, "wb") as file:
  •        pickle.dump({"embeddings": self.embeddings, "metadata": self.metadata, 
    
  •                     "query_cache": json.dumps(self.query_cache)}, file)
    
  •        pickle.dump({"embeddings": self.embeddings, "metadata": self.metadata, "query_cache": self.query_cache}, file)
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant