Spaces:
Runtime error
Runtime error
john
commited on
Commit
·
3592be6
1
Parent(s):
620a964
Update app.py
Browse files
app.py
CHANGED
@@ -1,34 +1,28 @@
|
|
|
|
1 |
import os
|
2 |
import wget
|
3 |
-
import gradio as gr
|
4 |
from llama_cpp import Llama
|
5 |
import random
|
6 |
-
|
7 |
url = 'https://huggingface.co/TheBloke/WizardLM-7B-uncensored-GGML/resolve/main/WizardLM-7B-uncensored.ggmlv3.q4_0.bin'
|
8 |
filename = wget.download(url)
|
9 |
-
|
10 |
theme = gr.themes.Soft(
|
11 |
primary_hue=gr.themes.Color("#ededed", "#fee2e2", "#fecaca", "#fca5a5", "#f87171", "#ef4444", "#dc2626", "#b91c1c", "#991b1b", "#7f1d1d", "#6c1e1e"),
|
12 |
neutral_hue="red",
|
13 |
)
|
14 |
-
title = """<h1 align="center">Chat with awesome WizardLM 7b model!</h1><br
|
|
|
15 |
with gr.Blocks(theme=theme) as demo:
|
16 |
gr.HTML(title)
|
17 |
-
gr.HTML("This model is awesome for its size! It is only 20th the size of
|
18 |
chatbot = gr.Chatbot()
|
19 |
msg = gr.Textbox()
|
20 |
-
clear = gr.ClearButton([msg, chatbot])
|
21 |
-
#instruction = gr.Textbox(label="Instruction", placeholder=)
|
22 |
|
23 |
def user(user_message, history):
|
24 |
return gr.update(value="", interactive=True), history + [[user_message, None]]
|
25 |
|
26 |
def bot(history):
|
27 |
-
#instruction = history[-1][1] or ""
|
28 |
user_message = history[-1][0]
|
29 |
-
#token1 = llm.tokenize(b"### Instruction: ")
|
30 |
-
#token2 = llm.tokenize(instruction.encode())
|
31 |
-
#token3 = llm2.tokenize(b"USER: ")
|
32 |
tokens3 = llm2.tokenize(user_message.encode())
|
33 |
token4 = llm2.tokenize(b"\n\n### Response:")
|
34 |
tokens = tokens3 + token4
|
|
|
1 |
+
import gradio as gr
|
2 |
import os
|
3 |
import wget
|
|
|
4 |
from llama_cpp import Llama
|
5 |
import random
|
|
|
6 |
url = 'https://huggingface.co/TheBloke/WizardLM-7B-uncensored-GGML/resolve/main/WizardLM-7B-uncensored.ggmlv3.q4_0.bin'
|
7 |
filename = wget.download(url)
|
8 |
+
llm2 = Llama(model_path=filename, seed=random.randint(1, 2**31))
|
9 |
theme = gr.themes.Soft(
|
10 |
primary_hue=gr.themes.Color("#ededed", "#fee2e2", "#fecaca", "#fca5a5", "#f87171", "#ef4444", "#dc2626", "#b91c1c", "#991b1b", "#7f1d1d", "#6c1e1e"),
|
11 |
neutral_hue="red",
|
12 |
)
|
13 |
+
title = """<h1 align="center">Chat with awesome WizardLM 7b model!</h1><br>"""
|
14 |
+
|
15 |
with gr.Blocks(theme=theme) as demo:
|
16 |
gr.HTML(title)
|
17 |
+
gr.HTML("This model is awesome for its size! It is only 20th the size of ChatGPT but is around 90% as good as ChatGPT. However, please don't rely on WizardLM to provide 100% true information as it might be wrong sometimes.")
|
18 |
chatbot = gr.Chatbot()
|
19 |
msg = gr.Textbox()
|
|
|
|
|
20 |
|
21 |
def user(user_message, history):
|
22 |
return gr.update(value="", interactive=True), history + [[user_message, None]]
|
23 |
|
24 |
def bot(history):
|
|
|
25 |
user_message = history[-1][0]
|
|
|
|
|
|
|
26 |
tokens3 = llm2.tokenize(user_message.encode())
|
27 |
token4 = llm2.tokenize(b"\n\n### Response:")
|
28 |
tokens = tokens3 + token4
|