Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,28 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Model
|
5 |
-
model_name = "
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
9 |
|
10 |
-
# AlpDroid promptunu
|
11 |
-
import requests
|
12 |
prompt_url = "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
13 |
system_prompt = requests.get(prompt_url).text
|
14 |
|
15 |
def alp_droid_chat(user_input):
|
16 |
full_prompt = system_prompt + "\n\nKullanıcı: " + user_input + "\nAlpDroid:"
|
17 |
-
|
18 |
-
return
|
19 |
|
20 |
-
iface = gr.Interface(fn=alp_droid_chat,
|
21 |
-
inputs=gr.Textbox(lines=
|
22 |
outputs="text",
|
23 |
-
title="AlpDroid
|
24 |
-
description="Mistral tabanlı AlpDroid
|
25 |
-
|
26 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import requests
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
# Model: Mistral-7B-Instruct-v0.2 (instruct-savvy)
|
6 |
+
model_name = "mistralai/Mistral-7B-Instruct-v0.2"
|
7 |
+
chat = pipeline("text-generation",
|
8 |
+
model=model_name,
|
9 |
+
torch_dtype="auto",
|
10 |
+
device_map="auto",
|
11 |
+
trust_remote_code=True,
|
12 |
+
max_new_tokens=512)
|
13 |
|
14 |
+
# AlpDroid promptunu GitHub'dan çek
|
|
|
15 |
prompt_url = "https://raw.githubusercontent.com/ALPERALL/AlpDroid/main/prompt.txt"
|
16 |
system_prompt = requests.get(prompt_url).text
|
17 |
|
18 |
def alp_droid_chat(user_input):
|
19 |
full_prompt = system_prompt + "\n\nKullanıcı: " + user_input + "\nAlpDroid:"
|
20 |
+
output = chat(full_prompt, temperature=0.7, top_p=0.9)[0]["generated_text"]
|
21 |
+
return output.split("AlpDroid:")[-1].strip()
|
22 |
|
23 |
+
iface = gr.Interface(fn=alp_droid_chat,
|
24 |
+
inputs=gr.Textbox(lines=4, placeholder="Sorunu yaz..."),
|
25 |
outputs="text",
|
26 |
+
title="AlpDroid (Mistral‑7B‑Instruct‑v0.2)",
|
27 |
+
description="Mistral‑7B‑Instruct‑v0.2 tabanlı AlpDroid asistanı.")
|
|
|
28 |
iface.launch()
|