File size: 936 Bytes
f24dc26
e9610e3
c00cf91
e9610e3
f24dc26
c00cf91
f24dc26
c00cf91
 
 
 
 
f24dc26
e9610e3
 
 
 
 
c00cf91
f24dc26
c00cf91
 
 
 
 
 
e9610e3
 
f24dc26
 
c00cf91
 
 
f24dc26
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import gradio as gr
from ctransformers import AutoModelForCausalLM
import subprocess
import os

MODEL = "unsloth.Q8_0.gguf"

print("Downloading model...")
subprocess.run([
    "wget", "-O", MODEL,
    "https://huggingface.co/Afifsudoers/NightPrompt_RV1_Instruct_8B_GGUF/resolve/main/unsloth.Q8_0.gguf?download=true"
], check=True)

llm = AutoModelForCausalLM(
    MODEL,
    model_type="llama",
    n_threads=8,
    max_new_tokens=256
)

def chat_fn(message, history):
    prompt = ""
    for user, assistant in history:
        prompt += f"User: {user}\nAssistant: {assistant}\n"
    prompt += f"User: {message}\nAssistant:"

    output = llm(prompt, stop=["User:", "Assistant:"])
    return output

demo = gr.ChatInterface(
    fn=chat_fn,
    title="NightPrompt RV1 Instruct 8B Q8_0",
    description="Chat with NightPrompt RV1 Instruct 8B model quantized to Q8_0 using GGUF format.",
)

if __name__ == "__main__":
    demo.launch()