paulcalzada commited on
Commit
2d35fe8
·
1 Parent(s): ad3670e

fixing faiss pointing

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -179,16 +179,20 @@ def ensure_index_downloaded() -> Path:
179
  local_dir=str(CACHE_DIR),
180
  local_dir_use_symlinks=False,
181
  )
 
 
 
 
 
 
 
 
 
182
 
183
- # Prefer INDEX_SUBDIR if present
184
- candidate = Path(snapshot_path) / INDEX_SUBDIR
185
- if candidate.exists() and any(candidate.iterdir()):
186
- print(f"[INFO] Found index files under {candidate}")
187
- return candidate
188
 
189
- # Otherwise use snapshot root
190
- print(f"[WARN] INDEX_SUBDIR='{INDEX_SUBDIR}' not found or empty; using snapshot root.")
191
- return Path(snapshot_path)
192
 
193
  # Keep a lightweight global cache so we don’t reload embeddings on every click
194
  _VECTORSTORE_PATH = None
@@ -204,8 +208,8 @@ def run_generation(spec, use_rag, top_k, model_choice, api_key, temperature, top
204
  return "// Please provide a design specification and your API key.", "", []
205
 
206
  # Prepare agent
207
- faiss_path = get_vectorstore_path()
208
  try:
 
209
  agent = VerilogAgent(
210
  model_id=model_choice,
211
  embedding_id=EMBEDDING_MODEL,
@@ -262,8 +266,8 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
262
  "gpt-4o",
263
  "gpt-4o-mini",
264
  "gpt-4.1",
265
- "gpt-5",
266
- "gpt-5-mini"
267
  ],
268
  value="gpt-4o",
269
  label="Model"
@@ -276,7 +280,6 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
276
  max_new_tokens = gr.Slider(128, 4096, value=768, step=64, label="Max tokens")
277
 
278
  run_btn = gr.Button("Generate Verilog", variant="primary")
279
- # fixing
280
  with gr.Column(scale=3):
281
  gr.Markdown("**Output**")
282
  out_code = gr.Textbox(
@@ -301,4 +304,4 @@ with gr.Blocks(title="DeepV for RTL (Model-Agnostic)") as demo:
301
  )
302
 
303
  if __name__ == "__main__":
304
- demo.launch()
 
179
  local_dir=str(CACHE_DIR),
180
  local_dir_use_symlinks=False,
181
  )
182
+
183
+ # --- START OF FIX ---
184
+ # Walk the downloaded directory to find the index files
185
+ downloaded_dir = Path(snapshot_path)
186
+ for root, dirs, files in os.walk(downloaded_dir):
187
+ if 'index.faiss' in files and 'index.pkl' in files:
188
+ index_path = Path(root)
189
+ print(f"[INFO] Found index files at {index_path}. Using this path.")
190
+ return index_path
191
 
192
+ # If the files are not found, raise an error
193
+ raise FileNotFoundError("FAISS index files (index.faiss and index.pkl) not found in the downloaded dataset.")
194
+ # --- END OF FIX ---
 
 
195
 
 
 
 
196
 
197
  # Keep a lightweight global cache so we don’t reload embeddings on every click
198
  _VECTORSTORE_PATH = None
 
208
  return "// Please provide a design specification and your API key.", "", []
209
 
210
  # Prepare agent
 
211
  try:
212
+ faiss_path = get_vectorstore_path()
213
  agent = VerilogAgent(
214
  model_id=model_choice,
215
  embedding_id=EMBEDDING_MODEL,
 
266
  "gpt-4o",
267
  "gpt-4o-mini",
268
  "gpt-4.1",
269
+ "gpt-5",
270
+ "gpt-5-mini"
271
  ],
272
  value="gpt-4o",
273
  label="Model"
 
280
  max_new_tokens = gr.Slider(128, 4096, value=768, step=64, label="Max tokens")
281
 
282
  run_btn = gr.Button("Generate Verilog", variant="primary")
 
283
  with gr.Column(scale=3):
284
  gr.Markdown("**Output**")
285
  out_code = gr.Textbox(
 
304
  )
305
 
306
  if __name__ == "__main__":
307
+ demo.launch()