QalamABD commited on
Commit
477420d
·
verified ·
1 Parent(s): 944106c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import gradio as gr
4
+ from qusai_core.pipeline.middleware import QusaiMiddleware
5
+
6
+ # Configure Logging
7
+ logging.basicConfig(level=logging.INFO, format='%(message)s')
8
+
9
+ # Get Token from environment (Add 'HF_TOKEN' to your Space Secrets)
10
+ hf_token = os.environ.get("HF_TOKEN")
11
+
12
+ # Initialize Middleware with the 72B API Model
13
+ # Competitor note: You can swap this for "meta-llama/Meta-Llama-3-70B-Instruct" if preferred.
14
+ middleware = QusaiMiddleware(
15
+ model_id="Qwen/Qwen2.5-72B-Instruct",
16
+ api_token=hf_token,
17
+ lazy_load=False
18
+ )
19
+
20
+ def chat_interface(message, history, arabic_only):
21
+ if arabic_only:
22
+ message = f"{message} (Please answer strictly in Arabic / العربية)"
23
+ return middleware.process_query(message)
24
+
25
+ # Gradio UI
26
+ with gr.Blocks(title="QUSAI v2 - Mizan (Pro)") as demo:
27
+ gr.Markdown("# 🕌 QUSAI v2 - Quranic Ontological Alignment")
28
+ gr.Markdown("""
29
+ **System Status:**
30
+ - ✅ **Model**: Qwen 2.5 72B (Serverless Inference API)
31
+ - ✅ **Ontology**: v3 Root Topology (Active)
32
+ - ✅ **Bridge**: Universal Concept Map (Active)
33
+ - ⚡ **Tier**: Pro Acceleration Enabled
34
+ """)
35
+
36
+ with gr.Row():
37
+ arabic_check = gr.Checkbox(label="Output in Arabic Only (مخرجات عربية فقط)", value=False)
38
+
39
+ chatbot = gr.ChatInterface(
40
+ fn=chat_interface,
41
+ additional_inputs=[arabic_check],
42
+ type="messages"
43
+ )
44
+
45
+ if __name__ == "__main__":
46
+ logger.info("🚀 Launching Gradio Server on 0.0.0.0:7860")
47
+ demo.launch(server_name="0.0.0.0", server_port=7860)