feat(Chat Trigger Node): Add support for file uploads & harmonize public and development chat (#9802)

Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
oleg
2024-07-09 13:45:41 +02:00
committed by GitHub
parent 501bcd80ff
commit df783151b8
32 changed files with 2309 additions and 940 deletions

View File

@@ -8,6 +8,8 @@ export function createPage({
i18n: { en },
initialMessages,
authentication,
allowFileUploads,
allowedFilesMimeTypes,
}: {
instanceId: string;
webhookUrl?: string;
@@ -19,6 +21,8 @@ export function createPage({
initialMessages: string[];
mode: 'test' | 'production';
authentication: AuthenticationChatOption;
allowFileUploads?: boolean;
allowedFilesMimeTypes?: string;
}) {
const validAuthenticationOptions: AuthenticationChatOption[] = [
'none',
@@ -35,6 +39,8 @@ export function createPage({
? authentication
: 'none';
const sanitizedShowWelcomeScreen = !!showWelcomeScreen;
const sanitizedAllowFileUploads = !!allowFileUploads;
const sanitizedAllowedFilesMimeTypes = allowedFilesMimeTypes?.toString() ?? '';
const sanitizedLoadPreviousSession = validLoadPreviousSessionOptions.includes(
loadPreviousSession as LoadPreviousSessionChatOption,
)
@@ -103,6 +109,8 @@ export function createPage({
'X-Instance-Id': '${instanceId}',
}
},
allowFileUploads: ${sanitizedAllowFileUploads},
allowedFilesMimeTypes: '${sanitizedAllowedFilesMimeTypes}',
i18n: {
${en ? `en: ${JSON.stringify(en)},` : ''}
},