Spaces:
Sleeping
Sleeping
File size: 1,294 Bytes
38b9924 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import gradio as gr
def general_chat(text: str, gr_history: list):
yield text
def online_chat(gr_webcam_image, gr_history: list):
if gr_webcam_image:
query = {"role": "user", "content": (gr_webcam_image, )}
response = {"role": "assistant", "content": 'this is a frame.'}
gr_history.extend([query, response])
yield gr_history
with gr.Blocks() as demo:
gr.Markdown("## Simple Streaming Record and Response")
with gr.Row():
with gr.Column():
gr_webcam_image = gr.Image(
label='WebCam',
sources="webcam",
height=250,
type='filepath')
gr_chatinterface_ol = gr.ChatInterface(
fn=general_chat,
type="messages",
multimodal=True,
)
gr_webcam_image.stream(
fn=online_chat,
inputs=[gr_webcam_image, gr_chatinterface_ol.chatbot],
outputs=[gr_chatinterface_ol.chatbot],
stream_every=1,
concurrency_limit=30,
)
demo.queue(default_concurrency_limit=100, max_size=100).launch(share=True,
max_threads=100,
ssr_mode=False) |