########################### # UI for Meeting RAG Q&A. # ########################### ##################### Imports ##################### import gradio as gr from utilities.setup import get_files from server import EmbeddingService, QAService #################### Functions #################### def process_transcripts(files, context): print(files) print(context) #with EmbeddingService(conf) as e: # e.run(files) # some way to wait or a progress bar? return context def retrieve_answer(question): with QAService(conf) as q: q.run(question) answer = retriever.answer() return answer ##################### Process ##################### def main(conf): with gr.Blocks() as demo: # Main page with gr.TabItem(conf["layout"]["page_names"][0]): gr.Markdown(get_files.load_markdown_file(conf["layout"]["about"])) # User config page with gr.TabItem(conf["layout"]["page_names"][1]): gr.Markdown("# Upload Transcript and Necessary Context") gr.Markdown("Please wait as the transcript is being processed.") load_file = gr.UploadButton(label="Upload Transcript (.vtt)", file_types=[".vtt"]) goals = gr.Textbox(label="Goals for the Meeting", value=conf["defaults"]["goals"]) # not incorporated yet. Will be with Q&A. repository = gr.Textbox(label="Blank", visible=True) # since there is no output. load_file.upload(process_transcripts, [load_file, goals], repository) # Meeting Question & Answer Page with gr.TabItem(conf["layout"]["page_names"][2]): question = gr.Textbox(label="Ask a Question", value=conf["defaults"]["question"]) ask_button = gr.Button("Ask!") model_output = gr.components.Textbox(label="Answer") ask_button.click(fn=retrieve_answer, inputs=question, outputs=model_output) demo.launch() ##################### Execute ##################### if __name__ == "__main__": # Get config conf = get_files.json_cfg() main(conf)