Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MultimodalQnA/docker_compose/intel/cpu/xeon/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ services:
- DATAPREP_INGEST_SERVICE_ENDPOINT=${DATAPREP_INGEST_SERVICE_ENDPOINT}
- DATAPREP_GEN_TRANSCRIPT_SERVICE_ENDPOINT=${DATAPREP_GEN_TRANSCRIPT_SERVICE_ENDPOINT}
- DATAPREP_GEN_CAPTION_SERVICE_ENDPOINT=${DATAPREP_GEN_CAPTION_SERVICE_ENDPOINT}
- DATAPREP_GET_FILE_ENDPOINT=${DATAPREP_GET_FILE_ENDPOINT}
- DATAPREP_DELETE_FILE_ENDPOINT=${DATAPREP_DELETE_FILE_ENDPOINT}
- MEGA_SERVICE_PORT:=${MEGA_SERVICE_PORT}
- UI_PORT=${UI_PORT}
- DATAPREP_MMR_PORT=${DATAPREP_MMR_PORT}
Expand Down
58 changes: 58 additions & 0 deletions MultimodalQnA/ui/gradio/multimodalqna_ui_gradio.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,39 @@ def clear_text(request: gr.Request):
return None


def get_files():
try:
response = requests.post(dataprep_get_file_addr, headers=headers)
logger.info(response.status_code)
files = response.json()
Comment thread
dmsuehir marked this conversation as resolved.
if files:
html_content = "<ul>" + "".join(f"<li>{item}</li>" for item in files) + "</ul>"
yield (
gr.HTML(html_content, visible=True, max_height=200)
)
return
else:
yield (
gr.HTML("Vector store is empty.", visible=True)
)
return
except Exception as e:
logger.info(f"Error getting files from vector store: {str(e)}")


def delete_files():
import json

data = {"file_path": "all"}
try:
response = requests.post(dataprep_delete_file_addr, headers=headers, data=json.dumps(data))
logger.info(response.status_code)
yield (gr.update(value="Deleted all files!"))
return
except Exception as e:
logger.info(f"Error deleting files from vector store: {str(e)}")


with gr.Blocks() as upload_video:
gr.Markdown("# Ingest Videos Using Generated Transcripts or Captions")
gr.Markdown("Use this interface to ingest a video and generate transcripts or captions for it")
Expand Down Expand Up @@ -577,6 +610,19 @@ def select_upload_type(choice, request: gr.Request):
],
[state, chatbot, video, image, pdf, clear_btn],
)

with gr.Blocks() as vector_store:
gr.Markdown("# Uploaded Files")

with gr.Row():
with gr.Column(scale=6):
files = gr.HTML(visible=False)
with gr.Column(scale=3):
refresh_btn = gr.Button(value="↻ Refresh", interactive=True, variant="primary")
delete_btn = gr.Button(value="🗑️ Delete", interactive=True, variant="stop")
refresh_btn.click(get_files, None, [files])
delete_btn.click(delete_files, None, [files])

with gr.Blocks(css=css) as demo:
gr.Markdown("# MultimodalQnA")
with gr.Tabs():
Expand All @@ -590,6 +636,8 @@ def select_upload_type(choice, request: gr.Request):
upload_audio.render()
with gr.TabItem("Upload PDF"):
upload_pdf.render()
with gr.TabItem("Vector Store"):
vector_store.render()

demo.queue()
app = gr.mount_gradio_app(app, demo, path="/")
Expand Down Expand Up @@ -618,6 +666,12 @@ def select_upload_type(choice, request: gr.Request):
dataprep_gen_caption_endpoint = os.getenv(
"DATAPREP_GEN_CAPTION_SERVICE_ENDPOINT", f"http://localhost:{DATAPREP_MMR_PORT}/v1/generate_captions"
)
dataprep_get_file_endpoint = os.getenv(
"DATAPREP_GET_FILE_ENDPOINT", f"http://localhost:{DATAPREP_MMR_PORT}/v1/dataprep/get"
)
dataprep_delete_file_endpoint = os.getenv(
"DATAPREP_DELETE_FILE_ENDPOINT", f"http://localhost:{DATAPREP_MMR_PORT}/v1/dataprep/delete"
Comment thread
HarshaRamayanam marked this conversation as resolved.
)
args = parser.parse_args()
logger.info(f"args: {args}")
global gateway_addr
Expand All @@ -628,5 +682,9 @@ def select_upload_type(choice, request: gr.Request):
dataprep_gen_transcript_addr = dataprep_gen_transcript_endpoint
global dataprep_gen_caption_addr
dataprep_gen_caption_addr = dataprep_gen_caption_endpoint
global dataprep_get_file_addr
dataprep_get_file_addr = dataprep_get_file_endpoint
global dataprep_delete_file_addr
dataprep_delete_file_addr = dataprep_delete_file_endpoint

uvicorn.run(app, host=args.host, port=args.port)