llmasaservice-ui 0.3.14 → 0.3.15
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 +2 -8
- package/dist/index.mjs +2 -8
- package/package.json +1 -1
- package/src/ChatPanel.tsx +2 -26
package/dist/index.js
CHANGED
|
@@ -119,13 +119,11 @@ var ChatPanel = ({
|
|
|
119
119
|
const regex = new RegExp(action.pattern, "gmi");
|
|
120
120
|
newResponse = newResponse.replace(regex, (match, ...groups) => {
|
|
121
121
|
var _a, _b;
|
|
122
|
-
console.log("match", match);
|
|
123
|
-
console.log("groups", groups);
|
|
122
|
+
console.log("action match", match, groups);
|
|
124
123
|
const matchIndex = groups[groups.length - 2];
|
|
125
124
|
const buttonId = `button-${messages.length}-${index}-${matchIndex}`;
|
|
126
125
|
let html = match;
|
|
127
126
|
if (action.type === "button" || action.type === "callback") {
|
|
128
|
-
console.log("Creating button", buttonId, action);
|
|
129
127
|
html = `<button id="${buttonId}">${(_a = action.markdown) != null ? _a : match}</button>`;
|
|
130
128
|
} else if (action.type === "markdown" || action.type === "html") {
|
|
131
129
|
html = (_b = action.markdown) != null ? _b : "";
|
|
@@ -138,12 +136,9 @@ var ChatPanel = ({
|
|
|
138
136
|
const button = document.getElementById(buttonId);
|
|
139
137
|
if (button) {
|
|
140
138
|
if (!button.onclick) {
|
|
141
|
-
console.log("Setting button click event", buttonId, action, groups);
|
|
142
139
|
button.onclick = () => {
|
|
143
140
|
if (action.callback) {
|
|
144
|
-
|
|
145
|
-
console.log("Calling callback", match, groupsCopy);
|
|
146
|
-
action.callback(match, groupsCopy);
|
|
141
|
+
action.callback(match, groups);
|
|
147
142
|
}
|
|
148
143
|
if (action.clickCode) {
|
|
149
144
|
try {
|
|
@@ -157,7 +152,6 @@ var ChatPanel = ({
|
|
|
157
152
|
}
|
|
158
153
|
}
|
|
159
154
|
}, 0);
|
|
160
|
-
console.log("html", html);
|
|
161
155
|
return html;
|
|
162
156
|
});
|
|
163
157
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -86,13 +86,11 @@ var ChatPanel = ({
|
|
|
86
86
|
const regex = new RegExp(action.pattern, "gmi");
|
|
87
87
|
newResponse = newResponse.replace(regex, (match, ...groups) => {
|
|
88
88
|
var _a, _b;
|
|
89
|
-
console.log("match", match);
|
|
90
|
-
console.log("groups", groups);
|
|
89
|
+
console.log("action match", match, groups);
|
|
91
90
|
const matchIndex = groups[groups.length - 2];
|
|
92
91
|
const buttonId = `button-${messages.length}-${index}-${matchIndex}`;
|
|
93
92
|
let html = match;
|
|
94
93
|
if (action.type === "button" || action.type === "callback") {
|
|
95
|
-
console.log("Creating button", buttonId, action);
|
|
96
94
|
html = `<button id="${buttonId}">${(_a = action.markdown) != null ? _a : match}</button>`;
|
|
97
95
|
} else if (action.type === "markdown" || action.type === "html") {
|
|
98
96
|
html = (_b = action.markdown) != null ? _b : "";
|
|
@@ -105,12 +103,9 @@ var ChatPanel = ({
|
|
|
105
103
|
const button = document.getElementById(buttonId);
|
|
106
104
|
if (button) {
|
|
107
105
|
if (!button.onclick) {
|
|
108
|
-
console.log("Setting button click event", buttonId, action, groups);
|
|
109
106
|
button.onclick = () => {
|
|
110
107
|
if (action.callback) {
|
|
111
|
-
|
|
112
|
-
console.log("Calling callback", match, groupsCopy);
|
|
113
|
-
action.callback(match, groupsCopy);
|
|
108
|
+
action.callback(match, groups);
|
|
114
109
|
}
|
|
115
110
|
if (action.clickCode) {
|
|
116
111
|
try {
|
|
@@ -124,7 +119,6 @@ var ChatPanel = ({
|
|
|
124
119
|
}
|
|
125
120
|
}
|
|
126
121
|
}, 0);
|
|
127
|
-
console.log("html", html);
|
|
128
122
|
return html;
|
|
129
123
|
});
|
|
130
124
|
});
|
package/package.json
CHANGED
package/src/ChatPanel.tsx
CHANGED
|
@@ -97,38 +97,18 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
97
97
|
|
|
98
98
|
let newResponse = response;
|
|
99
99
|
|
|
100
|
-
/*
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
[
|
|
104
|
-
{
|
|
105
|
-
"pattern": "any",
|
|
106
|
-
"markdown": "[$match]($1)",
|
|
107
|
-
"type": "markdown"
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
"pattern": "the",
|
|
111
|
-
"type": "button",
|
|
112
|
-
"clickCode": "alert(match);"
|
|
113
|
-
}
|
|
114
|
-
]
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
|
|
118
100
|
// replace actions with links
|
|
119
101
|
if (actions && actions.length > 0) {
|
|
120
102
|
actions.forEach((action, index) => {
|
|
121
103
|
const regex = new RegExp(action.pattern, "gmi");
|
|
122
104
|
newResponse = newResponse.replace(regex, (match, ...groups) => {
|
|
123
|
-
console.log("match", match);
|
|
124
|
-
console.log("groups", groups);
|
|
105
|
+
console.log("action match", match, groups);
|
|
125
106
|
|
|
126
107
|
const matchIndex = groups[groups.length - 2]; // The second-to-last argument is the match index
|
|
127
108
|
const buttonId = `button-${messages.length}-${index}-${matchIndex}`; // a unique button for the conversation level, action index, match index
|
|
128
109
|
|
|
129
110
|
let html = match;
|
|
130
111
|
if (action.type === "button" || action.type === "callback") {
|
|
131
|
-
console.log("Creating button", buttonId, action);
|
|
132
112
|
html = `<button id="${buttonId}">${
|
|
133
113
|
action.markdown ?? match
|
|
134
114
|
}</button>`;
|
|
@@ -145,12 +125,9 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
145
125
|
const button = document.getElementById(buttonId);
|
|
146
126
|
if (button) {
|
|
147
127
|
if (!button.onclick) {
|
|
148
|
-
console.log("Setting button click event", buttonId, action, groups);
|
|
149
128
|
button.onclick = () => {
|
|
150
129
|
if (action.callback) {
|
|
151
|
-
|
|
152
|
-
console.log("Calling callback", match, groupsCopy);
|
|
153
|
-
action.callback(match, groupsCopy);
|
|
130
|
+
action.callback(match, groups);
|
|
154
131
|
}
|
|
155
132
|
if (action.clickCode) {
|
|
156
133
|
try {
|
|
@@ -165,7 +142,6 @@ const ChatPanel: React.FC<ChatPanelProps & ExtraProps> = ({
|
|
|
165
142
|
}
|
|
166
143
|
}, 0);
|
|
167
144
|
|
|
168
|
-
console.log("html", html);
|
|
169
145
|
return html;
|
|
170
146
|
});
|
|
171
147
|
});
|