rajat5ranjan commited on
Commit
b0051f3
·
verified ·
1 Parent(s): af5fb28

Update stock_vector_db.py

Browse files
Files changed (1) hide show
  1. stock_vector_db.py +18 -3
stock_vector_db.py CHANGED
@@ -103,13 +103,28 @@ class HFVectorDB:
103
  return []
104
  return self.index.similarity_search(query, k=k)
105
 
106
- def save_top_picks_json(top_picks, date, path="top_picks.jsonl"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  record = {
108
  "date": date.isoformat(),
109
  "top_picks": top_picks
110
  }
111
- with open(path, "a") as f:
112
- f.write(json.dumps(record) + "\n")
113
  st.sidebar.write(f"✅ Saved top picks to {path}")
114
 
115
  def add_top_picks_to_vector_db(vector_db, top_picks, date):
 
103
  return []
104
  return self.index.similarity_search(query, k=k)
105
 
106
+ def upload_top_picks_jsonl(self, path="top_picks.jsonl"):
107
+ """Uploads the top_picks.jsonl to the HF dataset repo"""
108
+ try:
109
+ self.api.upload_file(
110
+ path_or_fileobj=path,
111
+ path_in_repo="top_picks.jsonl",
112
+ repo_id=self.hf_repo_id,
113
+ repo_type="dataset",
114
+ commit_message="Update top_picks.jsonl"
115
+ )
116
+ st.sidebar.write("✅ Uploaded top_picks.jsonl to HF repo")
117
+ except Exception as e:
118
+ st.sidebar.error(f"❌ Error uploading top_picks.jsonl: {e}")
119
+
120
+
121
+
122
+ def save_top_picks_json(vector_db,top_picks, date, path="top_picks.jsonl"):
123
  record = {
124
  "date": date.isoformat(),
125
  "top_picks": top_picks
126
  }
127
+ vector_db.upload_top_picks_jsonl(path)
 
128
  st.sidebar.write(f"✅ Saved top picks to {path}")
129
 
130
  def add_top_picks_to_vector_db(vector_db, top_picks, date):