gerglitzen commited on
Commit
c185cfc
·
1 Parent(s): eb50bc8
Files changed (1) hide show
  1. app.py +18 -15
app.py CHANGED
@@ -1,19 +1,22 @@
1
  import gradio as gr
2
 
3
- title = "Ask Rick a Question"
4
- description = """
5
- The bot was trained to answer questions based on Rick and Morty dialogues. Ask Rick anything!
6
- <img src="https://huggingface.co/spaces/course-demos/Rick_and_Morty_QA/resolve/main/rick.png" width=200px>
7
- """
8
 
9
- article = "Check out [the original Rick and Morty Bot](https://huggingface.co/spaces/kingabzpro/Rick_and_Morty_Bot) that this demo is based off of."
 
 
 
 
 
 
10
 
11
- gr.Interface(
12
- fn=predict,
13
- inputs="textbox",
14
- outputs="text",
15
- title=title,
16
- description=description,
17
- article=article,
18
- examples=[["What are you doing?"], ["Where should we time travel to?"]],
19
- ).launch()
 
 
1
  import gradio as gr
2
 
3
+ import random
 
 
 
 
4
 
5
+ def respond(message, chat_history):
6
+ #No LLM here, just respond with a random pre-made message
7
+ bot_message = random.choice(["Tell me more about it",
8
+ "Cool, but I'm not interested",
9
+ "Hmmmm, ok then"])
10
+ chat_history.append((message, bot_message))
11
+ return "", chat_history
12
 
13
+ with gr.Blocks() as demo:
14
+ chatbot = gr.Chatbot(height=240) #just to fit the notebook
15
+ msg = gr.Textbox(label="Prompt")
16
+ btn = gr.Button("Submit")
17
+ clear = gr.ClearButton(components=[msg, chatbot], value="Clear console")
18
+
19
+ btn.click(respond, inputs=[msg, chatbot], outputs=[msg, chatbot])
20
+ msg.submit(respond, inputs=[msg, chatbot], outputs=[msg, chatbot]) #Press enter to submit
21
+ gr.close_all()
22
+ demo.launch()