Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,11 +8,11 @@ manages the application lifecycle including initialization and cleanup.
|
|
| 8 |
|
| 9 |
import streamlit as st
|
| 10 |
import time
|
| 11 |
-
import json
|
| 12 |
import os
|
| 13 |
import logging
|
| 14 |
import atexit
|
| 15 |
-
import
|
|
|
|
| 16 |
from pathlib import Path
|
| 17 |
|
| 18 |
# Configure logging first, before other imports
|
|
@@ -29,14 +29,10 @@ if not os.environ.get("OPENAI_API_KEY"):
|
|
| 29 |
|
| 30 |
# Import our modules
|
| 31 |
from utils.models import initialize_models
|
| 32 |
-
from utils.performance import PerformanceTracker
|
| 33 |
|
| 34 |
# Import agent functionality
|
| 35 |
import agent
|
| 36 |
|
| 37 |
-
# Initialize performance tracker
|
| 38 |
-
performance_tracker = PerformanceTracker()
|
| 39 |
-
|
| 40 |
# Ensure data directory exists
|
| 41 |
data_dir = Path("data")
|
| 42 |
if not data_dir.exists():
|
|
@@ -252,7 +248,7 @@ st.markdown("### Enter a claim to verify")
|
|
| 252 |
def on_input_change():
|
| 253 |
st.session_state.input_content = st.session_state.claim_input_area
|
| 254 |
|
| 255 |
-
# Input area with callback
|
| 256 |
claim_input = st.text_area("",
|
| 257 |
value=st.session_state.input_content,
|
| 258 |
height=100,
|
|
@@ -473,7 +469,6 @@ else:
|
|
| 473 |
if isinstance(evidence, str):
|
| 474 |
# Try to parse string as a list
|
| 475 |
try:
|
| 476 |
-
import ast
|
| 477 |
parsed_evidence = ast.literal_eval(evidence)
|
| 478 |
if isinstance(parsed_evidence, list):
|
| 479 |
evidence = parsed_evidence
|
|
@@ -519,7 +514,7 @@ else:
|
|
| 519 |
|
| 520 |
# Only show evidence tabs if we have evidence
|
| 521 |
if evidence and any(ev for ev in evidence if ev):
|
| 522 |
-
# Create tabs for supporting and contradicting evidence only
|
| 523 |
evidence_tabs = st.tabs(["Supporting Evidence", "Contradicting Evidence", "Source Details"])
|
| 524 |
|
| 525 |
# Supporting Evidence tab
|
|
@@ -564,12 +559,10 @@ else:
|
|
| 564 |
source = "Unknown"
|
| 565 |
# Extract source info from evidence text
|
| 566 |
if "URL:" in ev:
|
| 567 |
-
import re
|
| 568 |
url_match = re.search(r'URL: https?://(?:www\.)?([^/]+)', ev)
|
| 569 |
if url_match:
|
| 570 |
source = url_match.group(1)
|
| 571 |
elif "Source:" in ev:
|
| 572 |
-
import re
|
| 573 |
source_match = re.search(r'Source: ([^,]+)', ev)
|
| 574 |
if source_match:
|
| 575 |
source = source_match.group(1)
|
|
|
|
| 8 |
|
| 9 |
import streamlit as st
|
| 10 |
import time
|
|
|
|
| 11 |
import os
|
| 12 |
import logging
|
| 13 |
import atexit
|
| 14 |
+
import ast
|
| 15 |
+
import re
|
| 16 |
from pathlib import Path
|
| 17 |
|
| 18 |
# Configure logging first, before other imports
|
|
|
|
| 29 |
|
| 30 |
# Import our modules
|
| 31 |
from utils.models import initialize_models
|
|
|
|
| 32 |
|
| 33 |
# Import agent functionality
|
| 34 |
import agent
|
| 35 |
|
|
|
|
|
|
|
|
|
|
| 36 |
# Ensure data directory exists
|
| 37 |
data_dir = Path("data")
|
| 38 |
if not data_dir.exists():
|
|
|
|
| 248 |
def on_input_change():
|
| 249 |
st.session_state.input_content = st.session_state.claim_input_area
|
| 250 |
|
| 251 |
+
# Input area with callback
|
| 252 |
claim_input = st.text_area("",
|
| 253 |
value=st.session_state.input_content,
|
| 254 |
height=100,
|
|
|
|
| 469 |
if isinstance(evidence, str):
|
| 470 |
# Try to parse string as a list
|
| 471 |
try:
|
|
|
|
| 472 |
parsed_evidence = ast.literal_eval(evidence)
|
| 473 |
if isinstance(parsed_evidence, list):
|
| 474 |
evidence = parsed_evidence
|
|
|
|
| 514 |
|
| 515 |
# Only show evidence tabs if we have evidence
|
| 516 |
if evidence and any(ev for ev in evidence if ev):
|
| 517 |
+
# Create tabs for supporting and contradicting evidence only
|
| 518 |
evidence_tabs = st.tabs(["Supporting Evidence", "Contradicting Evidence", "Source Details"])
|
| 519 |
|
| 520 |
# Supporting Evidence tab
|
|
|
|
| 559 |
source = "Unknown"
|
| 560 |
# Extract source info from evidence text
|
| 561 |
if "URL:" in ev:
|
|
|
|
| 562 |
url_match = re.search(r'URL: https?://(?:www\.)?([^/]+)', ev)
|
| 563 |
if url_match:
|
| 564 |
source = url_match.group(1)
|
| 565 |
elif "Source:" in ev:
|
|
|
|
| 566 |
source_match = re.search(r'Source: ([^,]+)', ev)
|
| 567 |
if source_match:
|
| 568 |
source = source_match.group(1)
|