import { createSignal, createEffect, For, onMount, Show, mergeProps, on, createMemo } from 'solid-js'; import { v4 as uuidv4 } from 'uuid'; import { sendMessageQuery, upsertVectorStoreWithFormData, isStreamAvailableQuery, IncomingInput, getChatbotConfig, FeedbackRatingType, createAttachmentWithFormData, } from '@/queries/sendMessageQuery'; import { TextInput } from './inputs/textInput'; import { GuestBubble } from './bubbles/GuestBubble'; import { BotBubble } from './bubbles/BotBubble'; import { LoadingBubble } from './bubbles/LoadingBubble'; import { StarterPromptBubble } from './bubbles/StarterPromptBubble'; import { BotMessageTheme, FooterTheme, TextInputTheme, UserMessageTheme, FeedbackTheme, DisclaimerPopUpTheme, DateTimeToggleTheme, } from '@/features/bubble/types'; import { Badge } from './Badge'; import { Popup, DisclaimerPopup } from '@/features/popup'; import { Avatar } from '@/components/avatars/Avatar'; import { DeleteButton, SendButton } from '@/components/buttons/SendButton'; import { FilePreview } from '@/components/inputs/textInput/components/FilePreview'; import { CircleDotIcon, SparklesIcon, TrashIcon, XIcon, ResetIcon } from './icons'; import { CancelButton } from './buttons/CancelButton'; import { cancelAudioRecording, startAudioRecording, stopAudioRecording } from '@/utils/audioRecording'; import { LeadCaptureBubble } from '@/components/bubbles/LeadCaptureBubble'; import { removeLocalStorageChatHistory, getLocalStorageChatflow, setLocalStorageChatflow, setCookie, getCookie } from '@/utils'; import { cloneDeep } from 'lodash'; import { FollowUpPromptBubble } from '@/components/bubbles/FollowUpPromptBubble'; import { fetchEventSource, EventStreamContentType } from '@microsoft/fetch-event-source'; export type FileEvent = { target: T; }; export type FormEvent = { preventDefault: () => void; currentTarget: T; }; type IUploadConstraits = { fileTypes: string[]; maxUploadSize: number; }; export type UploadsConfig = { imgUploadSizeAndTypes: IUploadConstraits[]; fileUploadSizeAndTypes: IUploadConstraits[]; isImageUploadAllowed: boolean; isSpeechToTextEnabled: boolean; isRAGFileUploadAllowed: boolean; }; type FilePreviewData = string | ArrayBuffer; type FilePreview = { data: FilePreviewData; mime: string; name: string; preview: string; type: string; }; type messageType = 'apiMessage' | 'userMessage' | 'usermessagewaiting' | 'leadCaptureMessage'; type ExecutionState = 'INPROGRESS' | 'FINISHED' | 'ERROR' | 'TERMINATED' | 'TIMEOUT' | 'STOPPED'; export type IAgentReasoning = { agentName?: string; messages?: string[]; usedTools?: any[]; artifacts?: FileUpload[]; sourceDocuments?: any[]; instructions?: string; nextAgent?: string; }; export type IAction = { id?: string; data?: any; elements?: Array<{ type: string; label: string; }>; mapping?: { approve: string; reject: string; toolCalls: any[]; }; }; export type FileUpload = Omit; export type AgentFlowExecutedData = { nodeLabel: string; nodeId: string; data: any; previousNodeIds: string[]; status?: ExecutionState; }; export type MessageType = { messageId?: string; message: string; type: messageType; sourceDocuments?: any; fileAnnotations?: any; fileUploads?: Partial[]; artifacts?: Partial[]; agentReasoning?: IAgentReasoning[]; execution?: any; agentFlowEventStatus?: string; agentFlowExecutedData?: any; usedTools?: any[]; toolExecutionStatus?: any[]; action?: IAction | null; rating?: FeedbackRatingType; id?: string; followUpPrompts?: string; dateTime?: string; }; type IUploads = { data: FilePreviewData; type: string; name: string; mime: string; }[]; type observerConfigType = (accessor: string | boolean | object | MessageType[]) => void; export type observersConfigType = Record<'observeUserInput' | 'observeLoading' | 'observeMessages', observerConfigType>; export type BotProps = { chatflowid: string; apiHost?: string; onRequest?: (request: RequestInit) => Promise; chatflowConfig?: Record; backgroundColor?: string; welcomeMessage?: string; errorMessage?: string; botMessage?: BotMessageTheme; userMessage?: UserMessageTheme; textInput?: TextInputTheme; feedback?: FeedbackTheme; poweredByTextColor?: string; badgeBackgroundColor?: string; bubbleBackgroundColor?: string; bubbleTextColor?: string; showTitle?: boolean; showAgentMessages?: boolean; title?: string; titleAvatarSrc?: string; titleTextColor?: string; titleBackgroundColor?: string; formBackgroundColor?: string; formTextColor?: string; fontSize?: number; isFullPage?: boolean; footer?: FooterTheme; sourceDocsTitle?: string; observersConfig?: observersConfigType; starterPrompts?: string[] | Record; starterPromptFontSize?: number; clearChatOnReload?: boolean; disclaimer?: DisclaimerPopUpTheme; dateTimeToggle?: DateTimeToggleTheme; renderHTML?: boolean; closeBot?: () => void; }; export type LeadsConfig = { status: boolean; title?: string; name?: boolean; email?: boolean; phone?: boolean; successMessage?: string; }; const defaultWelcomeMessage = 'Hi there! How can I help?'; /*const sourceDocuments = [ { "pageContent": "I know some are talking about "living with COVID-19". Tonight – I say that we will never just accept living with COVID-19. \r\n\r\nWe will continue to combat the virus as we do other diseases. And because this is a virus that mutates and spreads, we will stay on guard. \r\n\r\nHere are four common sense steps as we move forward safely. \r\n\r\nFirst, stay protected with vaccines and treatments. We know how incredibly effective vaccines are. If you're vaccinated and boosted you have the highest degree of protection. \r\n\r\nWe will never give up on vaccinating more Americans. Now, I know parents with kids under 5 are eager to see a vaccine authorized for their children. \r\n\r\nThe scientists are working hard to get that done and we'll be ready with plenty of vaccines when they do. \r\n\r\nWe're also ready with anti-viral treatments. If you get COVID-19, the Pfizer pill reduces your chances of ending up in the hospital by 90%.", "metadata": { "source": "blob", "blobType": "", "loc": { "lines": { "from": 450, "to": 462 } } } }, { "pageContent": "sistance, and polishing [65]. For instance, AI tools generate\nsuggestions based on inputting keywords or topics. The tools\nanalyze search data, trending topics, and popular queries to\ncreate fresh content. What's more, AIGC assists in writing\narticles and posting blogs on specific topics. While these tools\nmay not be able to produce high-quality content by themselves,\nthey can provide a starting point for a writer struggling with\nwriter's block.\nH. Cons of AIGC\nOne of the main concerns among the public is the potential\nlack of creativity and human touch in AIGC. In addition,\nAIGC sometimes lacks a nuanced understanding of language\nand context, which may lead to inaccuracies and misinterpre-\ntations. There are also concerns about the ethics and legality\nof using AIGC, particularly when it results in issues such as\ncopyright infringement and data privacy. In this section, we\nwill discuss some of the disadvantages of AIGC (Table IV).", "metadata": { "source": "blob", "blobType": "", "pdf": { "version": "1.10.100", "info": { "PDFFormatVersion": "1.5", "IsAcroFormPresent": false, "IsXFAPresent": false, "Title": "", "Author": "", "Subject": "", "Keywords": "", "Creator": "LaTeX with hyperref", "Producer": "pdfTeX-1.40.21", "CreationDate": "D:20230414003603Z", "ModDate": "D:20230414003603Z", "Trapped": { "name": "False" } }, "metadata": null, "totalPages": 17 }, "loc": { "pageNumber": 8, "lines": { "from": 301, "to": 317 } } } }, { "pageContent": "Main article: Views of Elon Musk", "metadata": { "source": "https://en.wikipedia.org/wiki/Elon_Musk", "loc": { "lines": { "from": 2409, "to": 2409 } } } }, { "pageContent": "First Name: John\nLast Name: Doe\nAddress: 120 jefferson st.\nStates: Riverside\nCode: NJ\nPostal: 8075", "metadata": { "source": "blob", "blobType": "", "line": 1, "loc": { "lines": { "from": 1, "to": 6 } } } }, ]*/ const defaultBackgroundColor = '#ffffff'; const defaultTextColor = '#303235'; const defaultTitleBackgroundColor = '#3B81F6'; /* FeedbackDialog component - for collecting user feedback */ const FeedbackDialog = (props: { isOpen: boolean; onClose: () => void; onSubmit: () => void; feedbackValue: string; setFeedbackValue: (value: string) => void; }) => { return (

Your Feedback