Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import requests | |
| st.title("TrialGPT API Tester π") | |
| api_base = "http://localhost:8000" | |
| # --- Section 1: /retrieve --- | |
| st.header("π /retrieve") | |
| query_text = st.text_input("Enter your clinical query:", "Obesity treatment for children") | |
| if st.button("Search Trials"): | |
| res = requests.post(f"{api_base}/retrieve", json={"text": query_text}) | |
| if res.ok: | |
| results = res.json()["matched_trials"] | |
| st.success(f"β Found {len(results)} trials") | |
| for trial in results: | |
| st.json(trial) | |
| else: | |
| st.error("β Error retrieving trials") | |
| # --- Section 2: /extract-timeline/ --- | |
| st.header("π /extract-timeline/") | |
| timeline_text = st.text_area("Enter study text for timeline extraction:", "This study includes a 2-week screening, 12-week treatment, and 6-week follow-up.") | |
| if st.button("Extract Timeline"): | |
| res = requests.post(f"{api_base}/extract-timeline/", json={"text": timeline_text}) | |
| if res.ok: | |
| st.write("π Timeline:") | |
| st.json(res.json()) | |
| else: | |
| st.error("β Error extracting timeline") | |
| # --- Section 3: /trial/{nct_id} --- | |
| st.header("π¬ /trial/{nct_id}") | |
| trial_id = st.text_input("Enter NCT ID:", "NCT01234567") | |
| if st.button("Get Trial Details"): | |
| res = requests.get(f"{api_base}/trial/{trial_id}") | |
| if res.ok: | |
| st.write("π Trial Details:") | |
| st.json(res.json()) | |
| else: | |
| st.error("β Error fetching trial details") | |