@smarter.sh/ui-chat 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smarter.sh/ui-chat",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "chatbot React.js component for the https://smarter.sh no-code, plugin based AI platform",
5
5
  "homepage": "https://smarter.sh",
6
6
  "main": "dist/smarter-chat-library.umd.js",
@@ -36,8 +36,8 @@ import "./styles.css";
36
36
  import { ContainerLayout, ContentLayout, WorkbenchLayout, ChatAppLayout, ConsoleLayout } from "./Layout.js";
37
37
  import { MessageDirectionEnum, SenderRoleEnum } from "./enums.js";
38
38
  import { fetchConfig, fetchPrompt } from "./api.js";
39
- import { setCookie } from "../shared/cookie.js"
40
- import { cookieMetaFactory, messageFactory, chatMessages2RequestMessages, chatInit } from "./utils.jsx";
39
+ import { setCookie, cookieMetaFactory } from "../shared/cookie.js"
40
+ import { messageFactory, chatMessages2RequestMessages, chatInit } from "./utils.jsx";
41
41
  import { ErrorBoundary } from "./ErrorBoundary.jsx";
42
42
 
43
43
  // The main chat component. This is the top-level component that
@@ -27,7 +27,7 @@ import { getCookie, setCookie } from "../shared/cookie";
27
27
  // Set to true to enable local development mode,
28
28
  // which will simulate the server-side API calls.
29
29
  const developerMode = false;
30
- const debugMode = getCookie(cookies.debugCookie) === "true" || developerMode;
30
+ let debugMode = developerMode;
31
31
  const userAgent = "SmarterChat/1.0";
32
32
  const applicationJson = "application/json";
33
33
 
@@ -138,6 +138,8 @@ async function getJsonResponse(url, init, cookies) {
138
138
  }
139
139
 
140
140
  export async function fetchPrompt(config, messages, cookies) {
141
+ debugMode = config.debug_mode || developerMode;
142
+
141
143
  if (debugMode) {
142
144
  console.log("fetchPrompt(): config", config);
143
145
  }
@@ -193,6 +195,7 @@ export async function fetchConfig(apiUrl, cookies) {
193
195
  if (newConfig) {
194
196
  setCookie(cookies.sessionCookie, newConfig.session_key);
195
197
  setCookie(cookies.debugCookie, newConfig.debug_mode);
198
+ debugMode = newConfig.debug_mode || developerMode;
196
199
  return newConfig;
197
200
  }
198
201
  return null;
@@ -1,16 +1,5 @@
1
1
  import { MessageDirectionEnum, SenderRoleEnum, ValidMessageRolesEnum } from "./enums.js";
2
2
 
3
- export function cookieMetaFactory(cookieName, cookieExpiration, cookieDomain, cookieValue = null) {
4
- /*
5
- Create a cookie object.
6
- */
7
- return {
8
- name: cookieName,
9
- expiration: cookieExpiration,
10
- domain: cookieDomain,
11
- value: cookieValue,
12
- };
13
- }
14
3
 
15
4
  export function chatRestoreFromBackend(chat_history, last_response) {
16
5
  /*
@@ -37,3 +37,15 @@ export function setCookie(cookie, value) {
37
37
  document.cookie = cookieData;
38
38
  }
39
39
  }
40
+
41
+ export function cookieMetaFactory(cookieName, cookieExpiration, cookieDomain, cookieValue = null) {
42
+ /*
43
+ Create a cookie object.
44
+ */
45
+ return {
46
+ name: cookieName,
47
+ expiration: cookieExpiration,
48
+ domain: cookieDomain,
49
+ value: cookieValue,
50
+ };
51
+ }