Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ from huggingface_hub import hf_hub_download #load from huggingfaces
|
|
| 9 |
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
| 10 |
|
| 11 |
history = []
|
|
|
|
| 12 |
history.append(["Hi there!", "Hello, how can I help you?"])
|
| 13 |
|
| 14 |
def generate_text(input_text, history):
|
|
@@ -21,12 +22,24 @@ def generate_text(input_text, history):
|
|
| 21 |
|
| 22 |
return "", history
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
with gr.Blocks() as demo:
|
| 25 |
chatbot = gr.Chatbot()
|
| 26 |
msg = gr.Textbox()
|
| 27 |
clear = gr.ClearButton([msg, chatbot])
|
| 28 |
|
| 29 |
-
msg.submit(generate_text, [msg, chatbot], [msg, chatbot])
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
demo.launch()
|
| 32 |
|
|
|
|
| 9 |
llm = Llama(model_path= hf_hub_download(repo_id="TheBloke/airoboros-l2-13b-gpt4-m2.0-GGML", filename="airoboros-l2-13b-gpt4-m2.0.ggmlv3.q6_K.bin"), n_ctx=2048) #download model from hf/ n_ctx=2048 for high ccontext length
|
| 10 |
|
| 11 |
history = []
|
| 12 |
+
h = []
|
| 13 |
history.append(["Hi there!", "Hello, how can I help you?"])
|
| 14 |
|
| 15 |
def generate_text(input_text, history):
|
|
|
|
| 22 |
|
| 23 |
return "", history
|
| 24 |
|
| 25 |
+
def bot(history):
|
| 26 |
+
bot_message = history
|
| 27 |
+
h[-1][1] = ""
|
| 28 |
+
for character in bot_message:
|
| 29 |
+
history[-1][1] += character
|
| 30 |
+
time.sleep(0.05)
|
| 31 |
+
yield h
|
| 32 |
+
|
| 33 |
+
|
| 34 |
with gr.Blocks() as demo:
|
| 35 |
chatbot = gr.Chatbot()
|
| 36 |
msg = gr.Textbox()
|
| 37 |
clear = gr.ClearButton([msg, chatbot])
|
| 38 |
|
| 39 |
+
msg.submit(generate_text, [msg, chatbot], [msg, chatbot]).then(
|
| 40 |
+
bot, chatbot, chatbot
|
| 41 |
+
)
|
| 42 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
| 43 |
|
| 44 |
demo.launch()
|
| 45 |
|