mtoft20 commited on
Commit
7e46f8f
Β·
verified Β·
1 Parent(s): 7ae5ce5

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +9 -3
src/streamlit_app.py CHANGED
@@ -5,6 +5,7 @@ from together import Together
5
  import os
6
  import json
7
  from collections import defaultdict
 
8
 
9
  # =============================================================================
10
  # CONFIGURATION - Using Secrets Management
@@ -260,7 +261,10 @@ def get_similar_content(content, n_recommendations=5):
260
  }
261
 
262
  # Debug: Print the title we're searching for
263
- st.write(f"πŸ” Searching for similar content to: {content.get('title')}")
 
 
 
264
 
265
  # URLs for both similarity tables
266
  similarity_table_urls = [
@@ -272,12 +276,14 @@ def get_similar_content(content, n_recommendations=5):
272
 
273
  # Check both tables for similarities
274
  for table_url in similarity_table_urls:
 
275
  params = {
276
- "where": f"(title,eq,\"{content['title']}\")"
277
  }
278
 
279
  # Debug: Print the request details
280
  st.write(f"πŸ“‘ Querying table: {table_url.split('/')[-1]}")
 
281
 
282
  response = requests.get(table_url, headers=headers, params=params)
283
 
@@ -309,7 +315,7 @@ def get_similar_content(content, n_recommendations=5):
309
  for item in similar_items:
310
  # Query main content table for full details
311
  content_params = {
312
- "where": f"(title,eq,\"{item['title']}\")"
313
  }
314
  content_response = requests.get(NOCODB_URL, headers=headers, params=content_params)
315
 
 
5
  import os
6
  import json
7
  from collections import defaultdict
8
+ import re
9
 
10
  # =============================================================================
11
  # CONFIGURATION - Using Secrets Management
 
261
  }
262
 
263
  # Debug: Print the title we're searching for
264
+ title = content.get('title', '')
265
+ # Remove year if it's in parentheses at the end
266
+ clean_title = re.sub(r'\s*\(\d{4}\)\s*$', '', title)
267
+ st.write(f"πŸ” Searching for similar content to: {clean_title}")
268
 
269
  # URLs for both similarity tables
270
  similarity_table_urls = [
 
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,like,\"{clean_title}\")"
282
  }
283
 
284
  # Debug: Print the request details
285
  st.write(f"πŸ“‘ Querying table: {table_url.split('/')[-1]}")
286
+ st.write(f"πŸ” Query params: {params}")
287
 
288
  response = requests.get(table_url, headers=headers, params=params)
289
 
 
315
  for item in similar_items:
316
  # Query main content table for full details
317
  content_params = {
318
+ "where": f"(title,like,\"{item['title']}\")"
319
  }
320
  content_response = requests.get(NOCODB_URL, headers=headers, params=content_params)
321