@@ -130,11 +130,6 @@ def inference(latest_message, history):
130
130
raise gr .Error ("Unexpected error encountered - see logs for details." )
131
131
132
132
133
- # UI theming
134
- theme = gr .themes .Default (** settings .theme_params )
135
- theme .set (** settings .theme_params_extended )
136
-
137
-
138
133
def inference_wrapper (* args ):
139
134
"""
140
135
Simple wrapper round the `inference` function which catches certain predictable errors
@@ -152,30 +147,26 @@ def inference_wrapper(*args):
152
147
yield chunk
153
148
154
149
155
- # Build main chat interface
156
- app = gr .ChatInterface (
157
- inference_wrapper ,
158
- chatbot = gr .Chatbot (
159
- # Height of conversation window in CSS units (string) or pixels (int)
160
- height = "68vh" ,
161
- show_copy_button = True ,
162
- ),
163
- textbox = gr .Textbox (
164
- placeholder = "Ask me anything..." ,
165
- container = False ,
166
- # Ratio of text box to submit button width
167
- scale = 7 ,
168
- ),
169
- title = settings .page_title ,
170
- retry_btn = "Retry" ,
171
- undo_btn = "Undo" ,
172
- clear_btn = "Clear" ,
173
- analytics_enabled = False ,
150
+ # UI theming
151
+ theme = gr .themes .Default (** settings .theme_params )
152
+ theme .set (** settings .theme_params_extended )
153
+
154
+ with gr .Blocks (
155
+ fill_height = True ,
174
156
theme = theme ,
175
157
css = settings .css_overrides ,
176
- js = settings .custom_javascript ,
177
- )
178
- log .debug ("Gradio chat interface config: %s" , app .config )
179
- app .queue (
180
- default_concurrency_limit = 10 ,
181
- ).launch (server_name = settings .host_address )
158
+ js = settings .custom_javascript
159
+ ) as demo :
160
+ gr .ChatInterface (
161
+ inference_wrapper ,
162
+ type = "messages" ,
163
+ title = settings .page_title ,
164
+ analytics_enabled = False ,
165
+ )
166
+
167
+
168
+ if __name__ == "__main__" :
169
+ log .debug ("Gradio chat interface config: %s" , demo .config )
170
+ demo .queue (
171
+ default_concurrency_limit = 10 ,
172
+ ).launch (server_name = settings .host_address )
0 commit comments