aliabd commited on
Commit
7484e64
·
1 Parent(s): c619bd0

Upload with huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +1 -1
  2. run.ipynb +1 -1
  3. run.py +5 -10
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
 
2
- https://gradio-main-build.s3.amazonaws.com/f81b8235c75e5b9569705b9ddcb270ccfee7e740/gradio-3.27.0-py3-none-any.whl
 
1
 
2
+ https://gradio-main-build.s3.amazonaws.com/7a04ebe7fd1ba871e3fe38a20a67ac47e6c0c540/gradio-3.27.0-py3-none-any.whl
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_simple"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot()\n", " msg = gr.Textbox()\n", " clear = gr.Button(\"Clear\")\n", "\n", " def user(user_message, history):\n", " return \"\", history + [[user_message, None]]\n", "\n", " def bot(history):\n", " bot_message = random.choice([\"Yes\", \"No\"])\n", " history[-1][1] = bot_message\n", " time.sleep(1)\n", " return history\n", "\n", " msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(\n", " bot, chatbot, chatbot\n", " )\n", " clear.click(lambda: None, None, chatbot, queue=False)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
 
1
+ {"cells": [{"cell_type": "markdown", "id": 302934307671667531413257853548643485645, "metadata": {}, "source": ["# Gradio Demo: chatbot_simple"]}, {"cell_type": "code", "execution_count": null, "id": 272996653310673477252411125948039410165, "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": 288918539441861185822528903084949547379, "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "import random\n", "import time\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot()\n", " msg = gr.Textbox()\n", " clear = gr.Button(\"Clear\")\n", "\n", " def respond(message, chat_history):\n", " bot_message = random.choice([\"How are you?\", \"I love you\", \"I'm very hungry\"])\n", " chat_history.append((message, bot_message))\n", " time.sleep(1)\n", " return \"\", chat_history\n", "\n", " msg.submit(respond, [msg, chatbot], [msg, chatbot])\n", " clear.click(lambda: None, None, chatbot, queue=False)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -7,18 +7,13 @@ with gr.Blocks() as demo:
7
  msg = gr.Textbox()
8
  clear = gr.Button("Clear")
9
 
10
- def user(user_message, history):
11
- return "", history + [[user_message, None]]
12
-
13
- def bot(history):
14
- bot_message = random.choice(["Yes", "No"])
15
- history[-1][1] = bot_message
16
  time.sleep(1)
17
- return history
18
 
19
- msg.submit(user, [msg, chatbot], [msg, chatbot], queue=False).then(
20
- bot, chatbot, chatbot
21
- )
22
  clear.click(lambda: None, None, chatbot, queue=False)
23
 
24
  if __name__ == "__main__":
 
7
  msg = gr.Textbox()
8
  clear = gr.Button("Clear")
9
 
10
+ def respond(message, chat_history):
11
+ bot_message = random.choice(["How are you?", "I love you", "I'm very hungry"])
12
+ chat_history.append((message, bot_message))
 
 
 
13
  time.sleep(1)
14
+ return "", chat_history
15
 
16
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
 
 
17
  clear.click(lambda: None, None, chatbot, queue=False)
18
 
19
  if __name__ == "__main__":