Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,7 +23,28 @@ examples = [
|
|
23 |
["What is the square root of 64?", "The square root of 64 is 8."]
|
24 |
]
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
demo = gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title="Llama Language Model", description=description, examples=examples)
|
28 |
-
demo.queue(concurrency_count=3)
|
29 |
-
demo.launch()
|
|
|
23 |
["What is the square root of 64?", "The square root of 64 is 8."]
|
24 |
]
|
25 |
|
26 |
+
with gr.Blocks() as demo:
|
27 |
+
chatbot = gr.Chatbot()
|
28 |
+
msg = gr.Textbox()
|
29 |
+
clear = gr.Button("Clear")
|
30 |
+
|
31 |
+
def user(user_message, history):
|
32 |
+
return "", history + [[user_message, None]]
|
33 |
+
|
34 |
+
def bot(history):
|
35 |
+
bot_message = output_text
|
36 |
+
history[-1][1] = ""
|
37 |
+
for character in bot_message:
|
38 |
+
history[-1][1] += character
|
39 |
+
time.sleep(0.05)
|
40 |
+
yield history
|
41 |
+
|
42 |
+
msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
|
43 |
+
bot, chatbot, chatbot
|
44 |
+
)
|
45 |
+
clear.click(lambda: None, None, chatbot, queue=False)
|
46 |
+
|
47 |
+
demo.queue()
|
48 |
+
if __name__ == "__main__":
|
49 |
+
demo.launch()
|
50 |
|
|
|
|
|
|