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 all thinking tags to pass through in gr.Chatbot at least for models that are loaded with gr.load() #10684

Closed
abidlabs opened this issue Feb 26, 2025 · 3 comments · Fixed by #10743 or #10768
Assignees
Labels
enhancement New feature or request

Comments

@abidlabs
Copy link
Member

abidlabs commented Feb 26, 2025

Two parts to this issue:

(1) Allow developers to set allow_tags=True to let all tags to come through
(2) Make this the default for chatbots loaded for gr.load()

See this internal conversation

@abidlabs abidlabs added the enhancement New feature or request label Feb 26, 2025
@abidlabs abidlabs changed the title Allow all thinking tags to pass through, at least for models that are loaded with gr.load() Allow all thinking tags to pass through in gr.Chatbot at least for models that are loaded with gr.load() Feb 26, 2025
@hysts
Copy link
Collaborator

hysts commented Mar 8, 2025

I tried the wheel in #10743, but the issue still persists.

#10743 added these lines, but this change applies to gr.load_chat, not gr.load.

gradio/gradio/external.py

Lines 856 to 857 in dd2de17

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

So, the same code should be added to this part as well.

gradio/gradio/external.py

Lines 319 to 333 in dd2de17

if tags and "conversational" in tags:
from gradio import ChatInterface
fn = external_utils.conversational_wrapper(client)
examples = [
"What is the capital of Pakistan?",
"Tell me a joke about calculus.",
"Explain gravity to a 5-year-old.",
"What were the main causes of World War I?",
]
chat_interface_kwargs = {
"examples": examples,
}
kwargs = dict(chat_interface_kwargs, **kwargs)
return ChatInterface(fn, type="messages", **kwargs) # type: ignore

Also, I think it would be better to pass gr.Chatbot(type="messages", scale=1, allow_tags=True) instead.
As type="messages" is specified when instantiating gr.ChatInterface in gr.load and gr.load_chat, without specifying it in gr.Chatbot, a deprecation warning appears in the log. It's harmless, but a bit annoying.
When passing gr.Chatbot to gr.ChatInterface without specifying scale=1, the default height of 400 is used, and it's rendered like this:

@hysts hysts reopened this Mar 8, 2025
@abidlabs
Copy link
Member Author

abidlabs commented Mar 8, 2025

Thanks @hysts agreed

@dawoodkhan82
Copy link
Collaborator

Thanks @hysts, opened a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
3 participants