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

Allow tags for chatbot models using gr.load #10768

Merged
merged 3 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/yummy-shirts-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

feat:Allow tags for chatbot models using `gr.load`
8 changes: 6 additions & 2 deletions gradio/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ def custom_post_binary(data):
# Example: meta-llama/Meta-Llama-3-8B-Instruct
if tags and "conversational" in tags:
from gradio import ChatInterface
from gradio.components import Chatbot

fn = external_utils.conversational_wrapper(client)
examples = [
Expand All @@ -330,7 +331,8 @@ def custom_post_binary(data):
"examples": examples,
}
kwargs = dict(chat_interface_kwargs, **kwargs)
return ChatInterface(fn, type="messages", **kwargs) # type: ignore
chatbot = Chatbot(scale=1, type="messages", allow_tags=True)
return ChatInterface(fn, chatbot=chatbot, type="messages", **kwargs) # type: ignore
inputs = components.Textbox(label="Text")
outputs = inputs
examples = ["Once upon a time"]
Expand Down Expand Up @@ -854,7 +856,9 @@ def open_api_stream(
)

if "chatbot" not in kwargs:
kwargs["chatbot"] = gr.Chatbot(allow_tags=True)
from gradio.components import Chatbot

kwargs["chatbot"] = Chatbot(type="messages", scale=1, allow_tags=True)

return ChatInterface(
open_api_stream if streaming else open_api,
Expand Down
Loading