Spaces:
Sleeping
Sleeping
Hazzzardous
commited on
Commit
•
561ca81
1
Parent(s):
c4a6474
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from rwkvstic.load import RWKV
|
2 |
+
|
3 |
+
model = RWKV(
|
4 |
+
"https://huggingface.co/Hazzzardous/RWKV-8Bit/resolve/main/RWKV-4-Pile-7B-Instruct.pqth"
|
5 |
+
)
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
|
9 |
+
def predict(input, history=None):
|
10 |
+
model.setState(history)
|
11 |
+
model.loadContext(newctx=f"{input}\n\nBot: ")
|
12 |
+
r = model.forward(number=100,stopStrings=["User: "])
|
13 |
+
|
14 |
+
return r["output"], r["state"]
|
15 |
+
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
chatbot = gr.Chatbot()
|
18 |
+
state = model.emptyState
|
19 |
+
state = model.loadContext(newctx="User: ")
|
20 |
+
|
21 |
+
with gr.Row():
|
22 |
+
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
|
23 |
+
|
24 |
+
txt.submit(predict, [txt, state], [chatbot, state])
|
25 |
+
|
26 |
+
demo.launch()
|