llmasaservice-ui 0.7.17 → 0.7.19

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,10 @@ var ChatPanel = ({
235
236
  responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
236
237
  }
237
238
  }, [idle]);
239
+ (0, import_react3.useEffect)(() => {
240
+ console.log("initialHistory", initialHistory);
241
+ setHistory(initialHistory);
242
+ }, [initialHistory]);
238
243
  (0, import_react3.useEffect)(() => {
239
244
  const handleBeforeUnload = (event) => {
240
245
  if (callToActionMustSendEmail && showCallToAction && callToActionEmailAddress && callToActionEmailAddress !== "" && !hasSentCallToActionEmail) {
@@ -1132,7 +1137,7 @@ var AgentPanel = ({
1132
1137
  //followOnPrompt = "",
1133
1138
  showPoweredBy = true,
1134
1139
  agent,
1135
- conversation = null
1140
+ conversation = null,
1136
1141
  //showCallToAction = false,
1137
1142
  //callToActionButtonText = "Submit",
1138
1143
  //callToActionEmailAddress = "",
@@ -1140,6 +1145,7 @@ var AgentPanel = ({
1140
1145
  //callToActionMustSendEmail = false,
1141
1146
  //ragQueryLimit = 10,
1142
1147
  //ragRankLimit = 5,
1148
+ initialHistory = {}
1143
1149
  }) => {
1144
1150
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1145
1151
  const [followOnPrompt, setFollowOnPrompt] = (0, import_react4.useState)("");
@@ -1229,7 +1235,8 @@ var AgentPanel = ({
1229
1235
  ragRankLimit: (_u = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _u : 5,
1230
1236
  showPoweredBy,
1231
1237
  messages,
1232
- conversation
1238
+ conversation,
1239
+ initialHistory
1233
1240
  }
1234
1241
  ));
1235
1242
  };
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,10 @@ var ChatPanel = ({
201
202
  responseCompleteCallback(lastCallId, lastPrompt != null ? lastPrompt : "", response);
202
203
  }
203
204
  }, [idle]);
205
+ useEffect(() => {
206
+ console.log("initialHistory", initialHistory);
207
+ setHistory(initialHistory);
208
+ }, [initialHistory]);
204
209
  useEffect(() => {
205
210
  const handleBeforeUnload = (event) => {
206
211
  if (callToActionMustSendEmail && showCallToAction && callToActionEmailAddress && callToActionEmailAddress !== "" && !hasSentCallToActionEmail) {
@@ -1098,7 +1103,7 @@ var AgentPanel = ({
1098
1103
  //followOnPrompt = "",
1099
1104
  showPoweredBy = true,
1100
1105
  agent,
1101
- conversation = null
1106
+ conversation = null,
1102
1107
  //showCallToAction = false,
1103
1108
  //callToActionButtonText = "Submit",
1104
1109
  //callToActionEmailAddress = "",
@@ -1106,6 +1111,7 @@ var AgentPanel = ({
1106
1111
  //callToActionMustSendEmail = false,
1107
1112
  //ragQueryLimit = 10,
1108
1113
  //ragRankLimit = 5,
1114
+ initialHistory = {}
1109
1115
  }) => {
1110
1116
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
1111
1117
  const [followOnPrompt, setFollowOnPrompt] = useState4("");
@@ -1195,7 +1201,8 @@ var AgentPanel = ({
1195
1201
  ragRankLimit: (_u = agentData == null ? void 0 : agentData.ragRankLimit) != null ? _u : 5,
1196
1202
  showPoweredBy,
1197
1203
  messages,
1198
- conversation
1204
+ conversation,
1205
+ initialHistory
1199
1206
  }
1200
1207
  ));
1201
1208
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llmasaservice-ui",
3
- "version": "0.7.17",
3
+ "version": "0.7.19",
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
 
@@ -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,13 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
148
156
  }
149
157
  }, [idle]);
150
158
 
159
+ useEffect(() => {
160
+ console.log("initialHistory", initialHistory);
161
+ //if (Object.keys(initialHistory).length > 0) {
162
+ setHistory(initialHistory);
163
+ //}
164
+ }, [initialHistory]);
165
+
151
166
  useEffect(() => {
152
167
  const handleBeforeUnload = (event: BeforeUnloadEvent) => {
153
168
  if (
@@ -197,7 +212,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
197
212
  const matchIndex = groups[groups.length - 2]; // The second-to-last argument is the match index
198
213
  const buttonId = `button-${messages.length}-${index}-${matchIndex}`; // a unique button for the conversation level, action index, match index
199
214
 
200
- let html = match;
215
+ let html = match;
201
216
  if (action.type === "button" || action.type === "callback") {
202
217
  html = ` <button id="${buttonId}" ${
203
218
  action.style ? 'class=" ' + action.style + '"' : ""
@@ -729,7 +744,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
729
744
  style={{ width: width, height: height }}
730
745
  className={"side-panel" + (theme === "light" ? "" : "-dark")}
731
746
  >
732
- {title && title !== "" ? <div className="title">{title}</div> : null}
747
+ {title && title !== "" ? <div className="title">{title}</div> : null}
733
748
  <div className="responseArea" ref={responseAreaRef}>
734
749
  {initialMessage && initialMessage !== "" ? (
735
750
  <div className="history-entry">