141582-ACCENTCARE HOSPICE & PALLIATIVE CARE OF ILLINOIS – Hospice Report (2024)

';let aiName = '

Jessica L.

';let sysName = 'System:';let env = 'chatbot';let apiKey = '';let session = 'N/A';let mode = 'chat';let model = 'gpt-3.5-turbo';let context = isCasuallyFineTuned ? null : 'Converse as if you were an Medical Professional. Be Friendly. If prompt does not contain a question or statement regarding Hospice Care, Palliative Care, or general greeting, respond with a friendly request to keep conversation or topics related to hospice or palliative care.';let embeddingsIndex = '';let promptEnding = '';let stop = '';let startSentence = 'Hi! Let me know if you have any questions regarding hospice care.';let maxSentences = 15;let memorizeChat = false;let maxTokens = 1024;let maxResults = 1;let temperature = 1;let memorizedChat = [];let typewriter = false;let copyButton = true;if (isDebugMode) {window.mwai_668e7a38a91d7 = {memorizedChat: memorizedChat,parameters: { mode: mode, model, temperature, maxTokens, context: context, startSentence,isMobile, isWindow, isFullscreen, isCasuallyFineTuned, memorizeChat, maxSentences,rawUserName, rawAiName, embeddingsIndex, typewriter, maxResults, userName, aiName, env, apiKey, session}};}// Set button textfunction setButtonText() {let input = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-input textarea');let button = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-input button');let buttonSpan = button.querySelector('span');if (memorizedChat.length < 2) {buttonSpan.innerHTML = 'Send';}else if (!input.value.length) {button.classList.add('mwai-clear');buttonSpan.innerHTML = 'Clear';}else {button.classList.remove('mwai-clear');buttonSpan.innerHTML = 'Send';}}// Inject timerfunction injectTimer(element) {let intervalId;let startTime = new Date();let timerElement = null;function updateTimer() {let now = new Date();let timer = Math.floor((now - startTime) / 1000);if (!timerElement) {if (timer > 0.5) {timerElement = document.createElement('div');timerElement.classList.add('mwai-timer');element.appendChild(timerElement);}}if (timerElement) {let minutes = Math.floor(timer / 60);let seconds = timer - (minutes * 60);seconds = seconds < 10 ? '0' + seconds : seconds;let display = minutes + ':' + seconds;timerElement.innerHTML = display;}}intervalId = setInterval(updateTimer, 500);return function stopTimer() {clearInterval(intervalId);if (timerElement) {timerElement.remove();}};}// Push the reply in the conversationfunction addReply(text, role = 'user', replay = false) {var conversation = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-conversation');if (memorizeChat) {localStorage.setItem('mwai-chat-668e7a38a91d7', JSON.stringify(memorizedChat));}// If text is array, then it's image URLs. Let's create a simple gallery in HTML in $text.if (Array.isArray(text)) {var newText = '

';for (var i = 0; i < text.length; i++) {newText += '';}text = newText + '

';}var mwaiClasses = ['mwai-reply'];if (role === 'assistant') {mwaiClasses.push('mwai-ai');}else if (role === 'system') {mwaiClasses.push('mwai-system');}else {mwaiClasses.push('mwai-user');}var div = document.createElement('div');div.classList.add(...mwaiClasses);var nameSpan = document.createElement('span');nameSpan.classList.add('mwai-name');if (role === 'assistant') {nameSpan.innerHTML = aiName;}else if (role === 'system') {nameSpan.innerHTML = sysName;}else {nameSpan.innerHTML = userName;}var textSpan = document.createElement('span');textSpan.classList.add('mwai-text');textSpan.innerHTML = text;div.appendChild(nameSpan);div.appendChild(textSpan);// Copy Buttonif (copyButton && role === 'assistant') {var button = document.createElement('div');button.classList.add('mwai-copy-button');var firstElement = document.createElement('div');firstElement.classList.add('mwai-copy-button-one');var secondElement = document.createElement('div');secondElement.classList.add('mwai-copy-button-two');button.appendChild(firstElement);button.appendChild(secondElement);div.appendChild(button);button.addEventListener('click', function () {try {var content = textSpan.textContent;navigator.clipboard.writeText(content);button.classList.add('mwai-animate');setTimeout(function () {button.classList.remove('mwai-animate');}, 1000);}catch (err) {console.warn('Not allowed to copy to clipboard. Make sure your website uses HTTPS.');}});}conversation.appendChild(div);if (typewriter) {if (role === 'assistant' && text !== startSentence && !replay) {let typewriter = new Typewriter(textSpan, {deleteSpeed: 50, delay: 25, loop: false, cursor: '', autoStart: true,wrapperClassName: 'mwai-typewriter',});typewriter.typeString(text).start().callFunction((state) => {state.elements.cursor.setAttribute('hidden', 'hidden');typewriter.stop();});}}conversation.scrollTop = conversation.scrollHeight;setButtonText();// Syntax coloringif (typeof hljs !== 'undefined') {document.querySelectorAll('pre code').forEach((el) => {hljs.highlightElement(el);});}}function buildPrompt(last = 15) {let prompt = context ? (context + '\n\n') : '';memorizedChat = memorizedChat.slice(-last);// Casually fine tuned, let's use the last questionif (isCasuallyFineTuned) {let lastLine = memorizedChat[memorizedChat.length - 1];prompt = lastLine.content + promptEnding;return prompt;}// Otherwise let's compile the latest conversationlet conversation = memorizedChat.map(x => x.who + x.content);prompt += conversation.join('\n');prompt += '\n' + rawAiName;return prompt;}// Function to request the completionfunction onSendClick() {let input = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-input textarea');let inputText = input.value.trim();// Reset the conversation if emptyif (inputText === '') {document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-conversation').innerHTML = '';localStorage.removeItem('mwai-chat-668e7a38a91d7');memorizedChat = [];memorizedChat.push({ role: 'assistant', content: startSentence, who: rawAiName, html: startSentence });addReply(startSentence, 'assistant');return;}// Disable the buttonvar button = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-input button');button.disabled = true;// Add the user replymemorizedChat.push({ role: 'user', content: inputText, who: rawUserName, html: inputText });addReply(inputText, 'user');input.value = '';input.setAttribute('rows', 1);input.disabled = true;let prompt = buildPrompt(maxSentences);const data = mode === 'images' ? {env, session: session,prompt: inputText, rawInput: inputText,model: model, maxResults, apiKey: apiKey,} : {env, session: session,prompt: prompt, context: context,messages: memorizedChat, rawInput: inputText,userName: userName, aiName: aiName,model: model, temperature: temperature, maxTokens: maxTokens, maxResults: 1, apiKey: apiKey,embeddingsIndex: embeddingsIndex, stop: stop,};// Start the timerconst stopTimer = injectTimer(button);// Send the requestif (isDebugMode) {console.log('[BOT] Sent: ', data);}fetch(apiURL, { method: 'POST', headers: {'Content-Type': 'application/json','X-WP-Nonce': restNonce,},body: JSON.stringify(data)}).then(response => response.json()).then(data => {if (isDebugMode) {console.log('[BOT] Recv: ', data);}if (!data.success) {addReply(data.message, 'system');}else {let html = data.images ? data.images : data.html;memorizedChat.push({ role: 'assistant', content: data.answer, who: rawAiName, html: html });addReply(html, 'assistant');}button.disabled = false;input.disabled = false;stopTimer();// Only focus only on desktop (to avoid the mobile keyboard to kick-in)if (!isMobile) {input.focus();}}).catch(error => {console.error(error);button.disabled = false;input.disabled = false;stopTimer();});}// Keep the textarea height in sync with the contentfunction resizeTextArea(ev) {ev.target.style.height = 'auto';ev.target.style.height = ev.target.scrollHeight + 'px';}// Keep the textarea height in sync with the contentfunction delayedResizeTextArea(ev) {window.setTimeout(resizeTextArea, 0, event);}// Init the chatbotfunction initMeowChatbot() {var input = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-input textarea');var button = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-input button');input.addEventListener('keypress', (event) => {let text = event.target.value;if (event.keyCode === 13 && !text.length && !event.shiftKey) {event.preventDefault();return;}if (event.keyCode === 13 && text.length && !event.shiftKey) {onSendClick();}});input.addEventListener('keydown', (event) => {var rows = input.getAttribute('rows');if (event.keyCode === 13 && event.shiftKey) {var lines = input.value.split('\n').length + 1;//mwaiSetTextAreaHeight(input, lines);}});input.addEventListener('keyup', (event) => {var rows = input.getAttribute('rows');var lines = input.value.split('\n').length ;//mwaiSetTextAreaHeight(input, lines);setButtonText();});input.addEventListener('change', resizeTextArea, false);input.addEventListener('cut', delayedResizeTextArea, false);input.addEventListener('paste', delayedResizeTextArea, false);input.addEventListener('drop', delayedResizeTextArea, false);input.addEventListener('keydown', delayedResizeTextArea, false);button.addEventListener('click', (event) => {onSendClick();});// If window, add event listener to mwai-open-button and mwai-close-buttonif ( isWindow ) {var openButton = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-open-button');openButton.addEventListener('click', (event) => {var chat = document.querySelector('#mwai-chat-668e7a38a91d7');chat.classList.add('mwai-open');// Only focus only on desktop (to avoid the mobile keyboard to kick-in)if (!isMobile) {input.focus();}});var closeButton = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-close-button');closeButton.addEventListener('click', (event) => {var chat = document.querySelector('#mwai-chat-668e7a38a91d7');chat.classList.remove('mwai-open');});if (isFullscreen) {var resizeButton = document.querySelector('#mwai-chat-668e7a38a91d7 .mwai-resize-button');resizeButton.addEventListener('click', (event) => {var chat = document.querySelector('#mwai-chat-668e7a38a91d7');chat.classList.toggle('mwai-fullscreen');});}}// Get back the previous chat if any for the same IDvar chatHistory = [];if (memorizeChat) {chatHistory = localStorage.getItem('mwai-chat-668e7a38a91d7');if (chatHistory) {memorizedChat = JSON.parse(chatHistory);memorizedChat = memorizedChat.filter(x => x && x.html && x.role);memorizedChat.forEach(x => {addReply(x.html, x.role, true);});}else {memorizedChat = [];}}if (memorizedChat.length === 0) {memorizedChat.push({ role: 'assistant', content: startSentence, who: rawAiName, html: startSentence });addReply(startSentence, 'assistant');}}// Let's go totally meoooow on this!initMeowChatbot();})();

141582-ACCENTCARE HOSPICE & PALLIATIVE CARE OF ILLINOIS – Hospice Report (2024)
Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 5995

Rating: 4 / 5 (71 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.