Custom Components GalleryNEW
ExploreCustom Components GalleryNEW
ExploreNew to Gradio? Start here: Getting Started
See the Release History
gradio.ChatInterface(fn, ยทยทยท)
import gradio as gr
def echo(message, history):
return message
demo = gr.ChatInterface(fn=echo, examples=["hello", "hola", "merhaba"], title="Echo Bot")
demo.launch()
Parameter | Description |
---|---|
fn Callable required | The function to wrap the chat interface around. Should accept two parameters: a string input message and list of two-element lists of the form [[user_message, bot_message], ...] representing the chat history, and return a string response. See the Chatbot documentation for more information on the chat history format. |
multimodal bool default: False | If True, the chat interface will use a gr.MultimodalTextbox component for the input, which allows for the uploading of multimedia files. If False, the chat interface will use a gr.Textbox component for the input. |
chatbot Chatbot | None default: None | An instance of the gr.Chatbot component to use for the chat interface, if you would like to customize the chatbot properties. If not provided, a default gr.Chatbot component will be created. |
textbox Textbox | MultimodalTextbox | None default: None | An instance of the gr.Textbox or gr.MultimodalTextbox component to use for the chat interface, if you would like to customize the textbox properties. If not provided, a default gr.Textbox or gr.MultimodalTextbox component will be created. |
additional_inputs str | Component | list[str | Component] | None default: None | An instance or list of instances of gradio components (or their string shortcuts) to use as additional inputs to the chatbot. If components are not already rendered in a surrounding Blocks, then the components will be displayed under the chatbot, in an accordion. |
additional_inputs_accordion_name str | None default: None | Deprecated. Will be removed in a future version of Gradio. Use the |
additional_inputs_accordion str | Accordion | None default: None | If a string is provided, this is the label of the |
examples list[str] | list[dict[str, str | list]] | list[list] | None default: None | Sample inputs for the function; if provided, appear below the chatbot and can be clicked to populate the chatbot input. Should be a list of strings if |
cache_examples bool | Literal['lazy'] | None default: None | If True, caches examples in the server for fast runtime in examples. The default option in HuggingFace Spaces is True. The default option elsewhere is False. |
examples_per_page int default: 10 | If examples are provided, how many to display per page. |
title str | None default: None | a title for the interface; if provided, appears above chatbot in large font. Also used as the tab title when opened in a browser window. |
description str | None default: None | a description for the interface; if provided, appears above the chatbot and beneath the title in regular font. Accepts Markdown and HTML content. |
theme Theme | str | None default: None | Theme to use, loaded from gradio.themes. |
css str | None default: None | Custom css as a string or path to a css file. This css will be included in the demo webpage. |
js str | None default: None | Custom js as a string or path to a js file. The custom js should be in the form of a single js function. This function will automatically be executed when the page loads. For more flexibility, use the head parameter to insert js inside <script> tags. |
head str | None default: None | Custom html to insert into the head of the demo webpage. This can be used to add custom meta tags, multiple scripts, stylesheets, etc. to the page. |
analytics_enabled bool | None default: None | Whether to allow basic telemetry. If None, will use GRADIO_ANALYTICS_ENABLED environment variable if defined, or default to True. |
submit_btn str | None | Button default: "Submit" | Text to display on the submit button. If None, no button will be displayed. If a Button object, that button will be used. |
stop_btn str | None | Button default: "Stop" | Text to display on the stop button, which replaces the submit_btn when the submit_btn or retry_btn is clicked and response is streaming. Clicking on the stop_btn will halt the chatbot response. If set to None, stop button functionality does not appear in the chatbot. If a Button object, that button will be used as the stop button. |
retry_btn str | None | Button default: "๐ Retry" | Text to display on the retry button. If None, no button will be displayed. If a Button object, that button will be used. |
undo_btn str | None | Button default: "โฉ๏ธ Undo" | Text to display on the delete last button. If None, no button will be displayed. If a Button object, that button will be used. |
clear_btn str | None | Button default: "๐๏ธ Clear" | Text to display on the clear button. If None, no button will be displayed. If a Button object, that button will be used. |
autofocus bool default: True | If True, autofocuses to the textbox when the page loads. |
concurrency_limit int | None | Literal['default'] default: "default" | If set, this is the maximum number of chatbot submissions that can be running simultaneously. Can be set to None to mean no limit (any number of chatbot submissions can be running simultaneously). Set to "default" to use the default concurrency limit (defined by the |
fill_height bool default: True | If True, the chat interface will expand to the height of window. |
delete_cache tuple[int, int] | None default: None | A tuple corresponding [frequency, age] both expressed in number of seconds. Every |