Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
-
from transformers import pipeline
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
torch_dtype="auto",
|
| 10 |
-
device_map="auto",
|
| 11 |
-
trust_remote_code=True,
|
| 12 |
-
max_new_tokens=512)
|
| 13 |
|
| 14 |
-
# AlpDroid
|
| 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 |
-
|
| 20 |
-
|
| 21 |
-
return
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 4 |
+
import torch
|
| 5 |
|
| 6 |
+
model_name = "TheBloke/SOLAR-10.7B-Instruct-v1.0-AWQ"
|
| 7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 8 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto", torch_dtype=torch.float16)
|
| 9 |
+
chat = pipeline("text-generation", model=model, tokenizer=tokenizer, device_map="auto")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# AlpDroid prompt
|
| 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 = f"{system_prompt}\n\nKullanıcı: {user_input}\nAlpDroid:"
|
| 17 |
+
res = chat(full, max_new_tokens=256, do_sample=True, temperature=0.7, top_p=0.9)[0]["generated_text"]
|
| 18 |
+
return res.split("AlpDroid:")[-1].strip()
|
| 19 |
|
| 20 |
+
app = gr.Interface(alp_droid_chat,
|
| 21 |
+
inputs=gr.Textbox(lines=4, placeholder="Sorunu yaz..."),
|
| 22 |
+
outputs="text",
|
| 23 |
+
title="AlpDroid (SOLAR‑10.7B)",
|
| 24 |
+
description="TheBloke'un instruct modeliyle çalışan AlpDroid.")
|
| 25 |
+
app.launch()
|