llmasaservice-ui 0.7.16 → 0.7.18

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.d.mts CHANGED
@@ -60,6 +60,12 @@ interface ChatPanelProps {
60
60
  callToActionMustSendEmail?: boolean;
61
61
  ragQueryLimit?: number;
62
62
  ragRankLimit?: number;
63
+ initialHistory?: {
64
+ [prompt: string]: {
65
+ content: string;
66
+ callId: string;
67
+ };
68
+ };
63
69
  }
64
70
  interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
65
71
  inline?: boolean;
@@ -105,6 +111,12 @@ interface AgentPanelProps {
105
111
  showPoweredBy?: boolean;
106
112
  agent: string;
107
113
  conversation?: string | null;
114
+ initialHistory?: {
115
+ [key: string]: {
116
+ content: string;
117
+ callId: string;
118
+ };
119
+ };
108
120
  }
109
121
  interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
110
122
  inline?: boolean;
package/dist/index.d.ts CHANGED
@@ -60,6 +60,12 @@ interface ChatPanelProps {
60
60
  callToActionMustSendEmail?: boolean;
61
61
  ragQueryLimit?: number;
62
62
  ragRankLimit?: number;
63
+ initialHistory?: {
64
+ [prompt: string]: {
65
+ content: string;
66
+ callId: string;
67
+ };
68
+ };
63
69
  }
64
70
  interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
65
71
  inline?: boolean;
@@ -105,6 +111,12 @@ interface AgentPanelProps {
105
111
  showPoweredBy?: boolean;
106
112
  agent: string;
107
113
  conversation?: string | null;
114
+ initialHistory?: {
115
+ [key: string]: {
116
+ content: string;
117
+ callId: string;
118
+ };
119
+ };
108
120
  }
109
121
  interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
110
122
  inline?: boolean;
package/dist/index.js CHANGED
@@ -202,7 +202,8 @@ var ChatPanel = ({
202
202
  callToActionEmailSubject = "Agent CTA submitted",
203
203
  callToActionMustSendEmail = false,
204
204
  ragQueryLimit = 10,
205
- ragRankLimit = 5
205
+ ragRankLimit = 5,
206
+ initialHistory = {}
206
207
  }) => {
207
208
  const { send, response, idle, stop, lastCallId } = (0, import_llmasaservice_client.useLLM)({
208
209
  project_id,
@@ -214,7 +215,7 @@ var ChatPanel = ({
214
215
  });
215
216
  const [nextPrompt, setNextPrompt] = (0, import_react3.useState)("");
216
217
  const [lastController, setLastController] = (0, import_react3.useState)(new AbortController());
217
- const [history, setHistory] = (0, import_react3.useState)({});
218
+ const [history, setHistory] = (0, import_react3.useState)(initialHistory);
218
219
  const [isLoading, setIsLoading] = (0, import_react3.useState)(false);
219
220
  const [lastPrompt, setLastPrompt] = (0, import_react3.useState)(null);
220
221
  const [lastKey, setLastKey] = (0, import_react3.useState)(null);
@@ -235,6 +236,9 @@ var ChatPanel = ({
235
236
  responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
236
237
  }
237
238
  }, [idle]);
239
+ (0, import_react3.useEffect)(() => {
240
+ setHistory(initialHistory);
241
+ }, [initialHistory]);
238
242
  (0, import_react3.useEffect)(() => {
239
243
  const handleBeforeUnload = (event) => {
240
244
  if (callToActionMustSendEmail && showCallToAction && callToActionEmailAddress && callToActionEmailAddress !== "" && !hasSentCallToActionEmail) {
@@ -1132,7 +1136,7 @@ var AgentPanel = ({
1132
1136
  //followOnPrompt = "",
1133
1137
  showPoweredBy = true,
1134
1138
  agent,
1135
- conversation = null
1139
+ conversation = null,
1136
1140
  //showCallToAction = false,
1137
1141
  //callToActionButtonText = "Submit",
1138
1142
  //callToActionEmailAddress = "",
@@ -1140,6 +1144,7 @@ var AgentPanel = ({
1140
1144
  //callToActionMustSendEmail = false,
1141
1145
  //ragQueryLimit = 10,
1142
1146
  //ragRankLimit = 5,
1147
+ initialHistory = {}
1143
1148
  }) => {
1144
1149
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1145
1150
  const [followOnPrompt, setFollowOnPrompt] = (0, import_react4.useState)("");
@@ -1151,7 +1156,7 @@ var AgentPanel = ({
1151
1156
  const fetchAgentData = () => __async(void 0, null, function* () {
1152
1157
  try {
1153
1158
  const response = yield fetch(
1154
- url.endsWith("dev") ? `https://duzyq4e8ql.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}` : `https://api.llmasaservice.io/agents/${agent}`,
1159
+ url.endsWith("dev") ? `https://8ftw8droff.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}` : `https://api.llmasaservice.io/agents/${agent}`,
1155
1160
  {
1156
1161
  method: "GET",
1157
1162
  headers: {
@@ -1229,7 +1234,8 @@ var AgentPanel = ({
1229
1234
  ragRankLimit: (_u = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _u : 5,
1230
1235
  showPoweredBy,
1231
1236
  messages,
1232
- conversation
1237
+ conversation,
1238
+ initialHistory
1233
1239
  }
1234
1240
  ));
1235
1241
  };
package/dist/index.mjs CHANGED
@@ -168,7 +168,8 @@ var ChatPanel = ({
168
168
  callToActionEmailSubject = "Agent CTA submitted",
169
169
  callToActionMustSendEmail = false,
170
170
  ragQueryLimit = 10,
171
- ragRankLimit = 5
171
+ ragRankLimit = 5,
172
+ initialHistory = {}
172
173
  }) => {
173
174
  const { send, response, idle, stop, lastCallId } = useLLM({
174
175
  project_id,
@@ -180,7 +181,7 @@ var ChatPanel = ({
180
181
  });
181
182
  const [nextPrompt, setNextPrompt] = useState3("");
182
183
  const [lastController, setLastController] = useState3(new AbortController());
183
- const [history, setHistory] = useState3({});
184
+ const [history, setHistory] = useState3(initialHistory);
184
185
  const [isLoading, setIsLoading] = useState3(false);
185
186
  const [lastPrompt, setLastPrompt] = useState3(null);
186
187
  const [lastKey, setLastKey] = useState3(null);
@@ -201,6 +202,9 @@ var ChatPanel = ({
201
202
  responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
202
203
  }
203
204
  }, [idle]);
205
+ useEffect(() => {
206
+ setHistory(initialHistory);
207
+ }, [initialHistory]);
204
208
  useEffect(() => {
205
209
  const handleBeforeUnload = (event) => {
206
210
  if (callToActionMustSendEmail && showCallToAction && callToActionEmailAddress && callToActionEmailAddress !== "" && !hasSentCallToActionEmail) {
@@ -1098,7 +1102,7 @@ var AgentPanel = ({
1098
1102
  //followOnPrompt = "",
1099
1103
  showPoweredBy = true,
1100
1104
  agent,
1101
- conversation = null
1105
+ conversation = null,
1102
1106
  //showCallToAction = false,
1103
1107
  //callToActionButtonText = "Submit",
1104
1108
  //callToActionEmailAddress = "",
@@ -1106,6 +1110,7 @@ var AgentPanel = ({
1106
1110
  //callToActionMustSendEmail = false,
1107
1111
  //ragQueryLimit = 10,
1108
1112
  //ragRankLimit = 5,
1113
+ initialHistory = {}
1109
1114
  }) => {
1110
1115
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1111
1116
  const [followOnPrompt, setFollowOnPrompt] = useState4("");
@@ -1117,7 +1122,7 @@ var AgentPanel = ({
1117
1122
  const fetchAgentData = () => __async(void 0, null, function* () {
1118
1123
  try {
1119
1124
  const response = yield fetch(
1120
- url.endsWith("dev") ? `https://duzyq4e8ql.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}` : `https://api.llmasaservice.io/agents/${agent}`,
1125
+ url.endsWith("dev") ? `https://8ftw8droff.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}` : `https://api.llmasaservice.io/agents/${agent}`,
1121
1126
  {
1122
1127
  method: "GET",
1123
1128
  headers: {
@@ -1195,7 +1200,8 @@ var AgentPanel = ({
1195
1200
  ragRankLimit: (_u = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _u : 5,
1196
1201
  showPoweredBy,
1197
1202
  messages,
1198
- conversation
1203
+ conversation,
1204
+ initialHistory
1199
1205
  }
1200
1206
  ));
1201
1207
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.7.16",
3
+ "version": "0.7.18",
4
4
  "description": "Prebuilt UI components for LLMAsAService.io",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -57,6 +57,7 @@ export interface AgentPanelProps {
57
57
  //callToActionMustSendEmail?: boolean;
58
58
  //ragQueryLimit?: number;
59
59
  //ragRankLimit?: number;
60
+ initialHistory?: { [key: string]: { content: string; callId: string } };
60
61
  }
61
62
  interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
62
63
  inline?: boolean;
@@ -101,6 +102,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
101
102
  //callToActionMustSendEmail = false,
102
103
  //ragQueryLimit = 10,
103
104
  //ragRankLimit = 5,
105
+ initialHistory = {}
104
106
  }) => {
105
107
  const [followOnPrompt, setFollowOnPrompt] = useState<string>("");
106
108
 
@@ -115,7 +117,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
115
117
  try {
116
118
  const response = await fetch(
117
119
  url.endsWith("dev")
118
- ? `https://duzyq4e8ql.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}`
120
+ ? `https://8ftw8droff.execute-api.us-east-1.amazonaws.com/dev/agents/${agent}`
119
121
  : `https://api.llmasaservice.io/agents/${agent}`,
120
122
  {
121
123
  method: "GET",
@@ -236,6 +238,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
236
238
  showPoweredBy={showPoweredBy}
237
239
  messages={messages}
238
240
  conversation={conversation}
241
+ initialHistory={initialHistory}
239
242
  />
240
243
  )}
241
244
  </>
package/src/ChatPanel.tsx CHANGED
@@ -37,7 +37,11 @@ export interface ChatPanelProps {
37
37
  historyChangedCallback?: (history: {
38
38
  [key: string]: { content: string; callId: string };
39
39
  }) => void;
40
- responseCompleteCallback?: (callId: string, prompt: string, response: string) => void;
40
+ responseCompleteCallback?: (
41
+ callId: string,
42
+ prompt: string,
43
+ response: string
44
+ ) => void;
41
45
  promptTemplate?: string;
42
46
  actions?: {
43
47
  pattern: string;
@@ -62,6 +66,9 @@ export interface ChatPanelProps {
62
66
  callToActionMustSendEmail?: boolean;
63
67
  ragQueryLimit?: number;
64
68
  ragRankLimit?: number;
69
+ initialHistory?: {
70
+ [prompt: string]: { content: string; callId: string };
71
+ };
65
72
  }
66
73
 
67
74
  interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
@@ -108,6 +115,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
108
115
  callToActionMustSendEmail = false,
109
116
  ragQueryLimit = 10,
110
117
  ragRankLimit = 5,
118
+ initialHistory = {},
111
119
  }) => {
112
120
  const { send, response, idle, stop, lastCallId } = useLLM({
113
121
  project_id: project_id,
@@ -122,7 +130,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
122
130
  const [lastController, setLastController] = useState(new AbortController());
123
131
  const [history, setHistory] = useState<{
124
132
  [prompt: string]: { content: string; callId: string };
125
- }>({});
133
+ }>(initialHistory);
126
134
  const [isLoading, setIsLoading] = useState(false);
127
135
  const [lastPrompt, setLastPrompt] = useState<string | null>(null);
128
136
  const [lastKey, setLastKey] = useState<string | null>(null);
@@ -148,6 +156,12 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
148
156
  }
149
157
  }, [idle]);
150
158
 
159
+ useEffect(() => {
160
+ //if (Object.keys(initialHistory).length > 0) {
161
+ setHistory(initialHistory);
162
+ //}
163
+ }, [initialHistory]);
164
+
151
165
  useEffect(() => {
152
166
  const handleBeforeUnload = (event: BeforeUnloadEvent) => {
153
167
  if (
@@ -197,7 +211,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
197
211
  const matchIndex = groups[groups.length - 2]; // The second-to-last argument is the match index
198
212
  const buttonId = `button-${messages.length}-${index}-${matchIndex}`; // a unique button for the conversation level, action index, match index
199
213
 
200
- let html = match;
214
+ let html = match;
201
215
  if (action.type === "button" || action.type === "callback") {
202
216
  html = ` <button id="${buttonId}" ${
203
217
  action.style ? 'class=" ' + action.style + '"' : ""
@@ -729,7 +743,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
729
743
  style={{ width: width, height: height }}
730
744
  className={"side-panel" + (theme === "light" ? "" : "-dark")}
731
745
  >
732
- {title && title !== "" ? <div className="title">{title}</div> : null}
746
+ {title && title !== "" ? <div className="title">{title}</div> : null}
733
747
  <div className="responseArea" ref={responseAreaRef}>
734
748
  {initialMessage && initialMessage !== "" ? (
735
749
  <div className="history-entry">