-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* artifacts * add changeset * chatinterface * guide fixes * example * zerogpu * Revert "zerogpu" This reverts commit 4d7b588. * changes * submit fn * chat interface * changes * add changeset * notebook * lint * type * regex * add changeset * fixes * line * fixes * formatting * change * change * add guard * link to playground demo * add changeset --------- Co-authored-by: gradio-pr-bot <[email protected]> Co-authored-by: aliabd <[email protected]>
- Loading branch information
1 parent
b0f3f3a
commit 01b919f
Showing
7 changed files
with
222 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"gradio": minor | ||
"website": minor | ||
--- | ||
|
||
feat:Support `additional_outputs` in `gr.ChatInterface` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_artifacts"]}, {"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", "python_code = \"\"\"\n", "def fib(n):\n", " if n <= 0:\n", " return 0\n", " elif n == 1:\n", " return 1\n", " else:\n", " return fib(n-1) + fib(n-2)\n", "\"\"\"\n", "\n", "js_code = \"\"\"\n", "function fib(n) {\n", " if (n <= 0) return 0;\n", " if (n === 1) return 1;\n", " return fib(n - 1) + fib(n - 2);\n", "}\n", "\"\"\"\n", "\n", "def chat(message, history):\n", " if \"python\" in message.lower():\n", " return \"Type Python or JavaScript to see the code.\", gr.Code(language=\"python\", value=python_code)\n", " elif \"javascript\" in message.lower():\n", " return \"Type Python or JavaScript to see the code.\", gr.Code(language=\"javascript\", value=js_code)\n", " else:\n", " return \"Please ask about Python or JavaScript.\", None\n", "\n", "with gr.Blocks() as demo:\n", " code = gr.Code(render=False)\n", " with gr.Row():\n", " with gr.Column():\n", " gr.Markdown(\"<center><h1>Write Python or JavaScript</h1></center>\")\n", " gr.ChatInterface(\n", " chat,\n", " examples=[\"Python\", \"JavaScript\"],\n", " additional_outputs=[code],\n", " type=\"messages\"\n", " )\n", " with gr.Column():\n", " gr.Markdown(\"<center><h1>Code Artifacts</h1></center>\")\n", " code.render()\n", "\n", "demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import gradio as gr | ||
|
||
python_code = """ | ||
def fib(n): | ||
if n <= 0: | ||
return 0 | ||
elif n == 1: | ||
return 1 | ||
else: | ||
return fib(n-1) + fib(n-2) | ||
""" | ||
|
||
js_code = """ | ||
function fib(n) { | ||
if (n <= 0) return 0; | ||
if (n === 1) return 1; | ||
return fib(n - 1) + fib(n - 2); | ||
} | ||
""" | ||
|
||
def chat(message, history): | ||
if "python" in message.lower(): | ||
return "Type Python or JavaScript to see the code.", gr.Code(language="python", value=python_code) | ||
elif "javascript" in message.lower(): | ||
return "Type Python or JavaScript to see the code.", gr.Code(language="javascript", value=js_code) | ||
else: | ||
return "Please ask about Python or JavaScript.", None | ||
|
||
with gr.Blocks() as demo: | ||
code = gr.Code(render=False) | ||
with gr.Row(): | ||
with gr.Column(): | ||
gr.Markdown("<center><h1>Write Python or JavaScript</h1></center>") | ||
gr.ChatInterface( | ||
chat, | ||
examples=["Python", "JavaScript"], | ||
additional_outputs=[code], | ||
type="messages" | ||
) | ||
with gr.Column(): | ||
gr.Markdown("<center><h1>Code Artifacts</h1></center>") | ||
code.render() | ||
|
||
demo.launch() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# How to Create a Chatbot with Gradio | ||
|
||
Tags: NLP, LLM, CHATBOT | ||
Tags: LLM, CHATBOT, NLP | ||
|
||
## Introduction | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters