{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatbot_feedback"]}, {"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", "\n", "def test_liked_loading():\n", " test_history = [\n", " {\"role\": \"user\", \"content\": \"test user message\"},\n", " {\"role\": \"assistant\", \"content\": \"test assistant message\"}\n", " ]\n", " # Set feedback_value to [\"Like\"] for the assistant message\n", " return gr.update(value=test_history, feedback_value=[\"Like\"])\n", "\n", "with gr.Blocks() as demo:\n", " chatbot = gr.Chatbot(\n", " resizable=True,\n", " min_height=500,\n", " layout=\"bubble\",\n", " )\n", " chatbot.like(\n", " lambda: None,\n", " inputs=[],\n", " outputs=None,\n", " )\n", " test_btn = gr.Button(\"Test Liked Loading\")\n", " test_btn.click(test_liked_loading, outputs=[chatbot])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch(debug=True)\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}