freddyaboulton HF Staff commited on
Commit
80284f7
·
verified ·
1 Parent(s): 26d3080

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. requirements.txt +2 -2
  2. run.ipynb +1 -1
  3. run.py +5 -6
requirements.txt CHANGED
@@ -1,2 +1,2 @@
1
- gradio-client @ git+https://github.com/gradio-app/gradio@d2691e7436f722781ee61db43ce3f2d5ccc3e253#subdirectory=client/python
2
- https://gradio-pypi-previews.s3.amazonaws.com/d2691e7436f722781ee61db43ce3f2d5ccc3e253/gradio-5.11.0-py3-none-any.whl
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@be40307d1d11421e01bf91fa5e05ec4ab97b09d8#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/be40307d1d11421e01bf91fa5e05ec4ab97b09d8/gradio-5.11.0-py3-none-any.whl
run.ipynb CHANGED
@@ -1 +1 @@
1
- {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_options"]}, {"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", "\n", "example_code = \"\"\"\n", "Here's an example Python lambda function:\n", "\n", "lambda x: x + {}\n", "\n", "Is this correct?\n", "\"\"\"\n", "\n", "def chat(message, history):\n", " if message == \"Yes, that's correct.\":\n", " return \"Great!\"\n", " else:\n", " return {\n", " \"role\": \"assistant\",\n", " \"content\": example_code.format(random.randint(1, 100)),\n", " \"options\": [\n", " {\"value\": \"Yes, that's correct.\", \"label\": \"Yes\"},\n", " {\"value\": \"No\"}\n", " ]\n", " }\n", "\n", "demo = gr.ChatInterface(\n", " chat,\n", " type=\"messages\",\n", " examples=[\"Write an example Python lambda function.\"]\n", ")\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: chatinterface_options"]}, {"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", "\n", "example_code = \"\"\"\n", "Here's an example Python lambda function:\n", "\n", "lambda x: x + {}\n", "\n", "Is this correct?\n", "\"\"\"\n", "\n", "def chat(message, history):\n", " if message == \"Yes, that's correct.\":\n", " return \"Great!\"\n", " else:\n", " return gr.ChatMessage(\n", " content=example_code.format(random.randint(1, 100)),\n", " options=[\n", " {\"value\": \"Yes, that's correct.\", \"label\": \"Yes\"},\n", " {\"value\": \"No\"}\n", " ]\n", " )\n", "\n", "demo = gr.ChatInterface(\n", " chat,\n", " type=\"messages\",\n", " examples=[\"Write an example Python lambda function.\"]\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py CHANGED
@@ -13,14 +13,13 @@ def chat(message, history):
13
  if message == "Yes, that's correct.":
14
  return "Great!"
15
  else:
16
- return {
17
- "role": "assistant",
18
- "content": example_code.format(random.randint(1, 100)),
19
- "options": [
20
  {"value": "Yes, that's correct.", "label": "Yes"},
21
  {"value": "No"}
22
- ]
23
- }
24
 
25
  demo = gr.ChatInterface(
26
  chat,
 
13
  if message == "Yes, that's correct.":
14
  return "Great!"
15
  else:
16
+ return gr.ChatMessage(
17
+ content=example_code.format(random.randint(1, 100)),
18
+ options=[
 
19
  {"value": "Yes, that's correct.", "label": "Yes"},
20
  {"value": "No"}
21
+ ]
22
+ )
23
 
24
  demo = gr.ChatInterface(
25
  chat,