Chawit Chaijirawiwat
add more example to gradio app
42ebff1
import gradio as gr
from get_langchain_fn import langchain_retrieval_invoke
def gradio_app():
with gr.Blocks() as demo:
gr.Markdown("## Video Content Retrieval")
gr.Markdown("When you want to rewatch some youtube videos for a specific content but cannot find it easily, try inputting the youtube url along with the content you want to hear about")
gr.Markdown("You should get the video url with the timestamp of that part, and the summary of that!")
# Input
with gr.Row():
video_ids = gr.Textbox(label="Enter video url(s) separated by comma")
with gr.Row():
content = gr.Textbox(label="Enter your content you want to rewatch")
# Output
with gr.Row():
with gr.Column():
gr.Markdown("output url")
url_output = gr.HTML(label="URL with timestamp")
summary_output = gr.Textbox(label="Summary", interactive=False)
# Submit button
submit_btn = gr.Button("Submit")
# Example inputs
examples = [['https://www.youtube.com/watch?v=wDVteayWWvU', 'Q learning using neural network which is good in case of milliions of possible states like chess game'],
['https://www.youtube.com/watch?v=00jbG_cfGuQ, https://www.youtube.com/watch?v=sQK3Yr4Sc_k', 'Krebs cycle'],
['https://www.youtube.com/watch?v=62wEk02YKs0', 'how caffaine actaully works']
]
# Define the action on submit
submit_btn.click(fn=langchain_retrieval_invoke, inputs=[video_ids, content], outputs=[url_output, summary_output])
# Example button
gr.Examples(examples=examples, inputs=[video_ids, content])
return demo
# Launch the app
demo = gradio_app()
demo.launch()