Spaces:
Sleeping
Sleeping
########################### | |
# UI for Meeting RAG Q&A. # | |
########################### | |
##################### Imports ##################### | |
import gradio as gr | |
from utilities.setup import get_files | |
#from server import EmbeddingService, QAService | |
from services.embed_service.embed import EmbeddingService | |
from server import QAService | |
#import spaces | |
#################### Functions #################### | |
def process_transcripts(files, context): | |
print(files) | |
with EmbeddingService(conf) as e: | |
f = e.run(files) | |
# some way to wait or a progress bar? | |
return "Completed Loading Data" | |
#@spaces.GPU | |
def retrieve_answer(question, context): | |
#with QAService(conf) as q: | |
# q.run(question) | |
return question + context | |
##################### 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"], | |
file_count='multiple') | |
goals = gr.Textbox(label="Goals for the Meeting", | |
value=conf["defaults"]["goals"]) # not incorporated yet. Will be with Q&A. | |
repository = gr.Textbox(label="Progress", value="Waiting for load...", visible=True) | |
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, goals], | |
outputs=model_output) | |
demo.launch() | |
##################### Execute ##################### | |
if __name__ == "__main__": | |
# Get config | |
conf = get_files.json_cfg() | |
main(conf) | |