Spaces:
Sleeping
Sleeping
File size: 2,332 Bytes
c7759ea bfbbbea c7759ea 1c03d71 bdf3e70 c7759ea e24890b bb2fd4a c7759ea bb2fd4a b1cf10f c7759ea 0a73bc9 c7759ea a40632d a52308c c7759ea aeb447f c7759ea f0bdafb aeb447f 2f1a468 c7759ea 2129e96 bb2fd4a c7759ea bc1c38e c7759ea 4df0f2d c7759ea 17dfda2 52589e7 c7759ea 52589e7 c7759ea |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
###########################
# 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)
|