freddyaboulton HF staff commited on
Commit
b907f7c
·
verified ·
1 Parent(s): 653ce45

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Test Chatinterface Examples Main
3
- emoji: 📉
4
  colorFrom: indigo
5
- colorTo: gray
6
  sdk: gradio
7
  sdk_version: 5.0.0
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: test_chatinterface_examples_main
4
+ emoji: 🔥
5
  colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
  sdk_version: 5.0.0
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
multimodal_messages_examples_testcase.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def generate(
4
+ message: dict,
5
+ chat_history: list[dict],
6
+ ):
7
+
8
+ output = ""
9
+ for character in message['text']:
10
+ output += character
11
+ yield output
12
+
13
+
14
+ demo = gr.ChatInterface(
15
+ fn=generate,
16
+ examples=[
17
+ [{"text": "Hey"}],
18
+ [{"text": "Can you explain briefly to me what is the Python programming language?"}],
19
+ ],
20
+ cache_examples=False,
21
+ type="messages",
22
+ multimodal=True,
23
+ )
24
+
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()
multimodal_tuples_examples_testcase.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def generate(
4
+ message: dict,
5
+ chat_history: list[dict],
6
+ ):
7
+
8
+ output = ""
9
+ for character in message['text']:
10
+ output += character
11
+ yield output
12
+
13
+
14
+ demo = gr.ChatInterface(
15
+ fn=generate,
16
+ examples=[
17
+ [{"text": "Hey"}],
18
+ [{"text": "Can you explain briefly to me what is the Python programming language?"}],
19
+ ],
20
+ cache_examples=False,
21
+ type="tuples",
22
+ multimodal=True,
23
+ )
24
+
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio-client @ git+https://github.com/gradio-app/gradio@2eaa0667e1d1a0edd1089bf8c3ffa3f563b9bca2#subdirectory=client/python
2
+ https://gradio-pypi-previews.s3.amazonaws.com/2eaa0667e1d1a0edd1089bf8c3ffa3f563b9bca2/gradio-5.0.0-py3-none-any.whl
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: test_chatinterface_examples"]}, {"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": ["# Downloading files from the demo repo\n", "import os\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/test_chatinterface_examples/multimodal_messages_examples_testcase.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/test_chatinterface_examples/multimodal_tuples_examples_testcase.py\n", "!wget -q https://github.com/gradio-app/gradio/raw/main/demo/test_chatinterface_examples/tuples_examples_testcase.py"]}, {"cell_type": "code", "execution_count": null, "id": "44380577570523278879349135829904343037", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def generate(\n", " message: str,\n", " chat_history: list[dict],\n", "):\n", "\n", " output = \"\"\n", " for character in message:\n", " output += character\n", " yield output\n", "\n", "\n", "demo = gr.ChatInterface(\n", " fn=generate,\n", " examples=[\n", " [\"Hey\"],\n", " [\"Can you explain briefly to me what is the Python programming language?\"],\n", " ],\n", " cache_examples=False,\n", " type=\"messages\",\n", ")\n", "\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def generate(
4
+ message: str,
5
+ chat_history: list[dict],
6
+ ):
7
+
8
+ output = ""
9
+ for character in message:
10
+ output += character
11
+ yield output
12
+
13
+
14
+ demo = gr.ChatInterface(
15
+ fn=generate,
16
+ examples=[
17
+ ["Hey"],
18
+ ["Can you explain briefly to me what is the Python programming language?"],
19
+ ],
20
+ cache_examples=False,
21
+ type="messages",
22
+ )
23
+
24
+
25
+ if __name__ == "__main__":
26
+ demo.launch()
tuples_examples_testcase.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def generate(
4
+ message: str,
5
+ chat_history: list[dict],
6
+ ):
7
+
8
+ output = ""
9
+ for character in message:
10
+ output += character
11
+ yield output
12
+
13
+
14
+ demo = gr.ChatInterface(
15
+ fn=generate,
16
+ examples=[
17
+ ["Hey"],
18
+ ["Can you explain briefly to me what is the Python programming language?"],
19
+ ],
20
+ cache_examples=False,
21
+ type="tuples",
22
+ )
23
+
24
+
25
+
26
+ if __name__ == "__main__":
27
+ demo.launch()