Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support saving chat history in gr.ChatInterface #10191

Open
wants to merge 82 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
b6bca34
save history prototype
abidlabs Dec 13, 2024
a846b38
add changeset
gradio-pr-bot Dec 13, 2024
d8d64bc
merge
dawoodkhan82 Dec 23, 2024
dfd3ad5
Merge branch 'main' into chat-history
abidlabs Dec 23, 2024
4572a74
Declare exports in __all__ for type checking (#10238)
dustalov Dec 23, 2024
bcd383e
Add `gr.BrowserState` change event (#10245)
abidlabs Dec 23, 2024
a1e0bd1
history
dawoodkhan82 Dec 27, 2024
02caf94
Merge branch 'main' into chat-history
dawoodkhan82 Dec 27, 2024
8ace831
Merge branch 'main' into chat-history
abidlabs Dec 30, 2024
be531b6
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 30, 2024
caccb0b
changes
abidlabs Dec 30, 2024
9251dea
changes
abidlabs Dec 30, 2024
08e6615
changes
abidlabs Dec 30, 2024
3cdb67b
history
abidlabs Dec 30, 2024
c20ceda
changes
abidlabs Dec 30, 2024
8438764
changes
abidlabs Dec 30, 2024
269ff00
changes
abidlabs Dec 30, 2024
5477552
format
abidlabs Dec 30, 2024
a51cbef
add changeset
gradio-pr-bot Dec 30, 2024
d8ca538
Merge branch 'main' into chat-history
abidlabs Dec 30, 2024
59baf96
changes
abidlabs Dec 30, 2024
25558a0
changes
abidlabs Dec 30, 2024
ea42b9e
more changes
abidlabs Dec 30, 2024
95b49fb
changes
abidlabs Dec 30, 2024
99bb7df
dataset changes
abidlabs Dec 31, 2024
7a6a8b7
changes
abidlabs Dec 31, 2024
2580513
add changeset
gradio-pr-bot Dec 31, 2024
9ce023f
add md variant for button
abidlabs Dec 31, 2024
dac913b
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 31, 2024
4e3a537
add changeset
gradio-pr-bot Dec 31, 2024
464db2b
changes
abidlabs Dec 31, 2024
690912e
changes
abidlabs Dec 31, 2024
303be42
format
abidlabs Dec 31, 2024
8b7cc0e
format
abidlabs Dec 31, 2024
11c34c3
add changeset
gradio-pr-bot Dec 31, 2024
21aa096
changes
abidlabs Dec 31, 2024
9d76b7d
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 31, 2024
a2b7542
changes
abidlabs Dec 31, 2024
b7357c1
more changes
abidlabs Dec 31, 2024
7987774
changes
abidlabs Dec 31, 2024
89e5c71
changes
abidlabs Dec 31, 2024
51e1daa
add changeset
gradio-pr-bot Dec 31, 2024
d95022b
changes
abidlabs Dec 31, 2024
5ec7613
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 31, 2024
86f4432
docs
abidlabs Dec 31, 2024
d18879b
changes
abidlabs Dec 31, 2024
7c4a8e3
changes
abidlabs Dec 31, 2024
af6523e
changes
abidlabs Dec 31, 2024
037b1e9
changes
abidlabs Dec 31, 2024
ded0b3d
fix
abidlabs Dec 31, 2024
7cbc66f
fix tests
abidlabs Dec 31, 2024
37f4a84
change
abidlabs Dec 31, 2024
6e90ca3
add changeset
gradio-pr-bot Dec 31, 2024
bff664e
fix logo issue
abidlabs Dec 31, 2024
0ec7f25
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 31, 2024
6842fa5
changes
abidlabs Dec 31, 2024
5052e5d
version
abidlabs Dec 31, 2024
791deca
add changeset
gradio-pr-bot Dec 31, 2024
59bcf92
fix typecheck
abidlabs Dec 31, 2024
67770ec
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 31, 2024
ddbe6a8
remove redundant
abidlabs Dec 31, 2024
92e905e
pkg version
abidlabs Dec 31, 2024
9075df8
add changeset
gradio-pr-bot Dec 31, 2024
13bfe8c
changes
abidlabs Dec 31, 2024
42a4333
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Dec 31, 2024
32bed0d
Revert "changes"
abidlabs Dec 31, 2024
48093c1
reorganize code
abidlabs Dec 31, 2024
edeb035
format
abidlabs Dec 31, 2024
abb8a8e
changes
abidlabs Dec 31, 2024
df7c388
add to deployed demos
abidlabs Jan 2, 2025
9e79e86
fix icons
abidlabs Jan 2, 2025
4fe0eaf
fix icon
abidlabs Jan 2, 2025
993b84e
Merge branch 'main' into chat-history
abidlabs Jan 2, 2025
b63a9bb
lint
abidlabs Jan 2, 2025
49be8b0
changes
abidlabs Jan 2, 2025
bcb7bc2
Merge branch 'chat-history' of github.com:gradio-app/gradio into chat…
abidlabs Jan 2, 2025
eaeb078
Merge branch 'main' into chat-history
abidlabs Jan 3, 2025
fc00a7d
example
abidlabs Jan 3, 2025
14f4899
changes
abidlabs Jan 3, 2025
25b590c
fix buttons
abidlabs Jan 3, 2025
01363e2
add changeset
gradio-pr-bot Jan 3, 2025
657e085
svg fix
dawoodkhan82 Jan 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .changeset/tiny-areas-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@gradio/button": minor
"@gradio/dataset": minor
"@gradio/downloadbutton": minor
"@gradio/textbox": minor
"@gradio/uploadbutton": minor
"gradio": minor
---

feat:Support saving chat history in `gr.ChatInterface`
1 change: 1 addition & 0 deletions demo/chatinterface_save_history/run.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_save_history"]}, {"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", "def echo_multimodal(message, history):\n", " response = \"You wrote: '\" + message[\"text\"] + \"' and uploaded: \" + str(len(message[\"files\"])) + \" files\"\n", " return response\n", "\n", "demo = gr.ChatInterface(\n", " echo_multimodal,\n", " type=\"messages\",\n", " multimodal=True,\n", " textbox=gr.MultimodalTextbox(file_count=\"multiple\"),\n", " save_history=True,\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
16 changes: 16 additions & 0 deletions demo/chatinterface_save_history/run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import gradio as gr

def echo_multimodal(message, history):
response = "You wrote: '" + message["text"] + "' and uploaded: " + str(len(message["files"])) + " files"
return response

demo = gr.ChatInterface(
echo_multimodal,
type="messages",
multimodal=True,
textbox=gr.MultimodalTextbox(file_count="multiple"),
save_history=True,
)

if __name__ == "__main__":
demo.launch()
2 changes: 1 addition & 1 deletion demo/chatinterface_streaming_echo/run.ipynb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_streaming_echo"]}, {"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 time\n", "import gradio as gr\n", "\n", "def slow_echo(message, history):\n", " for i in range(len(message)):\n", " time.sleep(0.05)\n", " yield \"You typed: \" + message[: i + 1]\n", "\n", "demo = gr.ChatInterface(slow_echo, type=\"messages\", flagging_mode=\"manual\", flagging_options=[\"Like\", \"Spam\", \"Inappropriate\", \"Other\"])\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
{"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: chatinterface_streaming_echo"]}, {"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 time\n", "import gradio as gr\n", "\n", "def slow_echo(message, history):\n", " for i in range(len(message)):\n", " time.sleep(0.05)\n", " yield \"You typed: \" + message[: i + 1]\n", "\n", "demo = gr.ChatInterface(\n", " slow_echo,\n", " type=\"messages\",\n", " flagging_mode=\"manual\",\n", " flagging_options=[\"Like\", \"Spam\", \"Inappropriate\", \"Other\"], \n", " save_history=True,\n", ")\n", "\n", "if __name__ == \"__main__\":\n", " demo.launch()\n"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
8 changes: 7 additions & 1 deletion demo/chatinterface_streaming_echo/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ def slow_echo(message, history):
time.sleep(0.05)
yield "You typed: " + message[: i + 1]

demo = gr.ChatInterface(slow_echo, type="messages", flagging_mode="manual", flagging_options=["Like", "Spam", "Inappropriate", "Other"])
demo = gr.ChatInterface(
slow_echo,
type="messages",
flagging_mode="manual",
flagging_options=["Like", "Spam", "Inappropriate", "Other"],
save_history=True,
)

if __name__ == "__main__":
demo.launch()
2 changes: 1 addition & 1 deletion gradio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@
"ImageEditor",
"ImageMask",
"Info",
"Success",
"Interface",
"JSON",
"Json",
Expand Down Expand Up @@ -204,6 +203,7 @@
"Sketchpad",
"Slider",
"State",
"Success",
"Tab",
"TabItem",
"TabbedInterface",
Expand Down
Loading
Loading