File size: 1,715 Bytes
d66c0a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
HuggingFace Spaces - Gradio SDK entry point.

Ye file sirf ek thin wrapper hai:
- Asli UI (HTML/CSS/JS) bilkul wesa hi serve hoti hai jesa pehle tha
- FastAPI backend sab kuch handle karta hai
- Gradio sirf HuggingFace Spaces ke liye mount kiya gaya hai
"""
import gradio as gr
import uvicorn
from backend.app import app as northstar_app

# Minimal Gradio interface - sirf HuggingFace Spaces SDK ko satisfy karne ke liye
# Asli UI / pe serve hoti hai (static/index.html)
with gr.Blocks(title="Northstar Knowledge Assistant") as _gradio_demo:
    gr.HTML("""
<style>
  body { margin: 0; padding: 0; }
  .redirect-box {
    display: flex; align-items: center; justify-content: center;
    height: 100vh; font-family: sans-serif; color: #666;
    flex-direction: column; gap: 12px;
  }
  .spinner {
    width: 32px; height: 32px;
    border: 3px solid #e0d8f0;
    border-top-color: #6955c7;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
</style>
<script>
  // Redirect to our custom UI immediately
  window.location.replace('/');
</script>
<div class="redirect-box">
  <div class="spinner"></div>
  <span>Loading Northstar Knowledge Assistant...</span>
</div>
""")

# Gradio ko apne FastAPI app ke andar mount karo
# Ye HuggingFace Spaces Gradio SDK ke saath compatibility deta hai
# jabke asli custom HTML/CSS/JS UI bilkul wese kaam karti hai
app = gr.mount_gradio_app(northstar_app, _gradio_demo, path="/__gradio__")

if __name__ == "__main__":
    uvicorn.run(
        app,
        host="0.0.0.0",
        port=7860,
        workers=1,
        proxy_headers=True,
        forwarded_allow_ips="*",
        access_log=False,
    )