@lambforge/agent-chat 0.0.7 → 0.0.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/README.md +13 -0
- package/dist/agent-chat.js +75 -38
- package/dist/agent-chat.js.map +3 -3
- package/dist/index.cjs +166 -8
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +166 -8
- package/dist/index.mjs.map +3 -3
- package/package.json +3 -3
- package/types/index.d.ts +12 -0
package/dist/index.mjs
CHANGED
|
@@ -2639,6 +2639,12 @@ var resume = action(
|
|
|
2639
2639
|
var agentEvent = action("[chat] event", payload());
|
|
2640
2640
|
var runEnded = action("[chat] run ended");
|
|
2641
2641
|
var stop = action("[chat] stop", payload());
|
|
2642
|
+
var rate = action("[chat] rate", payload());
|
|
2643
|
+
var rateFailed = action(
|
|
2644
|
+
"[chat] rate failed",
|
|
2645
|
+
payload()
|
|
2646
|
+
);
|
|
2647
|
+
var closeComment = action("[chat] close comment");
|
|
2642
2648
|
|
|
2643
2649
|
// ../../node_modules/@rxdi/redux-store/dist/esm/interfaces.js
|
|
2644
2650
|
var FlattenOperator;
|
|
@@ -2989,6 +2995,20 @@ var ChatEffects = class {
|
|
|
2989
2995
|
})
|
|
2990
2996
|
)
|
|
2991
2997
|
);
|
|
2998
|
+
/** Send a rating; a refusal puts the earlier one back. */
|
|
2999
|
+
this.rate$ = createEffect()(
|
|
3000
|
+
(action$) => action$.pipe(
|
|
3001
|
+
ofType(rate),
|
|
3002
|
+
mergeMap2(({ payload: payload2 }) => {
|
|
3003
|
+
const { agentId, conversationId, messageId, rating, comment, previous } = payload2;
|
|
3004
|
+
if (!this.ctx.client) return EMPTY2;
|
|
3005
|
+
return this.conversation(agentId, conversationId).rate(messageId, rating, comment).pipe(
|
|
3006
|
+
ignoreElements2(),
|
|
3007
|
+
catchError3(() => of5(rateFailed({ messageId, previous })))
|
|
3008
|
+
);
|
|
3009
|
+
})
|
|
3010
|
+
)
|
|
3011
|
+
);
|
|
2992
3012
|
/** Failures also reach the page as an `error` event. */
|
|
2993
3013
|
this.failures$ = createEffect()(
|
|
2994
3014
|
(action$) => action$.pipe(
|
|
@@ -3031,7 +3051,8 @@ var initialChatState = {
|
|
|
3031
3051
|
answering: false,
|
|
3032
3052
|
live: null,
|
|
3033
3053
|
notice: null,
|
|
3034
|
-
files: []
|
|
3054
|
+
files: [],
|
|
3055
|
+
commentFor: null
|
|
3035
3056
|
};
|
|
3036
3057
|
function toMessage(m4) {
|
|
3037
3058
|
const tools = (m4.toolCalls ?? []).map((c9) => c9?.name).filter((n11) => !!n11);
|
|
@@ -3040,7 +3061,8 @@ function toMessage(m4) {
|
|
|
3040
3061
|
role: m4.role,
|
|
3041
3062
|
text: m4.text ?? "",
|
|
3042
3063
|
tools: Array.from(new Set(tools)),
|
|
3043
|
-
attachments: (m4.attachments ?? []).map((a5) => a5.name)
|
|
3064
|
+
attachments: (m4.attachments ?? []).map((a5) => a5.name),
|
|
3065
|
+
feedback: m4.feedback?.rating ?? null
|
|
3044
3066
|
};
|
|
3045
3067
|
}
|
|
3046
3068
|
|
|
@@ -3052,7 +3074,8 @@ var empty = {
|
|
|
3052
3074
|
answering: false,
|
|
3053
3075
|
live: null,
|
|
3054
3076
|
notice: null,
|
|
3055
|
-
files: []
|
|
3077
|
+
files: [],
|
|
3078
|
+
commentFor: null
|
|
3056
3079
|
};
|
|
3057
3080
|
var chatReducer = reducer(
|
|
3058
3081
|
initialChatState,
|
|
@@ -3097,7 +3120,8 @@ var chatReducer = reducer(
|
|
|
3097
3120
|
role: "user",
|
|
3098
3121
|
text: payload2.text,
|
|
3099
3122
|
tools: [],
|
|
3100
|
-
attachments: (payload2.files ?? []).map((f4) => f4.name)
|
|
3123
|
+
attachments: (payload2.files ?? []).map((f4) => f4.name),
|
|
3124
|
+
feedback: null
|
|
3101
3125
|
}
|
|
3102
3126
|
],
|
|
3103
3127
|
files: [],
|
|
@@ -3124,6 +3148,22 @@ var chatReducer = reducer(
|
|
|
3124
3148
|
live: null,
|
|
3125
3149
|
notice: s9.notice?.kind === "busy" ? null : s9.notice
|
|
3126
3150
|
})),
|
|
3151
|
+
on(rate, (s9, { payload: payload2 }) => ({
|
|
3152
|
+
...s9,
|
|
3153
|
+
messages: s9.messages.map(
|
|
3154
|
+
(m4) => m4.id === payload2.messageId ? { ...m4, feedback: payload2.rating } : m4
|
|
3155
|
+
),
|
|
3156
|
+
// a fresh thumbs down asks what was wrong; a comment or anything else closes it
|
|
3157
|
+
commentFor: payload2.rating === "down" && payload2.comment === void 0 && payload2.previous !== "down" ? payload2.messageId : null
|
|
3158
|
+
})),
|
|
3159
|
+
on(rateFailed, (s9, { payload: payload2 }) => ({
|
|
3160
|
+
...s9,
|
|
3161
|
+
messages: s9.messages.map(
|
|
3162
|
+
(m4) => m4.id === payload2.messageId ? { ...m4, feedback: payload2.previous } : m4
|
|
3163
|
+
),
|
|
3164
|
+
commentFor: s9.commentFor === payload2.messageId ? null : s9.commentFor
|
|
3165
|
+
})),
|
|
3166
|
+
on(closeComment, (s9) => ({ ...s9, commentFor: null })),
|
|
3127
3167
|
on(stop, (s9) => ({ ...s9, answering: false, live: null, notice: { kind: "info", what: "stopped" } }))
|
|
3128
3168
|
);
|
|
3129
3169
|
function withEvent(s9, event) {
|
|
@@ -3138,6 +3178,7 @@ function withEvent(s9, event) {
|
|
|
3138
3178
|
};
|
|
3139
3179
|
}
|
|
3140
3180
|
if (event.type === "delta") return withDelta({ ...s9, conversationId }, event);
|
|
3181
|
+
if (event.type === "step") return withStep({ ...s9, conversationId }, event);
|
|
3141
3182
|
if (event.type !== "message" || !event.data?.id) return { ...s9, conversationId };
|
|
3142
3183
|
const message = toMessage(event.data);
|
|
3143
3184
|
if (s9.messages.some((m4) => m4.id === message.id)) return { ...s9, conversationId };
|
|
@@ -3148,6 +3189,13 @@ function withEvent(s9, event) {
|
|
|
3148
3189
|
const live = message.role === "assistant" ? null : s9.live;
|
|
3149
3190
|
return { ...s9, conversationId, messages, live };
|
|
3150
3191
|
}
|
|
3192
|
+
function withStep(s9, event) {
|
|
3193
|
+
if (!s9.answering || s9.notice?.kind !== "busy" || s9.notice.what !== "thinking") return s9;
|
|
3194
|
+
const n11 = Number(event.data?.step) || 0;
|
|
3195
|
+
if (s9.notice.step && n11 < s9.notice.step.n) return s9;
|
|
3196
|
+
const tool = typeof event.data?.tool === "string" && event.data.tool ? event.data.tool : null;
|
|
3197
|
+
return { ...s9, notice: { ...s9.notice, step: { n: n11, tool } } };
|
|
3198
|
+
}
|
|
3151
3199
|
function withDelta(s9, event) {
|
|
3152
3200
|
if (!s9.answering || !event.runId) return s9;
|
|
3153
3201
|
const segment = Number(event.data?.segment) || 0;
|
|
@@ -3175,6 +3223,7 @@ var ChatStore = class {
|
|
|
3175
3223
|
effects.select$,
|
|
3176
3224
|
effects.run$,
|
|
3177
3225
|
effects.abort$,
|
|
3226
|
+
effects.rate$,
|
|
3178
3227
|
effects.failures$,
|
|
3179
3228
|
effects.connect$
|
|
3180
3229
|
),
|
|
@@ -3201,6 +3250,8 @@ var en = {
|
|
|
3201
3250
|
send: "Send",
|
|
3202
3251
|
stop: "Stop",
|
|
3203
3252
|
thinking: "Thinking",
|
|
3253
|
+
checking: "Checking the data",
|
|
3254
|
+
lookingAt: "Looking at",
|
|
3204
3255
|
connecting: "Connecting",
|
|
3205
3256
|
pickAgent: "Assistant",
|
|
3206
3257
|
usedTools: "Used",
|
|
@@ -3209,6 +3260,12 @@ var en = {
|
|
|
3209
3260
|
attached: "Attached files",
|
|
3210
3261
|
removeFile: "Remove",
|
|
3211
3262
|
filesOnly: "Please look at the attached files.",
|
|
3263
|
+
helpful: "Helpful",
|
|
3264
|
+
notHelpful: "Not helpful",
|
|
3265
|
+
whatWentWrong: "What was wrong? (optional)",
|
|
3266
|
+
sendFeedback: "Send",
|
|
3267
|
+
skipFeedback: "Skip",
|
|
3268
|
+
thanks: "Thanks for the feedback",
|
|
3212
3269
|
errors: {
|
|
3213
3270
|
"limit-reached": "This conversation is full - start a new one.",
|
|
3214
3271
|
"cap-reached": "The assistant is not available right now - try again later.",
|
|
@@ -3216,6 +3273,9 @@ var en = {
|
|
|
3216
3273
|
"session-expired": "Your session ended - reload the page.",
|
|
3217
3274
|
"credential-expired": "Please sign in again.",
|
|
3218
3275
|
aborted: "Stopped.",
|
|
3276
|
+
timeout: "The answer took too long - try again or ask something shorter.",
|
|
3277
|
+
"embeddings-off": "Something went wrong - try again.",
|
|
3278
|
+
"embeddings-cap-reached": "Something went wrong - try again.",
|
|
3219
3279
|
internal: "Something went wrong - try again.",
|
|
3220
3280
|
unauthorized: "This chat is not allowed here.",
|
|
3221
3281
|
"bad-request": "That did not work - try again.",
|
|
@@ -3239,6 +3299,8 @@ var bg = {
|
|
|
3239
3299
|
send: "\u0418\u0437\u043F\u0440\u0430\u0442\u0438",
|
|
3240
3300
|
stop: "\u0421\u043F\u0440\u0438",
|
|
3241
3301
|
thinking: "\u041C\u0438\u0441\u043B\u044F",
|
|
3302
|
+
checking: "\u041F\u0440\u043E\u0432\u0435\u0440\u044F\u0432\u0430\u043C \u0434\u0430\u043D\u043D\u0438\u0442\u0435",
|
|
3303
|
+
lookingAt: "\u0413\u043B\u0435\u0434\u0430\u043C",
|
|
3242
3304
|
connecting: "\u0421\u0432\u044A\u0440\u0437\u0432\u0430\u043D\u0435",
|
|
3243
3305
|
pickAgent: "\u0410\u0441\u0438\u0441\u0442\u0435\u043D\u0442",
|
|
3244
3306
|
usedTools: "\u0418\u0437\u043F\u043E\u043B\u0437\u0432\u0430\u043D\u043E",
|
|
@@ -3247,6 +3309,12 @@ var bg = {
|
|
|
3247
3309
|
attached: "\u041F\u0440\u0438\u043A\u0430\u0447\u0435\u043D\u0438 \u0444\u0430\u0439\u043B\u043E\u0432\u0435",
|
|
3248
3310
|
removeFile: "\u041F\u0440\u0435\u043C\u0430\u0445\u043D\u0438",
|
|
3249
3311
|
filesOnly: "\u041C\u043E\u043B\u044F, \u0440\u0430\u0437\u0433\u043B\u0435\u0434\u0430\u0439\u0442\u0435 \u043F\u0440\u0438\u043A\u0430\u0447\u0435\u043D\u0438\u0442\u0435 \u0444\u0430\u0439\u043B\u043E\u0432\u0435.",
|
|
3312
|
+
helpful: "\u041F\u043E\u043B\u0435\u0437\u043D\u043E",
|
|
3313
|
+
notHelpful: "\u041D\u0435 \u0435 \u043F\u043E\u043B\u0435\u0437\u043D\u043E",
|
|
3314
|
+
whatWentWrong: "\u041A\u0430\u043A\u0432\u043E \u043D\u0435 \u0431\u0435\u0448\u0435 \u043D\u0430\u0440\u0435\u0434? (\u043F\u043E \u0436\u0435\u043B\u0430\u043D\u0438\u0435)",
|
|
3315
|
+
sendFeedback: "\u0418\u0437\u043F\u0440\u0430\u0442\u0438",
|
|
3316
|
+
skipFeedback: "\u041F\u0440\u043E\u043F\u0443\u0441\u043D\u0438",
|
|
3317
|
+
thanks: "\u0411\u043B\u0430\u0433\u043E\u0434\u0430\u0440\u0438\u043C \u0437\u0430 \u043E\u0442\u0437\u0438\u0432\u0430",
|
|
3250
3318
|
errors: {
|
|
3251
3319
|
"limit-reached": "\u0420\u0430\u0437\u0433\u043E\u0432\u043E\u0440\u044A\u0442 \u0435 \u043F\u044A\u043B\u0435\u043D - \u0437\u0430\u043F\u043E\u0447\u043D\u0435\u0442\u0435 \u043D\u043E\u0432.",
|
|
3252
3320
|
"cap-reached": "\u0410\u0441\u0438\u0441\u0442\u0435\u043D\u0442\u044A\u0442 \u043D\u0435 \u0435 \u0434\u043E\u0441\u0442\u044A\u043F\u0435\u043D \u0432 \u043C\u043E\u043C\u0435\u043D\u0442\u0430 - \u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043F\u043E-\u043A\u044A\u0441\u043D\u043E.",
|
|
@@ -3254,6 +3322,9 @@ var bg = {
|
|
|
3254
3322
|
"session-expired": "\u0421\u0435\u0441\u0438\u044F\u0442\u0430 \u0438\u0437\u0442\u0435\u0447\u0435 - \u043F\u0440\u0435\u0437\u0430\u0440\u0435\u0434\u0435\u0442\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430\u0442\u0430.",
|
|
3255
3323
|
"credential-expired": "\u041C\u043E\u043B\u044F, \u0432\u043B\u0435\u0437\u0442\u0435 \u043E\u0442\u043D\u043E\u0432\u043E.",
|
|
3256
3324
|
aborted: "\u0421\u043F\u0440\u044F\u043D\u043E.",
|
|
3325
|
+
timeout: "\u041E\u0442\u0433\u043E\u0432\u043E\u0440\u044A\u0442 \u043E\u0442\u043D\u0435 \u0442\u0432\u044A\u0440\u0434\u0435 \u0434\u044A\u043B\u0433\u043E - \u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043E\u0442\u043D\u043E\u0432\u043E \u0438\u043B\u0438 \u043F\u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043F\u043E-\u043A\u0440\u0430\u0442\u043A\u043E.",
|
|
3326
|
+
"embeddings-off": "\u041D\u0435\u0449\u043E \u0441\u0435 \u043E\u0431\u044A\u0440\u043A\u0430 - \u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043E\u0442\u043D\u043E\u0432\u043E.",
|
|
3327
|
+
"embeddings-cap-reached": "\u041D\u0435\u0449\u043E \u0441\u0435 \u043E\u0431\u044A\u0440\u043A\u0430 - \u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043E\u0442\u043D\u043E\u0432\u043E.",
|
|
3257
3328
|
internal: "\u041D\u0435\u0449\u043E \u0441\u0435 \u043E\u0431\u044A\u0440\u043A\u0430 - \u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043E\u0442\u043D\u043E\u0432\u043E.",
|
|
3258
3329
|
unauthorized: "\u0422\u043E\u0437\u0438 \u0447\u0430\u0442 \u043D\u0435 \u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043D \u0442\u0443\u043A.",
|
|
3259
3330
|
"bad-request": "\u041D\u0435 \u0441\u0435 \u043F\u043E\u043B\u0443\u0447\u0438 - \u043E\u043F\u0438\u0442\u0430\u0439\u0442\u0435 \u043E\u0442\u043D\u043E\u0432\u043E.",
|
|
@@ -3410,6 +3481,26 @@ header select {
|
|
|
3410
3481
|
@keyframes lf-caret { 50% { opacity: 0; } }
|
|
3411
3482
|
@media (prefers-reduced-motion: reduce) { .msg.live > :last-child::after { animation: none; } }
|
|
3412
3483
|
.tools { font-size: 12px; color: var(--_muted); margin-top: 4px; }
|
|
3484
|
+
.rate { display: flex; align-items: center; gap: 2px; margin-top: -6px; }
|
|
3485
|
+
.thumb {
|
|
3486
|
+
border: 0; background: transparent; color: var(--_muted);
|
|
3487
|
+
width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; cursor: pointer;
|
|
3488
|
+
}
|
|
3489
|
+
.thumb svg { width: 14px; height: 14px; }
|
|
3490
|
+
.thumb:hover, .thumb:focus-visible { background: var(--_bot-bg); color: var(--_fg); }
|
|
3491
|
+
.thumb.on { color: var(--_accent); }
|
|
3492
|
+
.thanks { font-size: 12px; color: var(--_muted); margin-left: 4px; }
|
|
3493
|
+
.comment { display: flex; gap: 6px; align-items: center; max-width: 85%; }
|
|
3494
|
+
.comment input {
|
|
3495
|
+
flex: 1; min-width: 0; font: inherit; font-size: 13px; color: var(--_fg); background: var(--_bg);
|
|
3496
|
+
border: 1px solid var(--_border); border-radius: 8px; padding: 6px 8px;
|
|
3497
|
+
}
|
|
3498
|
+
.comment button {
|
|
3499
|
+
border: 1px solid var(--_border); background: transparent; color: var(--_fg);
|
|
3500
|
+
border-radius: 8px; padding: 5px 9px; font-size: 13px; cursor: pointer;
|
|
3501
|
+
}
|
|
3502
|
+
.comment button[type='submit'] { border-color: var(--_accent); color: var(--_accent); }
|
|
3503
|
+
.comment .skip { color: var(--_muted); }
|
|
3413
3504
|
|
|
3414
3505
|
.welcome { color: var(--_muted); }
|
|
3415
3506
|
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
@@ -3561,6 +3652,8 @@ var TAG = "lambforge-agent-chat";
|
|
|
3561
3652
|
var ICON_CHAT = import_lit_html19.svg`<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/>`;
|
|
3562
3653
|
var ICON_CLOSE = import_lit_html19.svg`<path d="M18 6 6 18M6 6l12 12"/>`;
|
|
3563
3654
|
var ICON_NEW = import_lit_html19.svg`<path d="M12 5v14M5 12h14"/>`;
|
|
3655
|
+
var ICON_UP = import_lit_html19.svg`<path d="M7 10v12M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z"/>`;
|
|
3656
|
+
var ICON_DOWN = import_lit_html19.svg`<path d="M17 14V2M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z"/>`;
|
|
3564
3657
|
var ICON_ATTACH = import_lit_html19.svg`<path d="m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"/>`;
|
|
3565
3658
|
var ACCEPT = [...ACCEPTED_ATTACHMENT_TYPES, ".md", ".csv", ".yaml", ".yml", ".json", ".txt"].join(",");
|
|
3566
3659
|
var icon = (paths) => import_lit_html19.html`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${paths}</svg>`;
|
|
@@ -3780,7 +3873,11 @@ var LambforgeAgentChat = class extends import_lit_html19.LitElement {
|
|
|
3780
3873
|
noticeText(notice) {
|
|
3781
3874
|
if (!notice) return "";
|
|
3782
3875
|
const t9 = this.t;
|
|
3783
|
-
if (notice.kind === "busy")
|
|
3876
|
+
if (notice.kind === "busy") {
|
|
3877
|
+
const step = notice.what === "thinking" ? notice.step : void 0;
|
|
3878
|
+
if (!step) return t9[notice.what];
|
|
3879
|
+
return `${t9[notice.what]} - ${step.tool ? `${t9.lookingAt}: ${toolLabel(step.tool)}` : t9.checking}`;
|
|
3880
|
+
}
|
|
3784
3881
|
if (notice.kind === "info") return t9.errors.aborted;
|
|
3785
3882
|
return t9.errors[notice.code] ?? t9.errors.default;
|
|
3786
3883
|
}
|
|
@@ -3849,7 +3946,7 @@ var LambforgeAgentChat = class extends import_lit_html19.LitElement {
|
|
|
3849
3946
|
aria-relevant="additions"
|
|
3850
3947
|
aria-busy=${String(!!live)}
|
|
3851
3948
|
>
|
|
3852
|
-
${state.messages.length ? state.messages.map((m4) => this.bubble(m4)) : this.intro(state)}
|
|
3949
|
+
${state.messages.length ? state.messages.map((m4) => this.bubble(m4, state)) : this.intro(state)}
|
|
3853
3950
|
${live ? import_lit_html19.html`<div class="msg assistant live" part="message assistant live">${renderMarkdown(live.text)}</div>` : ""}
|
|
3854
3951
|
</div>
|
|
3855
3952
|
<div class="turnstile" ?hidden=${notice?.kind !== "busy" || notice.what !== "verifying"}></div>
|
|
@@ -3909,14 +4006,67 @@ var LambforgeAgentChat = class extends import_lit_html19.LitElement {
|
|
|
3909
4006
|
</section>
|
|
3910
4007
|
`;
|
|
3911
4008
|
}
|
|
3912
|
-
|
|
4009
|
+
/**
|
|
4010
|
+
* Rate an answer: the same thumb again clears it. Only stored answers of
|
|
4011
|
+
* an agent that takes ratings (plan 51 §15 #7).
|
|
4012
|
+
*/
|
|
4013
|
+
rateAnswer(m4, rating, comment) {
|
|
4014
|
+
return ([state]) => {
|
|
4015
|
+
if (!state.agentId || !state.conversationId) return;
|
|
4016
|
+
const next = comment === void 0 && m4.feedback === rating ? null : rating;
|
|
4017
|
+
this.dispatch(
|
|
4018
|
+
rate({
|
|
4019
|
+
agentId: state.agentId,
|
|
4020
|
+
conversationId: state.conversationId,
|
|
4021
|
+
messageId: m4.id,
|
|
4022
|
+
rating: next,
|
|
4023
|
+
...comment !== void 0 ? { comment } : {},
|
|
4024
|
+
previous: m4.feedback
|
|
4025
|
+
})
|
|
4026
|
+
);
|
|
4027
|
+
};
|
|
4028
|
+
}
|
|
4029
|
+
sendComment(ev, m4, state) {
|
|
4030
|
+
ev.preventDefault();
|
|
4031
|
+
const input = ev.target.querySelector("input");
|
|
4032
|
+
const text = input?.value.trim() ?? "";
|
|
4033
|
+
if (!text) {
|
|
4034
|
+
this.dispatch(closeComment());
|
|
4035
|
+
return;
|
|
4036
|
+
}
|
|
4037
|
+
this.rateAnswer(m4, "down", text)([state]);
|
|
4038
|
+
}
|
|
4039
|
+
feedback(m4, state) {
|
|
4040
|
+
const agent = state.agents.find((a5) => a5.id === state.agentId);
|
|
4041
|
+
if (agent?.allowFeedback === false || m4.id.startsWith("local:") || !state.conversationId) return "";
|
|
4042
|
+
const t9 = this.t;
|
|
4043
|
+
return import_lit_html19.html`
|
|
4044
|
+
<div class="rate" part="rate">
|
|
4045
|
+
<button type="button" class="thumb ${m4.feedback === "up" ? "on" : ""}" part="thumb-up"
|
|
4046
|
+
title=${t9.helpful} aria-label=${t9.helpful} aria-pressed=${m4.feedback === "up" ? "true" : "false"}
|
|
4047
|
+
@click=${() => this.rateAnswer(m4, "up")([state])}>${icon(ICON_UP)}</button>
|
|
4048
|
+
<button type="button" class="thumb ${m4.feedback === "down" ? "on" : ""}" part="thumb-down"
|
|
4049
|
+
title=${t9.notHelpful} aria-label=${t9.notHelpful} aria-pressed=${m4.feedback === "down" ? "true" : "false"}
|
|
4050
|
+
@click=${() => this.rateAnswer(m4, "down")([state])}>${icon(ICON_DOWN)}</button>
|
|
4051
|
+
${m4.feedback && state.commentFor !== m4.id ? import_lit_html19.html`<span class="thanks" aria-live="polite">${t9.thanks}</span>` : ""}
|
|
4052
|
+
</div>
|
|
4053
|
+
${state.commentFor === m4.id ? import_lit_html19.html`<form class="comment" part="feedback-comment" @submit=${(ev) => this.sendComment(ev, m4, state)}>
|
|
4054
|
+
<input type="text" maxlength="1000" placeholder=${t9.whatWentWrong} aria-label=${t9.whatWentWrong}
|
|
4055
|
+
@keydown=${(ev) => ev.key === "Escape" && this.dispatch(closeComment())} />
|
|
4056
|
+
<button type="submit">${t9.sendFeedback}</button>
|
|
4057
|
+
<button type="button" class="skip" @click=${() => this.dispatch(closeComment())}>${t9.skipFeedback}</button>
|
|
4058
|
+
</form>` : ""}
|
|
4059
|
+
`;
|
|
4060
|
+
}
|
|
4061
|
+
bubble(m4, state) {
|
|
3913
4062
|
if (m4.role === "user") {
|
|
3914
4063
|
return import_lit_html19.html`<div class="msg user" part="message user">${m4.text}${m4.attachments?.length ? import_lit_html19.html`<div class="msg-files">${m4.attachments.map((name) => import_lit_html19.html`<span class="msg-file">${name}</span>`)}</div>` : ""}</div>`;
|
|
3915
4064
|
}
|
|
3916
4065
|
return import_lit_html19.html`<div class="msg assistant" part="message assistant">
|
|
3917
4066
|
${renderMarkdown(m4.text)}
|
|
3918
4067
|
${m4.tools.length ? import_lit_html19.html`<div class="tools">${this.t.usedTools}: ${m4.tools.join(", ")}</div>` : ""}
|
|
3919
|
-
</div
|
|
4068
|
+
</div>
|
|
4069
|
+
${this.feedback(m4, state)}`;
|
|
3920
4070
|
}
|
|
3921
4071
|
intro(state) {
|
|
3922
4072
|
const agent = state.agents.find((a5) => a5.id === state.agentId);
|
|
@@ -4000,6 +4150,11 @@ LambforgeAgentChat = __decorateClass([
|
|
|
4000
4150
|
}
|
|
4001
4151
|
})
|
|
4002
4152
|
], LambforgeAgentChat);
|
|
4153
|
+
function toolLabel(name) {
|
|
4154
|
+
const bare = String(name).split("__").pop() ?? "";
|
|
4155
|
+
const words = bare.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").trim().toLowerCase();
|
|
4156
|
+
return words ? words[0].toUpperCase() + words.slice(1) : "";
|
|
4157
|
+
}
|
|
4003
4158
|
export {
|
|
4004
4159
|
ChatEffects,
|
|
4005
4160
|
ChatStore,
|
|
@@ -4011,6 +4166,7 @@ export {
|
|
|
4011
4166
|
agentEvent,
|
|
4012
4167
|
agentsLoaded,
|
|
4013
4168
|
chatReducer,
|
|
4169
|
+
closeComment,
|
|
4014
4170
|
connecting,
|
|
4015
4171
|
errorCode,
|
|
4016
4172
|
failed,
|
|
@@ -4020,6 +4176,8 @@ export {
|
|
|
4020
4176
|
newConversation,
|
|
4021
4177
|
pickAgent,
|
|
4022
4178
|
pickAgents,
|
|
4179
|
+
rate,
|
|
4180
|
+
rateFailed,
|
|
4023
4181
|
removeFile,
|
|
4024
4182
|
renderMarkdown,
|
|
4025
4183
|
resume,
|