Afifsudoers commited on
Commit
e9610e3
·
verified ·
1 Parent(s): 3bc8d23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -17
app.py CHANGED
@@ -1,23 +1,21 @@
1
  import gradio as gr
2
- from llama_cpp import Llama
3
- import os
4
  import subprocess
 
5
 
6
  MODEL = "unsloth.Q8_0.gguf"
7
 
8
-
9
  print("Downloading model...")
10
  subprocess.run([
11
  "wget", "-O", MODEL,
12
  "https://huggingface.co/Afifsudoers/NightPrompt_RV1_Instruct_8B_GGUF/resolve/main/unsloth.Q8_0.gguf?download=true"
13
  ], check=True)
14
 
15
-
16
- llm = Llama(
17
- model_path=MODEL,
18
- n_threads=8,
19
- n_ctx=2048,
20
- n_batch=128
21
  )
22
 
23
  def chat_fn(message, history):
@@ -26,14 +24,8 @@ def chat_fn(message, history):
26
  prompt += f"User: {user}\nAssistant: {assistant}\n"
27
  prompt += f"User: {message}\nAssistant:"
28
 
29
- output = llm(
30
- prompt,
31
- max_tokens=256,
32
- stop=["User:", "Assistant:"],
33
- echo=False
34
- )
35
- text = output["choices"][0]["text"].strip()
36
- return text
37
 
38
  demo = gr.ChatInterface(
39
  fn=chat_fn,
 
1
  import gradio as gr
2
+ from ctransformers import AutoModelForCausalLM
 
3
  import subprocess
4
+ import os
5
 
6
  MODEL = "unsloth.Q8_0.gguf"
7
 
 
8
  print("Downloading model...")
9
  subprocess.run([
10
  "wget", "-O", MODEL,
11
  "https://huggingface.co/Afifsudoers/NightPrompt_RV1_Instruct_8B_GGUF/resolve/main/unsloth.Q8_0.gguf?download=true"
12
  ], check=True)
13
 
14
+ llm = AutoModelForCausalLM(
15
+ MODEL,
16
+ model_type="llama",
17
+ n_threads=8,
18
+ max_new_tokens=256
 
19
  )
20
 
21
  def chat_fn(message, history):
 
24
  prompt += f"User: {user}\nAssistant: {assistant}\n"
25
  prompt += f"User: {message}\nAssistant:"
26
 
27
+ output = llm(prompt, stop=["User:", "Assistant:"])
28
+ return output
 
 
 
 
 
 
29
 
30
  demo = gr.ChatInterface(
31
  fn=chat_fn,