Update app.py
Browse files
app.py
CHANGED
|
@@ -1,55 +1,28 @@
|
|
| 1 |
-
|
| 2 |
-
import gradio as gr
|
| 3 |
-
from transformers import pipeline
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
model=MODEL_NAME,
|
| 14 |
-
token=HF_TOKEN, # artık gizli şekilde çekiliyor
|
| 15 |
-
torch_dtype="auto",
|
| 16 |
-
device_map="auto",
|
| 17 |
-
max_new_tokens=200,
|
| 18 |
-
temperature=0.7,
|
| 19 |
-
top_p=0.9,
|
| 20 |
-
repetition_penalty=1.1
|
| 21 |
-
)
|
| 22 |
|
| 23 |
def chat(message, history):
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
Kod isterse örnek kodu uygun biçimde yaz.
|
| 34 |
-
|
| 35 |
-
Geçmiş konuşma:
|
| 36 |
-
{prompt}
|
| 37 |
-
Kullanıcı: {message}
|
| 38 |
-
Asistan:
|
| 39 |
-
"""
|
| 40 |
-
outputs = pipe(full_prompt, return_full_text=False)
|
| 41 |
-
response = outputs[0]["generated_text"].strip()
|
| 42 |
-
history.append((message, response))
|
| 43 |
-
return history, ""
|
| 44 |
-
|
| 45 |
-
with gr.Blocks(title="ZenkaMind 2.0 - Türkçe Asistan") as demo:
|
| 46 |
-
gr.Markdown("## 🧠 ZenkaMind 2.0 — Türkçe Yapay Zekâ (Gizli Token)")
|
| 47 |
-
chatbot = gr.Chatbot(height=500)
|
| 48 |
-
msg = gr.Textbox(placeholder="Bir şey yaz...", label="Sen:")
|
| 49 |
clear = gr.Button("Temizle")
|
| 50 |
|
| 51 |
-
msg.submit(chat, [msg, chatbot],
|
| 52 |
-
clear.click(lambda:
|
| 53 |
|
| 54 |
-
|
| 55 |
-
demo.launch()
|
|
|
|
| 1 |
+
---
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
### 🎨 2. Görsel Taraf (ZenkaMind Logosu + UI)
|
| 4 |
+
ZenkaMind logosunu **Gradio temasına** şu şekilde ekleyebilirsin:
|
| 5 |
|
| 6 |
+
```python
|
| 7 |
+
import gradio as gr
|
| 8 |
+
from transformers import pipeline
|
| 9 |
|
| 10 |
+
# Model yükleme
|
| 11 |
+
pipe = pipeline("text-generation", model="mistralai/Mixtral-8x7B-Instruct-v0.1")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
def chat(message, history):
|
| 14 |
+
full_prompt = prompt + "\nKullanıcı: " + message + "\nZenkaMind:"
|
| 15 |
+
result = pipe(full_prompt, max_new_tokens=150, do_sample=True, temperature=0.8)
|
| 16 |
+
return result[0]["generated_text"].split("ZenkaMind:")[-1].strip()
|
| 17 |
+
|
| 18 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="ZenkaMind 2.0") as demo:
|
| 19 |
+
gr.Markdown("<center><img src='https://huggingface.co/path/to/zenkamind_logo.png' width='120'></center>")
|
| 20 |
+
gr.Markdown("<h2 style='text-align:center;'>🧠 ZenkaMind 2.0 - Doğal Türkçe Asistan</h2>")
|
| 21 |
+
chatbot = gr.Chatbot()
|
| 22 |
+
msg = gr.Textbox(label="Bir şey yaz...")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
clear = gr.Button("Temizle")
|
| 24 |
|
| 25 |
+
msg.submit(chat, [msg, chatbot], chatbot)
|
| 26 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
| 27 |
|
| 28 |
+
demo.launch()
|
|
|