Spaces:
Runtime error
Runtime error
Removed explicit render() on the chatbot component
Browse filesKey Changes:
Remove Explicit render() on the Chatbot Component:
gr.ChatInterface already handles the rendering of the chatbot, so you don’t need to call render() for the chatbot component directly. This should prevent the DuplicateBlockError.
Let Gradio Manage the Chatbot:
Gradio automatically handles component rendering inside ChatInterface. By avoiding extra manual rendering, you reduce the risk of duplicating components.
app.py
CHANGED
|
@@ -124,27 +124,27 @@ def respond(message, history, max_tokens, temperature, top_p):
|
|
| 124 |
# Gradio Chat Interface
|
| 125 |
with gr.Blocks() as demo:
|
| 126 |
# Ensure info_text_component is only rendered once
|
| 127 |
-
info_text_component.render() # Render
|
| 128 |
|
| 129 |
with gr.Accordion("Advanced Options", open=False):
|
| 130 |
max_tokens_slider = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
|
| 131 |
-
temperature_slider = gr.Slider(minimum=0.1, maximum
|
| 132 |
top_p_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
| 133 |
|
| 134 |
-
# Initialize the chatbot
|
| 135 |
chatbot = gr.ChatInterface(
|
| 136 |
respond,
|
| 137 |
-
chatbot=gr.Chatbot(height=600),
|
| 138 |
textbox=gr.Textbox(
|
| 139 |
-
placeholder="Type your message here (eg. How to do great work by Paul Graham?)",
|
| 140 |
-
container=False,
|
| 141 |
scale=7
|
| 142 |
),
|
| 143 |
additional_inputs=[
|
| 144 |
max_tokens_slider,
|
| 145 |
temperature_slider,
|
| 146 |
top_p_slider
|
| 147 |
-
]
|
| 148 |
)
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|
|
|
|
| 124 |
# Gradio Chat Interface
|
| 125 |
with gr.Blocks() as demo:
|
| 126 |
# Ensure info_text_component is only rendered once
|
| 127 |
+
info_text_component.render() # Render once
|
| 128 |
|
| 129 |
with gr.Accordion("Advanced Options", open=False):
|
| 130 |
max_tokens_slider = gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens")
|
| 131 |
+
temperature_slider = gr.Slider(minimum=0.1, maximum 4.0, value=0.7, step=0.1, label="Temperature")
|
| 132 |
top_p_slider = gr.Slider(minimum=0.1, maximum=1.0, value=0.95, step=0.05, label="Top-p (nucleus sampling)")
|
| 133 |
|
| 134 |
+
# Initialize the Chatbot without explicit rendering of the chatbot block
|
| 135 |
chatbot = gr.ChatInterface(
|
| 136 |
respond,
|
| 137 |
+
chatbot=gr.Chatbot(height=600), # No need to call render() on this chatbot
|
| 138 |
textbox=gr.Textbox(
|
| 139 |
+
placeholder="Type your message here (eg. How to do great work by Paul Graham?)",
|
| 140 |
+
container=False,
|
| 141 |
scale=7
|
| 142 |
),
|
| 143 |
additional_inputs=[
|
| 144 |
max_tokens_slider,
|
| 145 |
temperature_slider,
|
| 146 |
top_p_slider
|
| 147 |
+
]
|
| 148 |
)
|
| 149 |
|
| 150 |
if __name__ == "__main__":
|