Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,20 @@
|
|
1 |
import time
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
yield "You typed: " + message[: i+1]
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import time
|
2 |
import gradio as gr
|
3 |
+
from ctransformers import AutoModelForCausalLM
|
4 |
|
5 |
+
# Set gpu_layers to the number of layers to offload to GPU. Set to 0 if no GPU acceleration is available on your system.
|
6 |
+
model_path = "WizardLM-7B-uncensored.Q3_K_S.gguf"
|
7 |
+
llm = AutoModelForCausalLM.from_pretrained(model_path, model_type="llama")
|
|
|
8 |
|
9 |
+
def generate_response(message):
|
10 |
+
response = llm(message)
|
11 |
+
yield response
|
12 |
+
|
13 |
+
def chatbot(message, history):
|
14 |
+
response_generator = generate_response(message)
|
15 |
+
for response in response_generator:
|
16 |
+
time.sleep(0.3) # Optional delay for a natural chat feel
|
17 |
+
yield response
|
18 |
+
|
19 |
+
iface = gr.ChatInterface(chatbot)
|
20 |
+
iface.launch()
|