poemsforaphrodite commited on
Commit
3dc03f5
1 Parent(s): 6a06f9a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py CHANGED
@@ -3,6 +3,7 @@ import datetime
3
  import base64
4
  import os
5
  import sys
 
6
 
7
  # Related third-party imports
8
  import streamlit as st
@@ -353,6 +354,18 @@ def show_paginated_dataframe(report, rows_per_page=20, model_type='english'):
353
 
354
  page_data = report.iloc[start_idx:end_idx].reset_index(drop=True)
355
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  for idx, row in page_data.iterrows():
357
  col1, col2, col3, col4, col5, col6, col7, col8 = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
358
  with col1:
@@ -374,6 +387,7 @@ def show_paginated_dataframe(report, rows_per_page=20, model_type='english'):
374
  logger.info(f"Calculating relevancy for row index: {start_idx + idx}")
375
  try:
376
  page_content = fetch_content(row['page'])
 
377
  query = row['query']
378
  relevancy_score = calculate_single_relevancy_score(page_content, query, model_type)
379
  logger.info(f"Relevancy score calculated: {relevancy_score}")
@@ -382,9 +396,16 @@ def show_paginated_dataframe(report, rows_per_page=20, model_type='english'):
382
  st.experimental_rerun()
383
  except Exception as e:
384
  logger.error(f"Error calculating relevancy score: {str(e)}")
 
385
  st.error(f"Error calculating relevancy score: {str(e)}")
 
 
 
 
386
 
387
  return report
 
 
388
  # -------------
389
  # Main Streamlit App Function
390
  # -------------
 
3
  import base64
4
  import os
5
  import sys
6
+ import json
7
 
8
  # Related third-party imports
9
  import streamlit as st
 
354
 
355
  page_data = report.iloc[start_idx:end_idx].reset_index(drop=True)
356
 
357
+ # Display column headers
358
+ col1, col2, col3, col4, col5, col6, col7, col8 = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
359
+ col1.write("**Page**")
360
+ col2.write("**Query**")
361
+ col3.write("**Impressions**")
362
+ col4.write("**Clicks**")
363
+ col5.write("**CTR**")
364
+ col6.write("**Position**")
365
+ col7.write("**Relevancy Score**")
366
+ col8.write("**Action**")
367
+
368
+ # Display data rows
369
  for idx, row in page_data.iterrows():
370
  col1, col2, col3, col4, col5, col6, col7, col8 = st.columns([3, 2, 1, 1, 1, 1, 1, 1])
371
  with col1:
 
387
  logger.info(f"Calculating relevancy for row index: {start_idx + idx}")
388
  try:
389
  page_content = fetch_content(row['page'])
390
+ logger.info(f"Fetched content for {row['page']}: {page_content[:100]}...") # Log the first 100 characters
391
  query = row['query']
392
  relevancy_score = calculate_single_relevancy_score(page_content, query, model_type)
393
  logger.info(f"Relevancy score calculated: {relevancy_score}")
 
396
  st.experimental_rerun()
397
  except Exception as e:
398
  logger.error(f"Error calculating relevancy score: {str(e)}")
399
+ logger.error(f"Error details: {type(e).__name__}, {str(e)}")
400
  st.error(f"Error calculating relevancy score: {str(e)}")
401
+ if isinstance(e, requests.exceptions.RequestException):
402
+ st.error(f"Error fetching content from {row['page']}. Please check if the URL is accessible.")
403
+ elif isinstance(e, json.JSONDecodeError):
404
+ st.error("Error parsing JSON response. The content might not be in the expected format.")
405
 
406
  return report
407
+
408
+ # Make sure to import json at the top of your file
409
  # -------------
410
  # Main Streamlit App Function
411
  # -------------