alperall commited on
Commit
e18adb9
·
verified ·
1 Parent(s): 6308d4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -19
app.py CHANGED
@@ -1,28 +1,25 @@
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()
 
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 (SOLAR10.7B)",
24
+ description="TheBloke'un instruct modeliyle çalışan AlpDroid.")
25
+ app.launch()