llmasaservice-ui 0.7.8 → 0.7.9

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/dist/index.js CHANGED
@@ -1143,13 +1143,14 @@ var AgentPanel = ({
1143
1143
  );
1144
1144
  const data2 = yield response.json();
1145
1145
  if (data2 && data2.length > 0) {
1146
- setAgentData(data2[0]);
1147
- if (data2 && data2.cssUrl && data2.cssUrl !== "") {
1146
+ if (data2 && data2[0].cssUrl && data2[0].cssUrl !== "") {
1148
1147
  const link = document.createElement("link");
1149
1148
  link.rel = "stylesheet";
1150
- link.href = data2.cssUrl;
1149
+ link.href = data2[0].cssUrl;
1151
1150
  document.head.appendChild(link);
1151
+ console.log("Added css link", link);
1152
1152
  }
1153
+ setAgentData(data2[0]);
1153
1154
  }
1154
1155
  } catch (error) {
1155
1156
  console.error("Error fetching agent data:", error);
@@ -1173,7 +1174,7 @@ var AgentPanel = ({
1173
1174
  }
1174
1175
  return actions2;
1175
1176
  };
1176
- return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, /* @__PURE__ */ import_react4.default.createElement(
1177
+ return /* @__PURE__ */ import_react4.default.createElement(import_react4.default.Fragment, null, agentData && /* @__PURE__ */ import_react4.default.createElement(
1177
1178
  ChatPanel_default,
1178
1179
  {
1179
1180
  project_id: agentData == null ? void 0 : agentData.projectId,
package/dist/index.mjs CHANGED
@@ -1109,13 +1109,14 @@ var AgentPanel = ({
1109
1109
  );
1110
1110
  const data2 = yield response.json();
1111
1111
  if (data2 && data2.length > 0) {
1112
- setAgentData(data2[0]);
1113
- if (data2 && data2.cssUrl && data2.cssUrl !== "") {
1112
+ if (data2 && data2[0].cssUrl && data2[0].cssUrl !== "") {
1114
1113
  const link = document.createElement("link");
1115
1114
  link.rel = "stylesheet";
1116
- link.href = data2.cssUrl;
1115
+ link.href = data2[0].cssUrl;
1117
1116
  document.head.appendChild(link);
1117
+ console.log("Added css link", link);
1118
1118
  }
1119
+ setAgentData(data2[0]);
1119
1120
  }
1120
1121
  } catch (error) {
1121
1122
  console.error("Error fetching agent data:", error);
@@ -1139,7 +1140,7 @@ var AgentPanel = ({
1139
1140
  }
1140
1141
  return actions2;
1141
1142
  };
1142
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(
1143
+ return /* @__PURE__ */ React4.createElement(React4.Fragment, null, agentData && /* @__PURE__ */ React4.createElement(
1143
1144
  ChatPanel_default,
1144
1145
  {
1145
1146
  project_id: agentData == null ? void 0 : agentData.projectId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.7.8",
3
+ "version": "0.7.9",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -1,9 +1,6 @@
1
1
  import React, { useEffect, useState } from "react";
2
-
3
2
  import materialDark from "react-syntax-highlighter/dist/esm/styles/prism/material-dark.js";
4
-
5
3
  import materialLight from "react-syntax-highlighter/dist/esm/styles/prism/material-light.js";
6
-
7
4
  import ChatPanel from "./ChatPanel";
8
5
  import { LLMAsAServiceCustomer } from "llmasaservice-client";
9
6
  import PrismStyle from "react-syntax-highlighter";
@@ -119,17 +116,19 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
119
116
  },
120
117
  }
121
118
  );
119
+
122
120
  const data = await response.json();
123
121
  if (data && data.length > 0) {
124
122
  //console.log("data", data);
125
- setAgentData(data[0]);
126
-
127
- if (data && data.cssUrl && data.cssUrl !== "") {
123
+ if (data && data[0].cssUrl && data[0].cssUrl !== "") {
128
124
  const link = document.createElement("link");
129
125
  link.rel = "stylesheet";
130
- link.href = data.cssUrl; // "https://dev.llmasaservice.io/themes/simple.css";
126
+ link.href = data[0].cssUrl; // "https://dev.llmasaservice.io/themes/simple.css";
131
127
  document.head.appendChild(link);
128
+ console.log("Added css link", link);
132
129
  }
130
+
131
+ setAgentData(data[0]);
133
132
  }
134
133
  } catch (error) {
135
134
  console.error("Error fetching agent data:", error);
@@ -162,73 +161,75 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
162
161
 
163
162
  return (
164
163
  <>
165
- <ChatPanel
166
- project_id={agentData?.projectId}
167
- service={agentData?.groupId || null}
168
- url={url}
169
- title={agentData?.displayTitle ?? ""}
170
- theme={agentData?.displayTheme === "light" ? "light" : "dark"}
171
- height={agentData?.displayHeight ?? "75vh"}
172
- width={agentData?.displayWidth ?? "100%"}
173
- promptTemplate={agentData?.displayPromptTemplate ?? "{{prompt}}"}
174
- initialMessage={
175
- agentData?.displayStartMessageOrPrompt === "message"
176
- ? agentData?.displayInitialMessageOrPrompt ?? ""
177
- : undefined
178
- }
179
- initialPrompt={
180
- agentData?.displayStartMessageOrPrompt === "prompt"
181
- ? agentData?.displayInitialMessageOrPrompt ?? ""
182
- : undefined
183
- }
184
- followOnQuestions={
185
- followOnQuestions
186
- ? followOnQuestions
187
- : agentData?.displayFollowOnPrompts?.split("|") ?? []
188
- }
189
- clearFollowOnQuestionsNextPrompt={clearFollowOnQuestionsNextPrompt}
190
- historyChangedCallback={(history) => {
191
- if (history) {
192
- setFollowOnPrompt("");
164
+ {agentData && (
165
+ <ChatPanel
166
+ project_id={agentData?.projectId}
167
+ service={agentData?.groupId || null}
168
+ url={url}
169
+ title={agentData?.displayTitle ?? ""}
170
+ theme={agentData?.displayTheme === "light" ? "light" : "dark"}
171
+ height={agentData?.displayHeight ?? "75vh"}
172
+ width={agentData?.displayWidth ?? "100%"}
173
+ promptTemplate={agentData?.displayPromptTemplate ?? "{{prompt}}"}
174
+ initialMessage={
175
+ agentData?.displayStartMessageOrPrompt === "message"
176
+ ? agentData?.displayInitialMessageOrPrompt ?? ""
177
+ : undefined
193
178
  }
194
- }}
195
- prismStyle={
196
- (agentData?.displayTheme === "light"
197
- ? materialLight
198
- : materialDark) as any
199
- }
200
- actions={[
201
- ...actions,
202
- ...getActionsArraySafely(agentData?.displayActions),
203
- ]}
204
- followOnPrompt={followOnPrompt}
205
- agent={agent}
206
- placeholder={agentData?.displayPlaceholder ?? "Type a message"}
207
- hideInitialPrompt={agentData?.displayHideInitialPrompt ?? true}
208
- data={[...data, { key: "data", data: agentData?.data }]}
209
- showEmailButton={agentData?.displayShowEmailButton ?? true}
210
- showSaveButton={agentData?.displayShowSaveButton ?? true}
211
- showCallToAction={agentData?.displayShowCallToAction ?? false}
212
- callToActionButtonText={
213
- agentData?.displayCallToActionButtonText ?? "Submit"
214
- }
215
- callToActionEmailAddress={
216
- agentData?.displayCallToActionEmailAddress ?? ""
217
- }
218
- callToActionEmailSubject={
219
- agentData?.displayCallToActionEmailSubject ?? "Agent CTA Submitted"
220
- }
221
- callToActionMustSendEmail={
222
- agentData?.displayCallToActionMustSendEmail ?? false
223
- }
224
- customer={{
225
- customer_id: customer_id ?? "default",
226
- customer_user_email: customer_email ?? "",
227
- }}
228
- scrollToEnd={agentData?.displayScrollToEnd ?? false}
229
- ragQueryLimit={agentData?.ragQueryLimit ?? 10}
230
- ragRankLimit={agentData?.ragRankLimit ?? 5}
231
- />
179
+ initialPrompt={
180
+ agentData?.displayStartMessageOrPrompt === "prompt"
181
+ ? agentData?.displayInitialMessageOrPrompt ?? ""
182
+ : undefined
183
+ }
184
+ followOnQuestions={
185
+ followOnQuestions
186
+ ? followOnQuestions
187
+ : agentData?.displayFollowOnPrompts?.split("|") ?? []
188
+ }
189
+ clearFollowOnQuestionsNextPrompt={clearFollowOnQuestionsNextPrompt}
190
+ historyChangedCallback={(history) => {
191
+ if (history) {
192
+ setFollowOnPrompt("");
193
+ }
194
+ }}
195
+ prismStyle={
196
+ (agentData?.displayTheme === "light"
197
+ ? materialLight
198
+ : materialDark) as any
199
+ }
200
+ actions={[
201
+ ...actions,
202
+ ...getActionsArraySafely(agentData?.displayActions),
203
+ ]}
204
+ followOnPrompt={followOnPrompt}
205
+ agent={agent}
206
+ placeholder={agentData?.displayPlaceholder ?? "Type a message"}
207
+ hideInitialPrompt={agentData?.displayHideInitialPrompt ?? true}
208
+ data={[...data, { key: "data", data: agentData?.data }]}
209
+ showEmailButton={agentData?.displayShowEmailButton ?? true}
210
+ showSaveButton={agentData?.displayShowSaveButton ?? true}
211
+ showCallToAction={agentData?.displayShowCallToAction ?? false}
212
+ callToActionButtonText={
213
+ agentData?.displayCallToActionButtonText ?? "Submit"
214
+ }
215
+ callToActionEmailAddress={
216
+ agentData?.displayCallToActionEmailAddress ?? ""
217
+ }
218
+ callToActionEmailSubject={
219
+ agentData?.displayCallToActionEmailSubject ?? "Agent CTA Submitted"
220
+ }
221
+ callToActionMustSendEmail={
222
+ agentData?.displayCallToActionMustSendEmail ?? false
223
+ }
224
+ customer={{
225
+ customer_id: customer_id ?? "default",
226
+ customer_user_email: customer_email ?? "",
227
+ }}
228
+ scrollToEnd={agentData?.displayScrollToEnd ?? false}
229
+ ragQueryLimit={agentData?.ragQueryLimit ?? 10}
230
+ ragRankLimit={agentData?.ragRankLimit ?? 5}
231
+ />
232
+ )}
232
233
  </>
233
234
  );
234
235
  };
package/src/ChatPanel.tsx CHANGED
@@ -8,12 +8,8 @@ import "./ChatPanel.css";
8
8
  import remarkGfm from "remark-gfm";
9
9
  import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
10
10
  import PrismStyle from "react-syntax-highlighter";
11
-
12
11
  import materialDark from "react-syntax-highlighter/dist/esm/styles/prism/material-dark.js";
13
12
  import materialLight from "react-syntax-highlighter/dist/esm/styles/prism/material-light.js";
14
-
15
- //import materialDark from "react-syntax-highlighter/dist/cjs/styles/prism/material-dark.js";
16
- //import materialLight from "react-syntax-highlighter/dist/cjs/styles/prism/material-light.js";
17
13
  import EmailModal from "./EmailModal";
18
14
  import CallToActionlModal from "./CallToActionModal";
19
15