🐛(config) restrict uploadable file types for RAG
This allows to let the frontend know whi file types can be uploaded to do RAG. By default it's the format accepted by markitdown + PDF.
This commit is contained in:
@@ -500,6 +500,42 @@ class Base(Configuration):
|
||||
environ_prefix=None,
|
||||
)
|
||||
|
||||
# Uploaded files
|
||||
RAG_FILES_ACCEPTED_FORMATS = values.ListValue(
|
||||
default=[
|
||||
# docx files
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
# pptx files
|
||||
"application/vnd.openxmlformats-officedocument.presentationml",
|
||||
# xlsx and xls files
|
||||
"application/vnd.ms-excel",
|
||||
"application/excel",
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
# txt and csv files
|
||||
"text/plain",
|
||||
"text/csv",
|
||||
"application/csv",
|
||||
# pdf files
|
||||
"application/pdf",
|
||||
# html files
|
||||
"text/html",
|
||||
"application/xhtml+xml",
|
||||
# markdown files
|
||||
"text/markdown",
|
||||
"application/markdown",
|
||||
"application/x-markdown",
|
||||
# outlook msg files
|
||||
"application/vnd.ms-outlook",
|
||||
# images
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/gif",
|
||||
"image/webp",
|
||||
],
|
||||
environ_name="RAG_FILES_ACCEPTED_FORMATS",
|
||||
environ_prefix=None,
|
||||
)
|
||||
|
||||
# Documents
|
||||
ALBERT_API_PARSE_TIMEOUT = values.PositiveIntegerValue(
|
||||
default=120, # seconds
|
||||
|
||||
@@ -216,6 +216,8 @@ class ConfigView(drf.views.APIView):
|
||||
|
||||
dict_settings["theme_customization"] = self._load_theme_customization()
|
||||
|
||||
dict_settings["chat_upload_accept"] = ",".join(settings.RAG_FILES_ACCEPTED_FORMATS)
|
||||
|
||||
return drf.response.Response(dict_settings)
|
||||
|
||||
def _load_theme_customization(self):
|
||||
|
||||
@@ -25,6 +25,10 @@ pytestmark = pytest.mark.django_db
|
||||
POSTHOG_KEY={"id": "132456", "host": "https://eu.i.posthog-test.com"},
|
||||
SENTRY_DSN="https://sentry.test/123",
|
||||
THEME_CUSTOMIZATION_FILE_PATH="",
|
||||
RAG_FILES_ACCEPTED_FORMATS=[
|
||||
"application/pdf",
|
||||
"text/plain",
|
||||
],
|
||||
)
|
||||
@pytest.mark.parametrize("is_authenticated", [False, True])
|
||||
def test_api_config(is_authenticated):
|
||||
@@ -55,6 +59,7 @@ def test_api_config(is_authenticated):
|
||||
"POSTHOG_KEY": {"id": "132456", "host": "https://eu.i.posthog-test.com"},
|
||||
"SENTRY_DSN": "https://sentry.test/123",
|
||||
"theme_customization": {},
|
||||
"chat_upload_accept": "application/pdf,text/plain",
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ export interface ConfigResponse {
|
||||
POSTHOG_KEY?: PostHogConf;
|
||||
SENTRY_DSN?: string;
|
||||
theme_customization?: ThemeCustomization;
|
||||
chat_upload_accept?: string;
|
||||
}
|
||||
|
||||
const LOCAL_STORAGE_KEY = 'conversations_config';
|
||||
|
||||
@@ -18,6 +18,26 @@ export const CONFIG = {
|
||||
POSTHOG_KEY: {},
|
||||
SENTRY_DSN: null,
|
||||
theme_customization: {},
|
||||
chat_upload_accept:
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document,' +
|
||||
'application/vnd.openxmlformats-officedocument.presentationml,' +
|
||||
'application/vnd.ms-excel,' +
|
||||
'application/excel,' +
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,' +
|
||||
'text/plain,' +
|
||||
'text/csv,' +
|
||||
'application/csv,' +
|
||||
'application/pdf,' +
|
||||
'text/html,' +
|
||||
'application/xhtml+xml,' +
|
||||
'text/markdown,' +
|
||||
'application/markdown,' +
|
||||
'application/x-markdown' +
|
||||
',application/vnd.ms-outlook,' +
|
||||
'image/jpeg,' +
|
||||
'image/png,' +
|
||||
'image/gif,' +
|
||||
'image/webp',
|
||||
} as const;
|
||||
|
||||
export const overrideConfig = async (
|
||||
@@ -54,9 +74,7 @@ export const keyCloakSignIn = async (
|
||||
const password = `password-e2e-${browserName}`;
|
||||
|
||||
await expect(page).toHaveURL(/http:\/\/localhost:8083\/.+/);
|
||||
await expect(
|
||||
page.getByText('conversations'),
|
||||
).toBeVisible();
|
||||
await expect(page.getByText('conversations')).toBeVisible();
|
||||
|
||||
if (await page.getByLabel('Restart login').isVisible()) {
|
||||
await page.getByLabel('Restart login').click();
|
||||
|
||||
Reference in New Issue
Block a user