Skip to content

Commit

Permalink
feat: Implemented functionality to enable multilingual filename uploa…
Browse files Browse the repository at this point in the history
…ds in the Admin App. (#1404)
  • Loading branch information
Prasanjeet-Microsoft authored Oct 14, 2024
1 parent 28e628a commit 3b0c22e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion code/backend/pages/01_Ingest_Data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from os import path
import re
import streamlit as st
import traceback
import requests
Expand Down Expand Up @@ -56,6 +57,11 @@ def add_urls():
add_url_embeddings(urls)


def sanitize_metadata_value(value):
# Remove invalid characters
return re.sub(r"[^a-zA-Z0-9-_ .]", "?", value)


def add_url_embeddings(urls: list[str]):
params = {}
if env_helper.FUNCTION_KEY is not None:
Expand Down Expand Up @@ -89,7 +95,7 @@ def add_url_embeddings(urls: list[str]):
for up in uploaded_files:
# To read file as bytes:
bytes_data = up.getvalue()
title = up.name.encode("latin-1", "replace").decode("latin-1")
title = sanitize_metadata_value(up.name)
if st.session_state.get("filename", "") != up.name:
# Upload a new file
st.session_state["filename"] = up.name
Expand Down

0 comments on commit 3b0c22e

Please sign in to comment.