Teotonix commited on
Commit
3891dcb
·
verified ·
1 Parent(s): 86117b0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +105 -11
app.py CHANGED
@@ -27,20 +27,114 @@ def llm_reply(user_text: str) -> str:
27
  def chat_fn(message, history):
28
  history = history or []
29
  history.append({"role": "user", "content": message})
30
-
31
  try:
32
  reply = llm_reply(message)
33
  except Exception as e:
34
- reply = f"⚠️ Router hata: {e}"
35
-
36
  history.append({"role": "assistant", "content": reply})
37
- return history
38
-
39
- with gr.Blocks(title="MaindAI") as demo:
40
- gr.Image("logo.png", height=120, show_label=False)
41
- gr.Markdown("## 💙 MaindAI — Chat")
42
- chatbot = gr.Chatbot(value=[])
43
- msg = gr.Textbox(placeholder="Sor...", show_label=False)
44
- msg.submit(chat_fn, [msg, chatbot], chatbot)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  demo.launch()
 
27
  def chat_fn(message, history):
28
  history = history or []
29
  history.append({"role": "user", "content": message})
 
30
  try:
31
  reply = llm_reply(message)
32
  except Exception as e:
33
+ reply = f"⚠️ Hata: {e}"
 
34
  history.append({"role": "assistant", "content": reply})
35
+ return history, ""
36
+
37
+ CSS = """
38
+ :root{
39
+ --bg:#050b1a;
40
+ --panel:#0a1636;
41
+ --panel2:#0c1d46;
42
+ --stroke:rgba(56,189,248,.25);
43
+ --glow:rgba(56,189,248,.25);
44
+ --txt:#e6f1ff;
45
+ --muted:#93c5fd;
46
+ --blue:#38bdf8;
47
+ }
48
+ body, .gradio-container{
49
+ background: radial-gradient(1200px 800px at 20% 0%, rgba(56,189,248,.18), transparent 55%),
50
+ radial-gradient(900px 700px at 90% 20%, rgba(99,102,241,.18), transparent 55%),
51
+ var(--bg) !important;
52
+ color: var(--txt) !important;
53
+ }
54
+ #wrap{
55
+ max-width: 980px;
56
+ margin: 0 auto;
57
+ }
58
+ #topbar{
59
+ display:flex; align-items:center; gap:14px;
60
+ padding: 14px 16px;
61
+ background: linear-gradient(180deg, rgba(10,22,54,.9), rgba(10,22,54,.55));
62
+ border: 1px solid var(--stroke);
63
+ border-radius: 16px;
64
+ box-shadow: 0 0 0 1px rgba(56,189,248,.06), 0 20px 60px rgba(0,0,0,.35);
65
+ }
66
+ #brand h1{ margin:0; font-size: 20px; letter-spacing:.4px; }
67
+ #brand p{ margin:2px 0 0; color: var(--muted); font-size: 12px; }
68
+
69
+ #card{
70
+ margin-top: 14px;
71
+ padding: 14px;
72
+ background: linear-gradient(180deg, rgba(12,29,70,.85), rgba(10,22,54,.6));
73
+ border: 1px solid var(--stroke);
74
+ border-radius: 18px;
75
+ box-shadow: 0 0 0 1px rgba(56,189,248,.05), 0 30px 90px rgba(0,0,0,.45);
76
+ }
77
+
78
+ /* Chat area */
79
+ #chat .wrap{
80
+ border-radius: 14px;
81
+ }
82
+ .gr-chatbot{
83
+ background: transparent !important;
84
+ }
85
+ .gr-chatbot .message{
86
+ border-radius: 14px !important;
87
+ border: 1px solid rgba(56,189,248,.18) !important;
88
+ box-shadow: 0 0 20px rgba(56,189,248,.08);
89
+ }
90
+ .gr-chatbot .message.user{
91
+ background: rgba(56,189,248,.08) !important;
92
+ }
93
+ .gr-chatbot .message.bot{
94
+ background: rgba(99,102,241,.08) !important;
95
+ }
96
+
97
+ /* Input row */
98
+ #inputrow{
99
+ margin-top: 10px;
100
+ gap: 10px;
101
+ }
102
+ #sendbtn button{
103
+ background: linear-gradient(90deg, rgba(56,189,248,.95), rgba(99,102,241,.95)) !important;
104
+ border: 1px solid rgba(56,189,248,.35) !important;
105
+ border-radius: 14px !important;
106
+ box-shadow: 0 0 30px rgba(56,189,248,.18);
107
+ }
108
+ #sendbtn button:hover{
109
+ filter: brightness(1.05);
110
+ }
111
+ textarea, input, .gr-text-input textarea{
112
+ background: rgba(5,11,26,.55) !important;
113
+ border: 1px solid rgba(56,189,248,.22) !important;
114
+ border-radius: 14px !important;
115
+ color: var(--txt) !important;
116
+ }
117
+ """
118
+
119
+ with gr.Blocks(css=CSS, title="MaindAI") as demo:
120
+ with gr.Column(elem_id="wrap"):
121
+ with gr.Row(elem_id="topbar"):
122
+ gr.Image("logo.png", show_label=False, height=58, width=58, container=False)
123
+ with gr.Column(elem_id="brand"):
124
+ gr.Markdown("# MAIND AI")
125
+ gr.Markdown("<p>Neon mavi tema • HF Router • SmolLM3-3B</p>")
126
+
127
+ with gr.Column(elem_id="card"):
128
+ chatbot = gr.Chatbot(value=[], elem_id="chat", height=420)
129
+ with gr.Row(elem_id="inputrow"):
130
+ msg = gr.Textbox(
131
+ placeholder="Bir şey sor…",
132
+ show_label=False,
133
+ scale=8
134
+ )
135
+ send = gr.Button("Gönder", elem_id="sendbtn", scale=2)
136
+
137
+ send.click(chat_fn, [msg, chatbot], [chatbot, msg])
138
+ msg.submit(chat_fn, [msg, chatbot], [chatbot, msg])
139
 
140
  demo.launch()