Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from
|
| 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 |
-
|
| 17 |
-
|
| 18 |
-
n_threads=8,
|
| 19 |
-
|
| 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 |
-
|
| 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,
|