mtoft20 commited on
Commit
d5dc6d6
·
verified ·
1 Parent(s): c724814

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +23 -5
src/streamlit_app.py CHANGED
@@ -276,9 +276,14 @@ def get_similar_content(content, n_recommendations=5):
276
 
277
  # Check both tables for similarities
278
  for table_url in similarity_table_urls:
279
- # Case-insensitive title match
 
 
 
 
 
280
  params = {
281
- "where": f"(title,eq,\"{clean_title}\")" # Changed back to eq for exact match
282
  }
283
 
284
  # Debug: Print the request details
@@ -289,8 +294,16 @@ def get_similar_content(content, n_recommendations=5):
289
 
290
  # Debug: Print response status and content
291
  st.write(f"📥 Response status: {response.status_code}")
 
 
 
 
 
 
 
 
292
  if response.status_code == 200:
293
- data = response.json()
294
  st.write(f"📊 Found {len(data.get('list', []))} matches in table")
295
 
296
  if data and len(data.get('list', [])) > 0:
@@ -313,9 +326,14 @@ def get_similar_content(content, n_recommendations=5):
313
  # Get full content details for each similar item
314
  similar_content = []
315
  for item in similar_items:
316
- # Query main content table for full details
 
 
 
 
 
317
  content_params = {
318
- "where": f"(title,eq,\"{item['title']}\")" # Changed back to eq for exact match
319
  }
320
  content_response = requests.get(NOCODB_URL, headers=headers, params=content_params)
321
 
 
276
 
277
  # Check both tables for similarities
278
  for table_url in similarity_table_urls:
279
+ # Format query according to NocoDB API specs
280
+ where_condition = {
281
+ "title": {
282
+ "eq": clean_title
283
+ }
284
+ }
285
  params = {
286
+ "where": json.dumps(where_condition)
287
  }
288
 
289
  # Debug: Print the request details
 
294
 
295
  # Debug: Print response status and content
296
  st.write(f"📥 Response status: {response.status_code}")
297
+
298
+ # Debug: Print raw response
299
+ try:
300
+ response_json = response.json()
301
+ st.write("Raw response:", response_json)
302
+ except Exception as e:
303
+ st.write("Could not parse response as JSON:", response.text)
304
+
305
  if response.status_code == 200:
306
+ data = response_json
307
  st.write(f"📊 Found {len(data.get('list', []))} matches in table")
308
 
309
  if data and len(data.get('list', [])) > 0:
 
326
  # Get full content details for each similar item
327
  similar_content = []
328
  for item in similar_items:
329
+ # Format query for content lookup
330
+ content_where = {
331
+ "title": {
332
+ "eq": item['title']
333
+ }
334
+ }
335
  content_params = {
336
+ "where": json.dumps(content_where)
337
  }
338
  content_response = requests.get(NOCODB_URL, headers=headers, params=content_params)
339