NKessler commited on
Commit
81cf330
·
verified ·
1 Parent(s): ce76568

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
app.py CHANGED
@@ -18,6 +18,8 @@ ARTICLE_B = """Tech industry leaders and economists are sounding the alarm over
18
  URL_A = "https://www.foxnews.com/live-news/trump-iran-israel-war-updates-march-30"
19
  URL_B = "https://edition.cnn.com/2026/03/30/world/live-news/iran-war-us-israel-trump"
20
 
 
 
21
  # Initialize the AI model
22
  GROQ_API_KEY = st.secrets.get("GROQ_API_KEY")
23
 
@@ -245,15 +247,15 @@ def check_contradiction(text_a: str, text_b: str) -> dict:
245
  print(f"Error in contradiction check: {e}")
246
  result = {}
247
  return {"relationship": result.get("relationship", "NEUTRAL"), "confidence": result.get("confidence", 0.0)}
248
-
249
-
250
- # USER INTERFACE
251
- st.set_page_config(page_title="FrameVis | Media Framing", layout="wide")
252
 
253
- if not GROQ_API_KEY:
254
- st.warning("Groq API Key Missing.")
255
- st.stop()
256
 
 
 
 
 
257
  st.markdown("""
258
  <style>
259
  #MainMenu {visibility: hidden;}
@@ -263,6 +265,7 @@ st.markdown("""
263
  .block-container {
264
  padding-top: 2rem;
265
  padding-bottom: 2rem;
 
266
  }
267
 
268
  [data-testid="stMetric"] {
@@ -282,7 +285,10 @@ st.markdown("""
282
  [data-testid="stMetricValue"] > div {
283
  color: #0f172a;
284
  font-weight: 700 !important;
285
- font-size: 1.8rem !important;
 
 
 
286
  }
287
 
288
  [data-testid="stMetricLabel"] > div {
@@ -346,9 +352,9 @@ if execute_analysis:
346
  with st.spinner("Analyzing both sources."):
347
  try:
348
  with concurrent.futures.ThreadPoolExecutor() as executor:
349
- future_a = executor.submit(analyze_article, text_a_clean)
350
- future_b = executor.submit(analyze_article, text_b_clean)
351
- future_nli = executor.submit(check_contradiction, text_a_clean, text_b_clean)
352
 
353
  st.session_state.results_a = future_a.result()
354
  st.session_state.results_b = future_b.result()
 
18
  URL_A = "https://www.foxnews.com/live-news/trump-iran-israel-war-updates-march-30"
19
  URL_B = "https://edition.cnn.com/2026/03/30/world/live-news/iran-war-us-israel-trump"
20
 
21
+ st.set_page_config(page_title="FrameVis | Media Framing", layout="wide")
22
+
23
  # Initialize the AI model
24
  GROQ_API_KEY = st.secrets.get("GROQ_API_KEY")
25
 
 
247
  print(f"Error in contradiction check: {e}")
248
  result = {}
249
  return {"relationship": result.get("relationship", "NEUTRAL"), "confidence": result.get("confidence", 0.0)}
 
 
 
 
250
 
251
+ @st.cache_data(show_spinner=False)
252
+ def get_cached_analysis(text: str) -> dict:
253
+ return analyze_article(text)
254
 
255
+ @st.cache_data(show_spinner=False)
256
+ def get_cached_contradiction(text_a: str, text_b: str) -> dict:
257
+ return check_contradiction(text_a, text_b)
258
+
259
  st.markdown("""
260
  <style>
261
  #MainMenu {visibility: hidden;}
 
265
  .block-container {
266
  padding-top: 2rem;
267
  padding-bottom: 2rem;
268
+ max-width: 1200px;
269
  }
270
 
271
  [data-testid="stMetric"] {
 
285
  [data-testid="stMetricValue"] > div {
286
  color: #0f172a;
287
  font-weight: 700 !important;
288
+ font-size: 1.5rem !important;
289
+ white-space: normal !important;
290
+ line-height: 1.2 !important;
291
+ overflow-wrap: break-word;
292
  }
293
 
294
  [data-testid="stMetricLabel"] > div {
 
352
  with st.spinner("Analyzing both sources."):
353
  try:
354
  with concurrent.futures.ThreadPoolExecutor() as executor:
355
+ future_a = executor.submit(get_cached_analysis, text_a_clean)
356
+ future_b = executor.submit(get_cached_analysis, text_b_clean)
357
+ future_nli = executor.submit(get_cached_contradiction, text_a_clean, text_b_clean)
358
 
359
  st.session_state.results_a = future_a.result()
360
  st.session_state.results_b = future_b.result()