rivapereira123 commited on
Commit
b7844f9
·
verified ·
1 Parent(s): 85b92d9

Update core/agents/model_doc_sync.py

Browse files
Files changed (1) hide show
  1. core/agents/model_doc_sync.py +13 -10
core/agents/model_doc_sync.py CHANGED
@@ -150,32 +150,35 @@ def store_pricing(model: str, data: Dict[str, Any]):
150
  return False
151
 
152
  def sync_pricing(model_names: list):
153
- """Added verification step"""
 
 
 
 
 
 
154
  for model in model_names:
155
  try:
156
  model = model.strip()
157
  logging.info(f"\n🔄 Syncing {model}...")
158
-
159
  docs = search_model_docs(model)
160
  if not docs:
161
  logging.warning(f"No docs found for {model}")
162
  continue
163
-
164
  pricing = summarize_pricing(docs)
165
  if not pricing:
 
166
  continue
167
-
168
- # Store and verify
169
- if store_pricing(model, pricing):
170
- # Immediate fetch verification
171
- index = init_pinecone() # Add this line inside the loop
172
- stored_data = index.fetch(ids=[model.lower()])
173
 
 
 
174
  if stored_data.vectors:
175
  logging.info(f"✅ Verified storage for {model}")
176
  else:
177
  logging.error(f"❌ Storage failed for {model}")
178
-
179
  except Exception as e:
180
  logging.error(f"Critical error with {model}: {str(e)}")
181
 
 
150
  return False
151
 
152
  def sync_pricing(model_names: list):
153
+ """Fetch, summarize, and store model pricing info"""
154
+ from typing import Dict, Any
155
+ import logging
156
+
157
+ logging.basicConfig(level=logging.INFO)
158
+ index = init_pinecone()
159
+
160
  for model in model_names:
161
  try:
162
  model = model.strip()
163
  logging.info(f"\n🔄 Syncing {model}...")
164
+
165
  docs = search_model_docs(model)
166
  if not docs:
167
  logging.warning(f"No docs found for {model}")
168
  continue
169
+
170
  pricing = summarize_pricing(docs)
171
  if not pricing:
172
+ logging.error(f"No pricing extracted for {model}")
173
  continue
 
 
 
 
 
 
174
 
175
+ if store_pricing(model, pricing):
176
+ stored_data = index.fetch(ids=[model.lower()], namespace="pricing")
177
  if stored_data.vectors:
178
  logging.info(f"✅ Verified storage for {model}")
179
  else:
180
  logging.error(f"❌ Storage failed for {model}")
181
+
182
  except Exception as e:
183
  logging.error(f"Critical error with {model}: {str(e)}")
184