Zenkad commited on
Commit
5dba98f
·
verified ·
1 Parent(s): 671b848

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +55 -0
  2. requirements.txt.txt +2 -0
app.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, requests, gradio as gr
2
+
3
+ # Hugging Face API bağlantısı
4
+ API_URL = "https://api-inference.huggingface.co/models/tiiuae/falcon-7b-instruct"
5
+ HF_TOKEN = os.getenv("HF_TOKEN")
6
+ HEADERS = {"Authorization": f"Bearer {HF_TOKEN}"}
7
+
8
+ # Ana sohbet fonksiyonu
9
+ def chat(message, history):
10
+ if not message:
11
+ return history, history
12
+
13
+ history = history or []
14
+ prompt = "Kullanıcı: " + message + "\nZenkaMind:"
15
+
16
+ try:
17
+ response = requests.post(API_URL,
18
+ headers=HEADERS,
19
+ json={"inputs": prompt, "parameters": {"max_new_tokens": 256, "temperature": 0.7}},
20
+ timeout=60
21
+ )
22
+ if response.status_code != 200:
23
+ reply = f"⚠️ Model hatası ({response.status_code})"
24
+ else:
25
+ result = response.json()
26
+ reply = result[0]["generated_text"].split("ZenkaMind:")[-1].strip()
27
+ except Exception as e:
28
+ reply = f"❌ Sunucu hatası: {e}"
29
+
30
+ history.append((message, reply))
31
+ return history, history
32
+
33
+
34
+ # Tema ve arayüz
35
+ theme = gr.themes.Soft(
36
+ primary_hue="cyan",
37
+ secondary_hue="indigo"
38
+ ).set(
39
+ body_background_fill="#0f172a",
40
+ block_background_fill="#1e293b",
41
+ block_label_text_color="#f8fafc"
42
+ )
43
+
44
+ with gr.Blocks(theme=theme, title="ZenkaMind v16") as demo:
45
+ gr.Markdown("<h1 style='text-align:center;color:#06b6d4'>🧠 ZenkaMind AI</h1><p style='text-align:center;color:#94a3b8'>Falcon 7B Türkçe modeliyle akıllı sohbet</p>")
46
+ chatbot = gr.Chatbot(label="ZenkaMind Sohbet")
47
+ msg = gr.Textbox(placeholder="Mesajınızı yazın...", show_label=False)
48
+ clear = gr.Button("🧹 Sohbeti Temizle")
49
+
50
+ msg.submit(chat, [msg, chatbot], [chatbot, chatbot])
51
+ clear.click(lambda: None, None, chatbot, queue=False)
52
+
53
+ gr.Markdown("<p style='text-align:center;font-size:12px;color:#64748b'>© 2025 ZenkaMind Bilişim & Teknoloji — Manisa</p>")
54
+
55
+ demo.launch()
requirements.txt.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ requests