Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,7 +5,7 @@ emoji: 🔥
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
-
sdk_version:
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
|
|
|
| 5 |
colorFrom: indigo
|
| 6 |
colorTo: indigo
|
| 7 |
sdk: gradio
|
| 8 |
+
sdk_version: 6.0.0
|
| 9 |
app_file: run.py
|
| 10 |
pinned: false
|
| 11 |
hf_oauth: true
|
run.ipynb
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatbot_nested_thoughts"]}, {"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", "from gradio import ChatMessage\n", "import time\n", "\n", "sleep_time = 0.1\n", "long_sleep_time = 1\n", "\n", "def generate_response(history):\n", " history.append(\n", " ChatMessage(\n", " role=\"user\", content=\"What is the weather in San Francisco right now?\"\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"In order to find the current weather in San Francisco, I will need to use my weather tool.\",\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"\",\n", " metadata={\"title\": \"Gathering Weather Websites\", \"id\": 1},\n", " )\n", " )\n", " yield history\n", " time.sleep(long_sleep_time)\n", " history[-1].content = \"Will check: weather.com and sunny.org\"\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"Received weather from weather.com.\",\n", " metadata={\"title\": \"API Success \u2705\", \"parent_id\": 1, \"id\": 2},\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"API Error when connecting to sunny.org.\",\n", " metadata={\"title\": \"API Error \ud83d\udca5 \", \"parent_id\": 1, \"id\": 3},\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", "\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"I will try yet again\",\n", " metadata={\"title\": \"I will try again\", \"id\": 4, \"parent_id\": 3},\n", " )\n", " )\n", " yield history\n", "\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"Failed again\",\n", " metadata={\"title\": \"Failed again\", \"id\": 6, \"parent_id\": 4},\n", " )\n", " )\n", " yield history\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot(
|
|
|
|
| 1 |
+
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatbot_nested_thoughts"]}, {"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", "from gradio import ChatMessage\n", "import time\n", "\n", "sleep_time = 0.1\n", "long_sleep_time = 1\n", "\n", "def generate_response(history):\n", " history.append(\n", " ChatMessage(\n", " role=\"user\", content=\"What is the weather in San Francisco right now?\"\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"In order to find the current weather in San Francisco, I will need to use my weather tool.\",\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"\",\n", " metadata={\"title\": \"Gathering Weather Websites\", \"id\": 1},\n", " )\n", " )\n", " yield history\n", " time.sleep(long_sleep_time)\n", " history[-1].content = \"Will check: weather.com and sunny.org\"\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"Received weather from weather.com.\",\n", " metadata={\"title\": \"API Success \u2705\", \"parent_id\": 1, \"id\": 2},\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"API Error when connecting to sunny.org.\",\n", " metadata={\"title\": \"API Error \ud83d\udca5 \", \"parent_id\": 1, \"id\": 3},\n", " )\n", " )\n", " yield history\n", " time.sleep(sleep_time)\n", "\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"I will try yet again\",\n", " metadata={\"title\": \"I will try again\", \"id\": 4, \"parent_id\": 3},\n", " )\n", " )\n", " yield history\n", "\n", " time.sleep(sleep_time)\n", " history.append(\n", " ChatMessage(\n", " role=\"assistant\",\n", " content=\"Failed again\",\n", " metadata={\"title\": \"Failed again\", \"id\": 6, \"parent_id\": 4},\n", " )\n", " )\n", " yield history\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot(height=500, buttons=[\"copy\"])\n", " demo.load(generate_response, chatbot, chatbot)\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
|
run.py
CHANGED
|
@@ -72,7 +72,7 @@ def generate_response(history):
|
|
| 72 |
yield history
|
| 73 |
|
| 74 |
with gr.Blocks() as demo:
|
| 75 |
-
chatbot = gr.Chatbot(
|
| 76 |
demo.load(generate_response, chatbot, chatbot)
|
| 77 |
|
| 78 |
if __name__ == "__main__":
|
|
|
|
| 72 |
yield history
|
| 73 |
|
| 74 |
with gr.Blocks() as demo:
|
| 75 |
+
chatbot = gr.Chatbot(height=500, buttons=["copy"])
|
| 76 |
demo.load(generate_response, chatbot, chatbot)
|
| 77 |
|
| 78 |
if __name__ == "__main__":
|