Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,7 +39,8 @@ except Exception as e:
|
|
| 39 |
|
| 40 |
# ββ v2 agent ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 41 |
try:
|
| 42 |
-
|
|
|
|
| 43 |
AGENT_V2_OK = True
|
| 44 |
print("Step 3b: v2 agent imported OK")
|
| 45 |
except Exception as e:
|
|
@@ -47,6 +48,7 @@ except Exception as e:
|
|
| 47 |
agent_v2 = None
|
| 48 |
AGENT_V2_OK = False
|
| 49 |
def clean_thread_history_v2(tid): pass
|
|
|
|
| 50 |
|
| 51 |
# ββ constants ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 52 |
DATA_DIR = Path("data")
|
|
@@ -242,9 +244,9 @@ def _build_v2_cluster_table() -> pd.DataFrame:
|
|
| 242 |
str(s.get("label", "Cluster {}".format(s.get("cluster_id", "")))),
|
| 243 |
int(s.get("paper_count", 0)),
|
| 244 |
str(s.get("vote_agreement", "")),
|
| 245 |
-
str(s.get("
|
| 246 |
-
str(s.get("
|
| 247 |
-
str(s.get("
|
| 248 |
str(" | ".join(s.get("top3_titles", [])[:2])),
|
| 249 |
], summaries))
|
| 250 |
cols = ["#", "Cluster Label", "Papers", "Vote Agreement",
|
|
@@ -305,6 +307,10 @@ def handle_file_upload(file_path) -> str:
|
|
| 305 |
|
| 306 |
def reset_all_data() -> tuple:
|
| 307 |
import shutil as _shutil
|
|
|
|
|
|
|
|
|
|
|
|
|
| 308 |
if DATA_DIR.exists():
|
| 309 |
_shutil.rmtree(str(DATA_DIR))
|
| 310 |
DATA_DIR.mkdir(exist_ok=True)
|
|
@@ -866,6 +872,8 @@ with gr.Blocks(
|
|
| 866 |
"- `comparison_v2.csv` β one row per paper with cluster + PAJAIS\n"
|
| 867 |
"- `cluster_audit.csv` β full LLM voting record, per paper\n"
|
| 868 |
"- `narrative_v2.txt` β 500-word Section 7 discussion\n"
|
|
|
|
|
|
|
| 869 |
)
|
| 870 |
download_files = gr.File(
|
| 871 |
label="Output Files", file_count="multiple", interactive=False,
|
|
@@ -949,7 +957,7 @@ with gr.Blocks(
|
|
| 949 |
outputs=[table_status],
|
| 950 |
)
|
| 951 |
check_v2_btn.click(
|
| 952 |
-
fn=check_status,
|
| 953 |
inputs=[current_mode_state],
|
| 954 |
outputs=[table_status],
|
| 955 |
)
|
|
|
|
| 39 |
|
| 40 |
# ββ v2 agent ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 41 |
try:
|
| 42 |
+
|
| 43 |
+
from agent_v2 import agent_v2, clean_thread_history_v2, reset_thread_v2
|
| 44 |
AGENT_V2_OK = True
|
| 45 |
print("Step 3b: v2 agent imported OK")
|
| 46 |
except Exception as e:
|
|
|
|
| 48 |
agent_v2 = None
|
| 49 |
AGENT_V2_OK = False
|
| 50 |
def clean_thread_history_v2(tid): pass
|
| 51 |
+
def reset_thread_v2(tid): pass
|
| 52 |
|
| 53 |
# ββ constants ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 54 |
DATA_DIR = Path("data")
|
|
|
|
| 244 |
str(s.get("label", "Cluster {}".format(s.get("cluster_id", "")))),
|
| 245 |
int(s.get("paper_count", 0)),
|
| 246 |
str(s.get("vote_agreement", "")),
|
| 247 |
+
str(s.get("llm_vote_1_MISTRAL", "")),
|
| 248 |
+
str(s.get("llm_vote_2_OPENAI", "")),
|
| 249 |
+
str(s.get("llm_vote_3_GROQ", "")),
|
| 250 |
str(" | ".join(s.get("top3_titles", [])[:2])),
|
| 251 |
], summaries))
|
| 252 |
cols = ["#", "Cluster Label", "Papers", "Vote Agreement",
|
|
|
|
| 307 |
|
| 308 |
def reset_all_data() -> tuple:
|
| 309 |
import shutil as _shutil
|
| 310 |
+
try:
|
| 311 |
+
reset_thread_v2("default")
|
| 312 |
+
except Exception:
|
| 313 |
+
pass
|
| 314 |
if DATA_DIR.exists():
|
| 315 |
_shutil.rmtree(str(DATA_DIR))
|
| 316 |
DATA_DIR.mkdir(exist_ok=True)
|
|
|
|
| 872 |
"- `comparison_v2.csv` β one row per paper with cluster + PAJAIS\n"
|
| 873 |
"- `cluster_audit.csv` β full LLM voting record, per paper\n"
|
| 874 |
"- `narrative_v2.txt` β 500-word Section 7 discussion\n"
|
| 875 |
+
"> π‘ **Cache:** `data/v2/llm_cache/` stores LLM responses β "
|
| 876 |
+
"delete this folder to force fresh labels on re-run.\n"
|
| 877 |
)
|
| 878 |
download_files = gr.File(
|
| 879 |
label="Output Files", file_count="multiple", interactive=False,
|
|
|
|
| 957 |
outputs=[table_status],
|
| 958 |
)
|
| 959 |
check_v2_btn.click(
|
| 960 |
+
fn=lambda: check_status("v2"),
|
| 961 |
inputs=[current_mode_state],
|
| 962 |
outputs=[table_status],
|
| 963 |
)
|