{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "c:\\Users\\ardit\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\gradio\\deprecation.py:43: UserWarning: You have unused kwarg parameters in Radio, please remove them: {'multiselect': False}\n", " warnings.warn(\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7861\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" }, { "name": "stdout", "output_type": "stream", "text": [ "[40]\n", "[40, 30]\n", "[40, 30, 10]\n", "[40, 30, 10, 10]\n", "[40, 30, 10, 10, 10]\n" ] } ], "source": [ "import gradio as gr\n", "import statistics\n", "\n", "def predict(history, input1):\n", " history.append(input1)\n", "\n", " print(history)\n", " total = statistics.mean(history)\n", "\n", " return total\n", "\n", "with gr.Blocks(theme=gr.themes.Soft(primary_hue='amber', secondary_hue='gray', neutral_hue='amber')) as demo:\n", " gr.Markdown(\n", " \"\"\"\n", " # Gradio with History\n", " \"\"\"\n", " )\n", " history = gr.Variable(value=[]) #beginning\n", " input1 = gr.Radio([10, 20, 30, 40, 50], multiselect=False, label='value')\n", " btn = gr.Button(value=\"Search for a Room\")\n", " output1 = gr.Textbox(label='value')\n", " # btn.click(greet, inputs='text', outputs=['dataframe'])\n", " btn.click(predict, [history, input1], [output1])\n", "demo.launch(share=False)" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }