Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -180,73 +180,64 @@ def test():
|
|
180 |
def call_test():
|
181 |
return {"message": test()}
|
182 |
|
183 |
-
|
184 |
-
gr.
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
|
|
|
|
237 |
|
238 |
if __name__ == "__main__":
|
239 |
-
def run_fastapi():
|
240 |
-
uvicorn.run(app, host="0.0.0.0", port=8000)
|
241 |
-
|
242 |
-
def run_gradio():
|
243 |
-
demo.queue(api_open=False).launch(show_api=False, share=False)
|
244 |
-
|
245 |
-
fastapi_thread = Thread(target=run_fastapi)
|
246 |
-
fastapi_thread.start()
|
247 |
-
|
248 |
gradio_thread = Thread(target=run_gradio)
|
249 |
gradio_thread.start()
|
250 |
-
|
251 |
-
fastapi_thread.join()
|
252 |
-
gradio_thread.join()
|
|
|
180 |
def call_test():
|
181 |
return {"message": test()}
|
182 |
|
183 |
+
def run_gradio():
|
184 |
+
with gr.Blocks(css=CSS, theme="soft", fill_height=True) as demo:
|
185 |
+
gr.HTML(TITLE)
|
186 |
+
gr.HTML(DESCRIPTION)
|
187 |
+
gr.ChatInterface(
|
188 |
+
fn=stream_chat,
|
189 |
+
multimodal=True,
|
190 |
+
textbox=chat_input,
|
191 |
+
chatbot=chatbot,
|
192 |
+
fill_height=True,
|
193 |
+
additional_inputs_accordion=gr.Accordion(label="⚙️ Parameters", open=False, render=False),
|
194 |
+
additional_inputs=[
|
195 |
+
gr.Slider(
|
196 |
+
minimum=0,
|
197 |
+
maximum=1,
|
198 |
+
step=0.1,
|
199 |
+
value=0.8,
|
200 |
+
label="Temperature",
|
201 |
+
render=False,
|
202 |
+
),
|
203 |
+
gr.Slider(
|
204 |
+
minimum=1024,
|
205 |
+
maximum=8192,
|
206 |
+
step=1,
|
207 |
+
value=4096,
|
208 |
+
label="Max Length",
|
209 |
+
render=False,
|
210 |
+
),
|
211 |
+
gr.Slider(
|
212 |
+
minimum=0.0,
|
213 |
+
maximum=1.0,
|
214 |
+
step=0.1,
|
215 |
+
value=1.0,
|
216 |
+
label="top_p",
|
217 |
+
render=False,
|
218 |
+
),
|
219 |
+
gr.Slider(
|
220 |
+
minimum=1,
|
221 |
+
maximum=20,
|
222 |
+
step=1,
|
223 |
+
value=10,
|
224 |
+
label="top_k",
|
225 |
+
render=False,
|
226 |
+
),
|
227 |
+
gr.Slider(
|
228 |
+
minimum=0.0,
|
229 |
+
maximum=2.0,
|
230 |
+
step=0.1,
|
231 |
+
value=1.0,
|
232 |
+
label="Repetition penalty",
|
233 |
+
render=False,
|
234 |
+
),
|
235 |
+
],
|
236 |
+
),
|
237 |
+
gr.Examples(EXAMPLES, [chat_input])
|
238 |
+
demo.queue(api_open=False).launch(show_api=False, share=False)
|
239 |
|
240 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
gradio_thread = Thread(target=run_gradio)
|
242 |
gradio_thread.start()
|
243 |
+
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|
|