Spaces:
Sleeping
Sleeping
File size: 702 Bytes
561ca81 |
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 |
from rwkvstic.load import RWKV
model = RWKV(
"https://huggingface.co/Hazzzardous/RWKV-8Bit/resolve/main/RWKV-4-Pile-7B-Instruct.pqth"
)
import gradio as gr
def predict(input, history=None):
model.setState(history)
model.loadContext(newctx=f"{input}\n\nBot: ")
r = model.forward(number=100,stopStrings=["User: "])
return r["output"], r["state"]
with gr.Blocks() as demo:
chatbot = gr.Chatbot()
state = model.emptyState
state = model.loadContext(newctx="User: ")
with gr.Row():
txt = gr.Textbox(show_label=False, placeholder="Enter text and press enter").style(container=False)
txt.submit(predict, [txt, state], [chatbot, state])
demo.launch()
|