Spaces:
Paused
Paused
Commit ·
f49efc0
1
Parent(s): ef5ff5a
Clean up obsolete Streamlit files, scratch test scripts, and update dependencies
Browse files- .gitignore +3 -0
- requirements.txt +0 -2
- scratch/test_render.py +0 -21
- streamlit_app.py +0 -91
- web_ui/index.html +2 -10
.gitignore
CHANGED
|
@@ -48,6 +48,9 @@ data/indexes/*.log
|
|
| 48 |
*.key
|
| 49 |
*.pem
|
| 50 |
|
|
|
|
|
|
|
|
|
|
| 51 |
# IDE & OS
|
| 52 |
.vscode/
|
| 53 |
.idea/
|
|
|
|
| 48 |
*.key
|
| 49 |
*.pem
|
| 50 |
|
| 51 |
+
# Scratch & temporary
|
| 52 |
+
scratch/
|
| 53 |
+
|
| 54 |
# IDE & OS
|
| 55 |
.vscode/
|
| 56 |
.idea/
|
requirements.txt
CHANGED
|
@@ -26,5 +26,3 @@ soundfile>=0.12.1
|
|
| 26 |
pytest>=7.4.0
|
| 27 |
tqdm>=4.66.0
|
| 28 |
psutil>=5.9.0
|
| 29 |
-
streamlit>=1.30.0
|
| 30 |
-
|
|
|
|
| 26 |
pytest>=7.4.0
|
| 27 |
tqdm>=4.66.0
|
| 28 |
psutil>=5.9.0
|
|
|
|
|
|
scratch/test_render.py
DELETED
|
@@ -1,21 +0,0 @@
|
|
| 1 |
-
import urllib.request
|
| 2 |
-
import urllib.parse
|
| 3 |
-
import json
|
| 4 |
-
|
| 5 |
-
url = "https://visionquest-1.onrender.com/query"
|
| 6 |
-
|
| 7 |
-
# Test 1: Text Query
|
| 8 |
-
data = urllib.parse.urlencode({"text": "Who was J. Robert Oppenheimer?"}).encode("utf-8")
|
| 9 |
-
req = urllib.request.Request(url, data=data)
|
| 10 |
-
|
| 11 |
-
try:
|
| 12 |
-
res = urllib.request.urlopen(req)
|
| 13 |
-
print("=== TEST 1 (Text Query) ===")
|
| 14 |
-
print("Status:", res.status)
|
| 15 |
-
body_text = res.read().decode("utf-8")
|
| 16 |
-
print("Body preview:", body_text[:300])
|
| 17 |
-
except Exception as e:
|
| 18 |
-
print("=== TEST 1 ERROR ===")
|
| 19 |
-
print(e)
|
| 20 |
-
if hasattr(e, "read"):
|
| 21 |
-
print("Error content:", e.read().decode("utf-8"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
streamlit_app.py
DELETED
|
@@ -1,91 +0,0 @@
|
|
| 1 |
-
"""
|
| 2 |
-
Streamlit App to render the full retro-tropical Command Center UI (web_ui/index.html)
|
| 3 |
-
with base64 embedded assets and backend FastAPI support.
|
| 4 |
-
"""
|
| 5 |
-
import base64
|
| 6 |
-
from pathlib import Path
|
| 7 |
-
import threading
|
| 8 |
-
import os
|
| 9 |
-
import uvicorn
|
| 10 |
-
import streamlit as st
|
| 11 |
-
import streamlit.components.v1 as components
|
| 12 |
-
|
| 13 |
-
# Streamlit Page Config
|
| 14 |
-
st.set_page_config(
|
| 15 |
-
page_title="⚡ VECTOR 2026 — Voice Indic RAG Engine",
|
| 16 |
-
page_icon="⚡",
|
| 17 |
-
layout="wide",
|
| 18 |
-
initial_sidebar_state="collapsed"
|
| 19 |
-
)
|
| 20 |
-
|
| 21 |
-
# Hide Streamlit header/footer padding for full-screen UI experience
|
| 22 |
-
st.markdown("""
|
| 23 |
-
<style>
|
| 24 |
-
#MainMenu {visibility: hidden;}
|
| 25 |
-
footer {visibility: hidden;}
|
| 26 |
-
header {visibility: hidden;}
|
| 27 |
-
.block-container {
|
| 28 |
-
padding-top: 0rem;
|
| 29 |
-
padding-bottom: 0rem;
|
| 30 |
-
padding-left: 0rem;
|
| 31 |
-
padding-right: 0rem;
|
| 32 |
-
max-width: 100%;
|
| 33 |
-
}
|
| 34 |
-
iframe {
|
| 35 |
-
border: none !important;
|
| 36 |
-
width: 100% !important;
|
| 37 |
-
}
|
| 38 |
-
</style>
|
| 39 |
-
""", unsafe_allow_html=True)
|
| 40 |
-
|
| 41 |
-
# Helper to read file as base64
|
| 42 |
-
def get_base64_image(file_path: Path) -> str:
|
| 43 |
-
if file_path.exists():
|
| 44 |
-
with open(file_path, "rb") as f:
|
| 45 |
-
return f"data:image/png;base64,{base64.b64encode(f.read()).decode('utf-8')}"
|
| 46 |
-
return ""
|
| 47 |
-
|
| 48 |
-
# Load and prepare full HTML string
|
| 49 |
-
@st.cache_data
|
| 50 |
-
def get_prepared_html() -> str:
|
| 51 |
-
web_ui_dir = Path(__file__).parent / "web_ui"
|
| 52 |
-
index_file = web_ui_dir / "index.html"
|
| 53 |
-
|
| 54 |
-
if not index_file.exists():
|
| 55 |
-
return "<h1>Error: web_ui/index.html not found</h1>"
|
| 56 |
-
|
| 57 |
-
with open(index_file, "r", encoding="utf-8") as f:
|
| 58 |
-
html = f.read()
|
| 59 |
-
|
| 60 |
-
# Replace relative PNG images with inline base64
|
| 61 |
-
for img_name in ["ironman.png", "thor.png", "cap.png", "spider_gwen.png", "spider_gwen_clean.png", "spider_gwen_cutout.png", "bg_beach.png"]:
|
| 62 |
-
b64_data = get_base64_image(web_ui_dir / img_name)
|
| 63 |
-
if b64_data:
|
| 64 |
-
html = html.replace(f'"{img_name}"', f'"{b64_data}"')
|
| 65 |
-
html = html.replace(f"'{img_name}'", f"'{b64_data}'")
|
| 66 |
-
html = html.replace(f'src="/{img_name}"', f'src="{b64_data}"')
|
| 67 |
-
|
| 68 |
-
return html
|
| 69 |
-
|
| 70 |
-
# Start background FastAPI server for /query, /languages, /health endpoints
|
| 71 |
-
@st.cache_resource
|
| 72 |
-
def start_fastapi_backend():
|
| 73 |
-
def _run():
|
| 74 |
-
import main
|
| 75 |
-
# Disable heavy startup preloads in background thread
|
| 76 |
-
os.environ["ENABLE_PROMPT_GUARD"] = "false"
|
| 77 |
-
uvicorn.run(main.app, host="0.0.0.0", port=7860, log_level="warning")
|
| 78 |
-
|
| 79 |
-
thread = threading.Thread(target=_run, daemon=True)
|
| 80 |
-
thread.start()
|
| 81 |
-
return True
|
| 82 |
-
|
| 83 |
-
# Initialize backend
|
| 84 |
-
try:
|
| 85 |
-
start_fastapi_backend()
|
| 86 |
-
except Exception:
|
| 87 |
-
pass
|
| 88 |
-
|
| 89 |
-
# Render Full Command Center UI
|
| 90 |
-
prepared_html = get_prepared_html()
|
| 91 |
-
components.html(prepared_html, height=1200, scrolling=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
web_ui/index.html
CHANGED
|
@@ -945,14 +945,6 @@
|
|
| 945 |
});
|
| 946 |
searchBtn.addEventListener("click", executeSearch);
|
| 947 |
|
| 948 |
-
function getApiUrl(path) {
|
| 949 |
-
const origin = window.location.origin;
|
| 950 |
-
if (origin.includes("streamlit.app") || origin.includes("localhost:8501")) {
|
| 951 |
-
return "https://visionquest-production-0621.up.railway.app" + path;
|
| 952 |
-
}
|
| 953 |
-
return path;
|
| 954 |
-
}
|
| 955 |
-
|
| 956 |
async function executeSearch() {
|
| 957 |
const text = queryInput.value.trim();
|
| 958 |
if (!text) return;
|
|
@@ -971,7 +963,7 @@
|
|
| 971 |
fieldNoteText.textContent = `"${text}"`;
|
| 972 |
|
| 973 |
try {
|
| 974 |
-
const response = await fetch(
|
| 975 |
if (!response.ok) {
|
| 976 |
const errText = await response.text();
|
| 977 |
let msg = response.statusText || ("HTTP " + response.status);
|
|
@@ -1048,7 +1040,7 @@
|
|
| 1048 |
formData.append("cross_lingual", isCrossLingual ? "true" : "false");
|
| 1049 |
|
| 1050 |
try {
|
| 1051 |
-
const response = await fetch(
|
| 1052 |
if (!response.ok) {
|
| 1053 |
const errText = await response.text();
|
| 1054 |
let msg = response.statusText || ("HTTP " + response.status);
|
|
|
|
| 945 |
});
|
| 946 |
searchBtn.addEventListener("click", executeSearch);
|
| 947 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 948 |
async function executeSearch() {
|
| 949 |
const text = queryInput.value.trim();
|
| 950 |
if (!text) return;
|
|
|
|
| 963 |
fieldNoteText.textContent = `"${text}"`;
|
| 964 |
|
| 965 |
try {
|
| 966 |
+
const response = await fetch("/query", { method: "POST", body: formData });
|
| 967 |
if (!response.ok) {
|
| 968 |
const errText = await response.text();
|
| 969 |
let msg = response.statusText || ("HTTP " + response.status);
|
|
|
|
| 1040 |
formData.append("cross_lingual", isCrossLingual ? "true" : "false");
|
| 1041 |
|
| 1042 |
try {
|
| 1043 |
+
const response = await fetch("/query", { method: "POST", body: formData });
|
| 1044 |
if (!response.ok) {
|
| 1045 |
const errText = await response.text();
|
| 1046 |
let msg = response.statusText || ("HTTP " + response.status);
|