llmasaservice-ui 0.7.18 → 0.7.20
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -5
- package/dist/index.mjs +25 -5
- package/package.json +1 -1
- package/src/AgentPanel.tsx +4 -1
- package/src/ChatPanel.tsx +26 -2
package/dist/index.d.mts
CHANGED
|
@@ -66,6 +66,7 @@ interface ChatPanelProps {
|
|
|
66
66
|
callId: string;
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
+
hideRagContextInPrompt?: boolean;
|
|
69
70
|
}
|
|
70
71
|
interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
|
|
71
72
|
inline?: boolean;
|
|
@@ -117,6 +118,7 @@ interface AgentPanelProps {
|
|
|
117
118
|
callId: string;
|
|
118
119
|
};
|
|
119
120
|
};
|
|
121
|
+
hideRagContextInPrompt?: boolean;
|
|
120
122
|
}
|
|
121
123
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
122
124
|
inline?: boolean;
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,7 @@ interface ChatPanelProps {
|
|
|
66
66
|
callId: string;
|
|
67
67
|
};
|
|
68
68
|
};
|
|
69
|
+
hideRagContextInPrompt?: boolean;
|
|
69
70
|
}
|
|
70
71
|
interface ExtraProps$1 extends React.HTMLAttributes<HTMLElement> {
|
|
71
72
|
inline?: boolean;
|
|
@@ -117,6 +118,7 @@ interface AgentPanelProps {
|
|
|
117
118
|
callId: string;
|
|
118
119
|
};
|
|
119
120
|
};
|
|
121
|
+
hideRagContextInPrompt?: boolean;
|
|
120
122
|
}
|
|
121
123
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
122
124
|
inline?: boolean;
|
package/dist/index.js
CHANGED
|
@@ -203,7 +203,8 @@ var ChatPanel = ({
|
|
|
203
203
|
callToActionMustSendEmail = false,
|
|
204
204
|
ragQueryLimit = 10,
|
|
205
205
|
ragRankLimit = 5,
|
|
206
|
-
initialHistory = {}
|
|
206
|
+
initialHistory = {},
|
|
207
|
+
hideRagContextInPrompt = true
|
|
207
208
|
}) => {
|
|
208
209
|
const { send, response, idle, stop, lastCallId } = (0, import_llmasaservice_client.useLLM)({
|
|
209
210
|
project_id,
|
|
@@ -237,6 +238,7 @@ var ChatPanel = ({
|
|
|
237
238
|
}
|
|
238
239
|
}, [idle]);
|
|
239
240
|
(0, import_react3.useEffect)(() => {
|
|
241
|
+
console.log("initialHistory", initialHistory);
|
|
240
242
|
setHistory(initialHistory);
|
|
241
243
|
}, [initialHistory]);
|
|
242
244
|
(0, import_react3.useEffect)(() => {
|
|
@@ -613,7 +615,7 @@ var ChatPanel = ({
|
|
|
613
615
|
html += `
|
|
614
616
|
<div class="history-entry">
|
|
615
617
|
<div class="prompt-container">
|
|
616
|
-
<div class="prompt">${convertMarkdownToHTML(prompt)}</div>
|
|
618
|
+
<div class="prompt">${convertMarkdownToHTML(formatPromptForDisplay(prompt))}</div>
|
|
617
619
|
</div>
|
|
618
620
|
<div class="response-container">
|
|
619
621
|
<div class="response">${convertMarkdownToHTML(response2.content)}</div>
|
|
@@ -716,6 +718,22 @@ var ChatPanel = ({
|
|
|
716
718
|
})
|
|
717
719
|
});
|
|
718
720
|
};
|
|
721
|
+
const formatPromptForDisplay = (prompt) => {
|
|
722
|
+
var _a;
|
|
723
|
+
if (!prompt) {
|
|
724
|
+
return "";
|
|
725
|
+
}
|
|
726
|
+
if (hideRagContextInPrompt && prompt.includes("CONTEXT:")) {
|
|
727
|
+
const parts = prompt.split("CONTEXT:");
|
|
728
|
+
const withoutContext = parts.length > 0 ? parts[0] : "";
|
|
729
|
+
if (withoutContext.includes("PROMPT:")) {
|
|
730
|
+
const promptParts = withoutContext.split("PROMPT:");
|
|
731
|
+
return promptParts.length > 1 ? (_a = promptParts[1]) != null ? _a : "".trim() : withoutContext.trim();
|
|
732
|
+
}
|
|
733
|
+
return withoutContext.trim();
|
|
734
|
+
}
|
|
735
|
+
return prompt;
|
|
736
|
+
};
|
|
719
737
|
return /* @__PURE__ */ import_react3.default.createElement(import_react3.default.Fragment, null, /* @__PURE__ */ import_react3.default.createElement(
|
|
720
738
|
"div",
|
|
721
739
|
{
|
|
@@ -731,7 +749,7 @@ var ChatPanel = ({
|
|
|
731
749
|
rehypePlugins: [import_rehype_raw.default]
|
|
732
750
|
},
|
|
733
751
|
initialMessage
|
|
734
|
-
))) : null, Object.entries(history).map(([prompt, response2], index) => /* @__PURE__ */ import_react3.default.createElement("div", { className: "history-entry", key: index }, hideInitialPrompt && index === 0 ? null : /* @__PURE__ */ import_react3.default.createElement("div", { className: "prompt" }, prompt), /* @__PURE__ */ import_react3.default.createElement("div", { className: "response" }, index === Object.keys(history).length - 1 && isLoading ? /* @__PURE__ */ import_react3.default.createElement("div", { className: "loading-text" }, "loading...") : null, /* @__PURE__ */ import_react3.default.createElement(
|
|
752
|
+
))) : null, Object.entries(history).map(([prompt, response2], index) => /* @__PURE__ */ import_react3.default.createElement("div", { className: "history-entry", key: index }, hideInitialPrompt && index === 0 ? null : /* @__PURE__ */ import_react3.default.createElement("div", { className: "prompt" }, formatPromptForDisplay(prompt)), /* @__PURE__ */ import_react3.default.createElement("div", { className: "response" }, index === Object.keys(history).length - 1 && isLoading ? /* @__PURE__ */ import_react3.default.createElement("div", { className: "loading-text" }, "loading...") : null, /* @__PURE__ */ import_react3.default.createElement(
|
|
735
753
|
import_react_markdown.default,
|
|
736
754
|
{
|
|
737
755
|
className: markdownClass,
|
|
@@ -1144,7 +1162,8 @@ var AgentPanel = ({
|
|
|
1144
1162
|
//callToActionMustSendEmail = false,
|
|
1145
1163
|
//ragQueryLimit = 10,
|
|
1146
1164
|
//ragRankLimit = 5,
|
|
1147
|
-
initialHistory = {}
|
|
1165
|
+
initialHistory = {},
|
|
1166
|
+
hideRagContextInPrompt = true
|
|
1148
1167
|
}) => {
|
|
1149
1168
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1150
1169
|
const [followOnPrompt, setFollowOnPrompt] = (0, import_react4.useState)("");
|
|
@@ -1235,7 +1254,8 @@ var AgentPanel = ({
|
|
|
1235
1254
|
showPoweredBy,
|
|
1236
1255
|
messages,
|
|
1237
1256
|
conversation,
|
|
1238
|
-
initialHistory
|
|
1257
|
+
initialHistory,
|
|
1258
|
+
hideRagContextInPrompt
|
|
1239
1259
|
}
|
|
1240
1260
|
));
|
|
1241
1261
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -169,7 +169,8 @@ var ChatPanel = ({
|
|
|
169
169
|
callToActionMustSendEmail = false,
|
|
170
170
|
ragQueryLimit = 10,
|
|
171
171
|
ragRankLimit = 5,
|
|
172
|
-
initialHistory = {}
|
|
172
|
+
initialHistory = {},
|
|
173
|
+
hideRagContextInPrompt = true
|
|
173
174
|
}) => {
|
|
174
175
|
const { send, response, idle, stop, lastCallId } = useLLM({
|
|
175
176
|
project_id,
|
|
@@ -203,6 +204,7 @@ var ChatPanel = ({
|
|
|
203
204
|
}
|
|
204
205
|
}, [idle]);
|
|
205
206
|
useEffect(() => {
|
|
207
|
+
console.log("initialHistory", initialHistory);
|
|
206
208
|
setHistory(initialHistory);
|
|
207
209
|
}, [initialHistory]);
|
|
208
210
|
useEffect(() => {
|
|
@@ -579,7 +581,7 @@ var ChatPanel = ({
|
|
|
579
581
|
html += `
|
|
580
582
|
<div class="history-entry">
|
|
581
583
|
<div class="prompt-container">
|
|
582
|
-
<div class="prompt">${convertMarkdownToHTML(prompt)}</div>
|
|
584
|
+
<div class="prompt">${convertMarkdownToHTML(formatPromptForDisplay(prompt))}</div>
|
|
583
585
|
</div>
|
|
584
586
|
<div class="response-container">
|
|
585
587
|
<div class="response">${convertMarkdownToHTML(response2.content)}</div>
|
|
@@ -682,6 +684,22 @@ var ChatPanel = ({
|
|
|
682
684
|
})
|
|
683
685
|
});
|
|
684
686
|
};
|
|
687
|
+
const formatPromptForDisplay = (prompt) => {
|
|
688
|
+
var _a;
|
|
689
|
+
if (!prompt) {
|
|
690
|
+
return "";
|
|
691
|
+
}
|
|
692
|
+
if (hideRagContextInPrompt && prompt.includes("CONTEXT:")) {
|
|
693
|
+
const parts = prompt.split("CONTEXT:");
|
|
694
|
+
const withoutContext = parts.length > 0 ? parts[0] : "";
|
|
695
|
+
if (withoutContext.includes("PROMPT:")) {
|
|
696
|
+
const promptParts = withoutContext.split("PROMPT:");
|
|
697
|
+
return promptParts.length > 1 ? (_a = promptParts[1]) != null ? _a : "".trim() : withoutContext.trim();
|
|
698
|
+
}
|
|
699
|
+
return withoutContext.trim();
|
|
700
|
+
}
|
|
701
|
+
return prompt;
|
|
702
|
+
};
|
|
685
703
|
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(
|
|
686
704
|
"div",
|
|
687
705
|
{
|
|
@@ -697,7 +715,7 @@ var ChatPanel = ({
|
|
|
697
715
|
rehypePlugins: [rehypeRaw]
|
|
698
716
|
},
|
|
699
717
|
initialMessage
|
|
700
|
-
))) : null, Object.entries(history).map(([prompt, response2], index) => /* @__PURE__ */ React3.createElement("div", { className: "history-entry", key: index }, hideInitialPrompt && index === 0 ? null : /* @__PURE__ */ React3.createElement("div", { className: "prompt" }, prompt), /* @__PURE__ */ React3.createElement("div", { className: "response" }, index === Object.keys(history).length - 1 && isLoading ? /* @__PURE__ */ React3.createElement("div", { className: "loading-text" }, "loading...") : null, /* @__PURE__ */ React3.createElement(
|
|
718
|
+
))) : null, Object.entries(history).map(([prompt, response2], index) => /* @__PURE__ */ React3.createElement("div", { className: "history-entry", key: index }, hideInitialPrompt && index === 0 ? null : /* @__PURE__ */ React3.createElement("div", { className: "prompt" }, formatPromptForDisplay(prompt)), /* @__PURE__ */ React3.createElement("div", { className: "response" }, index === Object.keys(history).length - 1 && isLoading ? /* @__PURE__ */ React3.createElement("div", { className: "loading-text" }, "loading...") : null, /* @__PURE__ */ React3.createElement(
|
|
701
719
|
ReactMarkdown,
|
|
702
720
|
{
|
|
703
721
|
className: markdownClass,
|
|
@@ -1110,7 +1128,8 @@ var AgentPanel = ({
|
|
|
1110
1128
|
//callToActionMustSendEmail = false,
|
|
1111
1129
|
//ragQueryLimit = 10,
|
|
1112
1130
|
//ragRankLimit = 5,
|
|
1113
|
-
initialHistory = {}
|
|
1131
|
+
initialHistory = {},
|
|
1132
|
+
hideRagContextInPrompt = true
|
|
1114
1133
|
}) => {
|
|
1115
1134
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
|
|
1116
1135
|
const [followOnPrompt, setFollowOnPrompt] = useState4("");
|
|
@@ -1201,7 +1220,8 @@ var AgentPanel = ({
|
|
|
1201
1220
|
showPoweredBy,
|
|
1202
1221
|
messages,
|
|
1203
1222
|
conversation,
|
|
1204
|
-
initialHistory
|
|
1223
|
+
initialHistory,
|
|
1224
|
+
hideRagContextInPrompt
|
|
1205
1225
|
}
|
|
1206
1226
|
));
|
|
1207
1227
|
};
|
package/package.json
CHANGED
package/src/AgentPanel.tsx
CHANGED
|
@@ -58,6 +58,7 @@ export interface AgentPanelProps {
|
|
|
58
58
|
//ragQueryLimit?: number;
|
|
59
59
|
//ragRankLimit?: number;
|
|
60
60
|
initialHistory?: { [key: string]: { content: string; callId: string } };
|
|
61
|
+
hideRagContextInPrompt?: boolean;
|
|
61
62
|
}
|
|
62
63
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
63
64
|
inline?: boolean;
|
|
@@ -102,7 +103,8 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
102
103
|
//callToActionMustSendEmail = false,
|
|
103
104
|
//ragQueryLimit = 10,
|
|
104
105
|
//ragRankLimit = 5,
|
|
105
|
-
initialHistory = {}
|
|
106
|
+
initialHistory = {},
|
|
107
|
+
hideRagContextInPrompt = true,
|
|
106
108
|
}) => {
|
|
107
109
|
const [followOnPrompt, setFollowOnPrompt] = useState<string>("");
|
|
108
110
|
|
|
@@ -239,6 +241,7 @@ const AgentPanel: React.FC<AgentPanelProps & ExtraProps> = ({
|
|
|
239
241
|
messages={messages}
|
|
240
242
|
conversation={conversation}
|
|
241
243
|
initialHistory={initialHistory}
|
|
244
|
+
hideRagContextInPrompt={hideRagContextInPrompt}
|
|
242
245
|
/>
|
|
243
246
|
)}
|
|
244
247
|
</>
|
package/src/ChatPanel.tsx
CHANGED
|
@@ -69,6 +69,7 @@ export interface ChatPanelProps {
|
|
|
69
69
|
initialHistory?: {
|
|
70
70
|
[prompt: string]: { content: string; callId: string };
|
|
71
71
|
};
|
|
72
|
+
hideRagContextInPrompt?: boolean;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
interface ExtraProps extends React.HTMLAttributes<HTMLElement> {
|
|
@@ -116,6 +117,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
116
117
|
ragQueryLimit = 10,
|
|
117
118
|
ragRankLimit = 5,
|
|
118
119
|
initialHistory = {},
|
|
120
|
+
hideRagContextInPrompt = true,
|
|
119
121
|
}) => {
|
|
120
122
|
const { send, response, idle, stop, lastCallId } = useLLM({
|
|
121
123
|
project_id: project_id,
|
|
@@ -157,6 +159,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
157
159
|
}, [idle]);
|
|
158
160
|
|
|
159
161
|
useEffect(() => {
|
|
162
|
+
console.log("initialHistory", initialHistory);
|
|
160
163
|
//if (Object.keys(initialHistory).length > 0) {
|
|
161
164
|
setHistory(initialHistory);
|
|
162
165
|
//}
|
|
@@ -613,7 +616,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
613
616
|
html += `
|
|
614
617
|
<div class="history-entry">
|
|
615
618
|
<div class="prompt-container">
|
|
616
|
-
<div class="prompt">${convertMarkdownToHTML(prompt)}</div>
|
|
619
|
+
<div class="prompt">${convertMarkdownToHTML(formatPromptForDisplay(prompt))}</div>
|
|
617
620
|
</div>
|
|
618
621
|
<div class="response-container">
|
|
619
622
|
<div class="response">${convertMarkdownToHTML(response.content)}</div>
|
|
@@ -737,6 +740,27 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
737
740
|
});
|
|
738
741
|
};
|
|
739
742
|
|
|
743
|
+
const formatPromptForDisplay = (prompt: string): string => {
|
|
744
|
+
if (!prompt) {
|
|
745
|
+
return "";
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
if (hideRagContextInPrompt && prompt.includes("CONTEXT:")) {
|
|
749
|
+
const parts = prompt.split("CONTEXT:");
|
|
750
|
+
const withoutContext = parts.length > 0 ? parts[0] as string : "";
|
|
751
|
+
|
|
752
|
+
// Remove the optional chaining since withoutContext is always a string
|
|
753
|
+
if (withoutContext.includes("PROMPT:")) {
|
|
754
|
+
const promptParts = withoutContext.split("PROMPT:");
|
|
755
|
+
return promptParts.length > 1 ? promptParts[1] ?? "".trim() : withoutContext.trim();
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
return withoutContext.trim();
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
return prompt;
|
|
762
|
+
}
|
|
763
|
+
|
|
740
764
|
return (
|
|
741
765
|
<>
|
|
742
766
|
<div
|
|
@@ -762,7 +786,7 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
762
786
|
{Object.entries(history).map(([prompt, response], index) => (
|
|
763
787
|
<div className="history-entry" key={index}>
|
|
764
788
|
{hideInitialPrompt && index === 0 ? null : (
|
|
765
|
-
<div className="prompt">{prompt}</div>
|
|
789
|
+
<div className="prompt">{formatPromptForDisplay(prompt)}</div>
|
|
766
790
|
)}
|
|
767
791
|
|
|
768
792
|
<div className="response">
|