Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- requirements.txt +2 -2
- run.ipynb +1 -1
- run.py +5 -7
requirements.txt
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
gradio-client @ git+https://github.com/gradio-app/gradio@
|
2 |
-
https://gradio-pypi-previews.s3.amazonaws.com/
|
|
|
1 |
+
gradio-client @ git+https://github.com/gradio-app/gradio@a95f8ef3ee2663cf502129e829493a44b2641613#subdirectory=client/python
|
2 |
+
https://gradio-pypi-previews.s3.amazonaws.com/a95f8ef3ee2663cf502129e829493a44b2641613/gradio-5.9.1-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", "\n", "example_code = \"\"\"\n", "Here's
|
|
|
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}
|
run.py
CHANGED
@@ -1,12 +1,10 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
example_code = """
|
4 |
-
Here's
|
5 |
|
6 |
-
|
7 |
-
def greet(x):
|
8 |
-
return f"Hello, {x}!"
|
9 |
-
```
|
10 |
|
11 |
Is this correct?
|
12 |
"""
|
@@ -17,7 +15,7 @@ def chat(message, history):
|
|
17 |
else:
|
18 |
return {
|
19 |
"role": "assistant",
|
20 |
-
"content": example_code,
|
21 |
"options": [
|
22 |
{"value": "Yes, that's correct.", "label": "Yes"},
|
23 |
{"value": "No"}
|
@@ -27,7 +25,7 @@ def chat(message, history):
|
|
27 |
demo = gr.ChatInterface(
|
28 |
chat,
|
29 |
type="messages",
|
30 |
-
examples=["Write
|
31 |
)
|
32 |
|
33 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
+
import random
|
3 |
|
4 |
example_code = """
|
5 |
+
Here's an example Python lambda function:
|
6 |
|
7 |
+
lambda x: x + {}
|
|
|
|
|
|
|
8 |
|
9 |
Is this correct?
|
10 |
"""
|
|
|
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"}
|
|
|
25 |
demo = gr.ChatInterface(
|
26 |
chat,
|
27 |
type="messages",
|
28 |
+
examples=["Write an example Python lambda function."]
|
29 |
)
|
30 |
|
31 |
if __name__ == "__main__":
|