@box/box-ai-content-answers 1.19.4 → 1.21.0
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/chunks/clear-conversation-button.js +15 -16
- package/dist/chunks/stopResponseButton.js +19 -23
- package/dist/chunks/types.js +8 -8
- package/dist/chunks/warning-message.js +15 -16
- package/dist/esm/lib/components/answer/answer-content.js +15 -15
- package/dist/esm/lib/components/answer/answer.js +107 -109
- package/dist/esm/lib/components/answer/citation.js +23 -24
- package/dist/esm/lib/components/answer/copy-button.js +3 -3
- package/dist/esm/lib/components/answer/embed-the-answer-button.js +44 -44
- package/dist/esm/lib/components/answer/feedback-tooltip.js +63 -56
- package/dist/esm/lib/components/answer/inline-error.js +1 -1
- package/dist/esm/lib/components/answer/loading-indicator.js +15 -18
- package/dist/esm/lib/components/answer/references.js +30 -30
- package/dist/esm/lib/components/answer/thumb-buttons.js +95 -96
- package/dist/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +166 -167
- package/dist/esm/lib/components/api-wrapper/reducer.js +1 -1
- package/dist/esm/lib/components/api-wrapper/utils/request.js +8 -8
- package/dist/esm/lib/components/api-wrapper/utils/stream.js +24 -25
- package/dist/esm/lib/components/chat/chat.js +78 -79
- package/dist/esm/lib/components/common/focusInputUtils.js +3 -4
- package/dist/esm/lib/components/common/markdown-react.js +91 -93
- package/dist/esm/lib/components/common/markdown.js +2666 -2696
- package/dist/esm/lib/components/content/content.js +38 -39
- package/dist/esm/lib/components/footer/footer-actions.js +3 -3
- package/dist/esm/lib/components/footer/footer.js +97 -98
- package/dist/esm/lib/components/modal/modal.js +121 -122
- package/dist/esm/lib/components/sidebar/content.js +95 -101
- package/dist/esm/lib/components/sidebar/sidebar.js +82 -83
- package/dist/esm/lib/components/suggested-questions/suggested-questions.js +1 -1
- package/dist/esm/lib/components/suggested-questions/suggestions.js +30 -30
- package/dist/esm/lib/components/welcome-message/contextual-items-message.js +36 -38
- package/dist/esm/lib/components/welcome-message/items-dropdown.js +27 -27
- package/dist/esm/lib/hooks/usePromptFocus.js +13 -14
- package/dist/i18n/en-x-pseudo.js +89 -89
- package/dist/i18n/en-x-pseudo.properties +89 -89
- package/dist/styles/answer-content.css +1 -1
- package/dist/styles/answer.css +1 -1
- package/dist/styles/box-ai-content-answers.css +1 -1
- package/dist/styles/chat.css +1 -1
- package/dist/styles/clear-conversation-button.css +1 -1
- package/dist/styles/content.css +1 -1
- package/dist/styles/content2.css +1 -1
- package/dist/styles/markdown2.css +1 -1
- package/dist/styles/question.css +1 -1
- package/dist/styles/stopResponseButton.css +1 -1
- package/dist/styles/warning-message.css +1 -1
- package/dist/types/lib/components/api-wrapper/hooks/useContentAnswers.d.ts +1 -1
- package/package.json +11 -11
|
@@ -1,120 +1,119 @@
|
|
|
1
|
-
import { useBlueprintModernization as
|
|
2
|
-
import { ThumbUp as
|
|
3
|
-
import { ThumbUp as
|
|
4
|
-
import { ThumbsUp as
|
|
5
|
-
import { ThumbsUp as
|
|
6
|
-
import { useAgents as
|
|
7
|
-
import
|
|
8
|
-
import { useIntl as
|
|
9
|
-
import {
|
|
10
|
-
import { FeedbackTooltip as
|
|
11
|
-
import
|
|
12
|
-
import { focusInput as
|
|
13
|
-
import
|
|
14
|
-
import { jsxs as
|
|
15
|
-
import '../../../../styles/thumb-buttons.css';const
|
|
16
|
-
thumbDown:
|
|
17
|
-
},
|
|
1
|
+
import { useBlueprintModernization as W, useNotification as E, Tooltip as A, IconButton as L } from "@box/blueprint-web";
|
|
2
|
+
import { ThumbUp as j, ThumbDown as F } from "@box/blueprint-web-assets/icons/Fill";
|
|
3
|
+
import { ThumbUp as J, ThumbDown as K } from "@box/blueprint-web-assets/icons/Line";
|
|
4
|
+
import { ThumbsUp as Q, ThumbsDown as V } from "@box/blueprint-web-assets/icons/Medium";
|
|
5
|
+
import { ThumbsUp as X, ThumbsDown as Y } from "@box/blueprint-web-assets/icons/MediumFilled";
|
|
6
|
+
import { useAgents as Z } from "@box/box-ai-agent-selector";
|
|
7
|
+
import c from "react";
|
|
8
|
+
import { useIntl as q } from "react-intl";
|
|
9
|
+
import { LOGGER_ACTION_PROGRAMMATIC as tt, LOGGER_BASE_CONFIG as et } from "../common/constants.js";
|
|
10
|
+
import { FeedbackTooltip as ot } from "./feedback-tooltip.js";
|
|
11
|
+
import C from "../../messages.js";
|
|
12
|
+
import { focusInput as at } from "../common/focusInputUtils.js";
|
|
13
|
+
import l from "./messages.js";
|
|
14
|
+
import { jsxs as st, Fragment as nt, jsx as i } from "react/jsx-runtime";
|
|
15
|
+
import '../../../../styles/thumb-buttons.css';const mt = "_thumbDown_1axcd_1", lt = {
|
|
16
|
+
thumbDown: mt
|
|
17
|
+
}, m = {
|
|
18
18
|
THUMB_UP: "positive",
|
|
19
|
-
THUMB_DOWN: "negative"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
setAnswerFeedback: e,
|
|
19
|
+
THUMB_DOWN: "negative"
|
|
20
|
+
}, Bt = ({
|
|
21
|
+
feedbackValue: y,
|
|
22
|
+
hostAppName: b,
|
|
23
|
+
isFeedbackFormEnabled: O = !1,
|
|
24
|
+
isFeedbackTooltipOpen: x = !1,
|
|
25
|
+
items: p,
|
|
26
|
+
onFeedbackFormSubmit: h,
|
|
27
|
+
onFeedbackTooltipOpenChange: r,
|
|
28
|
+
prompt: T,
|
|
29
|
+
promptType: d,
|
|
30
|
+
questionId: e,
|
|
31
|
+
recordAction: U,
|
|
32
|
+
response: D,
|
|
33
|
+
setAnswerFeedback: _,
|
|
35
34
|
shouldFeedbackFormIncludeFeedbackText: w = !1,
|
|
36
|
-
shouldFeedbackIncludePromptData:
|
|
37
|
-
variant:
|
|
35
|
+
shouldFeedbackIncludePromptData: B = !1,
|
|
36
|
+
variant: M
|
|
38
37
|
}) => {
|
|
39
38
|
const {
|
|
40
|
-
enableModernizedComponents:
|
|
41
|
-
} =
|
|
42
|
-
formatMessage:
|
|
43
|
-
} =
|
|
44
|
-
addNotification:
|
|
45
|
-
} =
|
|
46
|
-
selectedAgent:
|
|
47
|
-
} =
|
|
48
|
-
|
|
49
|
-
...
|
|
50
|
-
action:
|
|
39
|
+
enableModernizedComponents: o
|
|
40
|
+
} = W(), {
|
|
41
|
+
formatMessage: a
|
|
42
|
+
} = q(), {
|
|
43
|
+
addNotification: H
|
|
44
|
+
} = E(), {
|
|
45
|
+
selectedAgent: g
|
|
46
|
+
} = Z(), n = y, f = c.useMemo(() => p.filter((t) => t.status === "supported").map((t) => t.fileType), [p]), u = c.useCallback((t) => {
|
|
47
|
+
n !== t && (_?.(e, t), U?.({
|
|
48
|
+
...et,
|
|
49
|
+
action: tt,
|
|
51
50
|
target: "answer_feedback",
|
|
52
|
-
component:
|
|
51
|
+
component: M,
|
|
53
52
|
data: {
|
|
54
53
|
feedback_value: t,
|
|
55
|
-
file_types:
|
|
56
|
-
feature:
|
|
57
|
-
prompt_type:
|
|
54
|
+
file_types: f,
|
|
55
|
+
feature: b,
|
|
56
|
+
prompt_type: d
|
|
58
57
|
}
|
|
59
|
-
}),
|
|
60
|
-
}, [
|
|
58
|
+
}), at());
|
|
59
|
+
}, [b, U, n, M, f, e, _, d]), I = ({
|
|
61
60
|
feedback: t,
|
|
62
|
-
feedbackPromptShareConsent:
|
|
63
|
-
issueType:
|
|
61
|
+
feedbackPromptShareConsent: $,
|
|
62
|
+
issueType: z
|
|
64
63
|
}) => {
|
|
65
|
-
if (
|
|
64
|
+
if (r?.(!1, e), !h)
|
|
66
65
|
return;
|
|
67
|
-
const
|
|
68
|
-
fileTypes:
|
|
66
|
+
const s = {
|
|
67
|
+
fileTypes: f,
|
|
69
68
|
hasPromptData: !1,
|
|
70
|
-
hostApp:
|
|
71
|
-
issueType:
|
|
69
|
+
hostApp: b,
|
|
70
|
+
issueType: z,
|
|
72
71
|
timestamp: Date.now(),
|
|
73
|
-
questionId:
|
|
72
|
+
questionId: e
|
|
74
73
|
};
|
|
75
|
-
w && (
|
|
76
|
-
|
|
74
|
+
w && (s.feedback = t, s.hasFeedback = !!t), B && $ && T && D && (s.hasPromptData = !0, s.prompt = T, s.response = D), g && (s.selectedAgentName = g.name), h(s, () => {
|
|
75
|
+
H({
|
|
77
76
|
sensitivity: "foreground",
|
|
78
|
-
styledText:
|
|
77
|
+
styledText: a(l.feedbackTooltipConfirmation),
|
|
79
78
|
variant: "success",
|
|
80
|
-
typeIconAriaLabel:
|
|
81
|
-
closeButtonAriaLabel:
|
|
79
|
+
typeIconAriaLabel: a(C.ariaTypeSuccessIconLabel),
|
|
80
|
+
closeButtonAriaLabel: a(C.closeButtonText)
|
|
82
81
|
});
|
|
83
82
|
});
|
|
84
|
-
},
|
|
85
|
-
t ||
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
}, [
|
|
89
|
-
return /* @__PURE__ */
|
|
90
|
-
children: [/* @__PURE__ */
|
|
91
|
-
content:
|
|
92
|
-
children: /* @__PURE__ */
|
|
93
|
-
"aria-label":
|
|
94
|
-
disabled:
|
|
95
|
-
icon:
|
|
96
|
-
onClick:
|
|
83
|
+
}, N = (t) => {
|
|
84
|
+
t || r?.(!1, e);
|
|
85
|
+
}, k = c.useCallback(() => u(m.THUMB_UP), [u]), P = c.useCallback(() => {
|
|
86
|
+
u(m.THUMB_DOWN), r?.(!0, e);
|
|
87
|
+
}, [u, r, e]), v = o ? Q : J, G = o ? V : K, R = o ? X : j, S = o ? Y : F;
|
|
88
|
+
return /* @__PURE__ */ st(nt, {
|
|
89
|
+
children: [/* @__PURE__ */ i(A, {
|
|
90
|
+
content: a(l.thumbsUpAriaLabel),
|
|
91
|
+
children: /* @__PURE__ */ i(L, {
|
|
92
|
+
"aria-label": a(l.thumbsUpAriaLabel),
|
|
93
|
+
disabled: n === m.THUMB_DOWN,
|
|
94
|
+
icon: n === m.THUMB_UP ? R : v,
|
|
95
|
+
onClick: k,
|
|
97
96
|
size: "x-small",
|
|
98
|
-
variant:
|
|
97
|
+
variant: o ? "icon-logo" : "default",
|
|
99
98
|
"data-target-id": "IconButton-thumbsUpAriaLabel"
|
|
100
99
|
})
|
|
101
|
-
}), /* @__PURE__ */
|
|
102
|
-
isOpen:
|
|
103
|
-
onOpenChange:
|
|
104
|
-
onSubmit:
|
|
100
|
+
}), /* @__PURE__ */ i(ot, {
|
|
101
|
+
isOpen: x,
|
|
102
|
+
onOpenChange: N,
|
|
103
|
+
onSubmit: I,
|
|
105
104
|
shouldIncludeFeedbackText: w,
|
|
106
|
-
shouldIncludePromptShareConsent:
|
|
107
|
-
shouldShow:
|
|
108
|
-
children: /* @__PURE__ */
|
|
109
|
-
content:
|
|
110
|
-
children: /* @__PURE__ */
|
|
111
|
-
"aria-label":
|
|
112
|
-
className:
|
|
113
|
-
disabled:
|
|
114
|
-
icon:
|
|
115
|
-
onClick:
|
|
105
|
+
shouldIncludePromptShareConsent: B,
|
|
106
|
+
shouldShow: O,
|
|
107
|
+
children: /* @__PURE__ */ i(A, {
|
|
108
|
+
content: a(l.thumbsDownAriaLabel),
|
|
109
|
+
children: /* @__PURE__ */ i(L, {
|
|
110
|
+
"aria-label": a(l.thumbsDownAriaLabel),
|
|
111
|
+
className: o ? "" : lt.thumbDown,
|
|
112
|
+
disabled: n === m.THUMB_UP,
|
|
113
|
+
icon: n === m.THUMB_DOWN ? S : G,
|
|
114
|
+
onClick: P,
|
|
116
115
|
size: "x-small",
|
|
117
|
-
variant:
|
|
116
|
+
variant: o ? "icon-logo" : "default",
|
|
118
117
|
"data-target-id": "IconButton-thumbsDownAriaLabel"
|
|
119
118
|
})
|
|
120
119
|
})
|
|
@@ -122,6 +121,6 @@ import '../../../../styles/thumb-buttons.css';const ut = "_thumbDown_1axcd_1", r
|
|
|
122
121
|
});
|
|
123
122
|
};
|
|
124
123
|
export {
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
Bt as ThumbButtons,
|
|
125
|
+
Bt as default
|
|
127
126
|
};
|
|
@@ -1,248 +1,247 @@
|
|
|
1
|
-
import { useAgentsDispatch as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { A as
|
|
5
|
-
import { SET_NEW_ITEM as
|
|
6
|
-
import { QuestionRecord as
|
|
7
|
-
import {
|
|
8
|
-
import { getAnswerRequest as
|
|
1
|
+
import { useAgentsDispatch as ae, ACTIONS as le } from "@box/box-ai-agent-selector";
|
|
2
|
+
import ie from "lodash/camelCase";
|
|
3
|
+
import r, { useMemo as ce, useCallback as ue } from "react";
|
|
4
|
+
import { A as _, C as Ee, R as J } from "../../../../../chunks/types.js";
|
|
5
|
+
import { SET_NEW_ITEM as fe, UPDATE_QUESTION as Ce, SET_MODAL_ERROR as _e, SET_MODAL_SUCCESS as Te, SET_IS_LOADING as V, SET_ANSWER_FEEDBACK as Re, CLEAR_CONVERSATION_HISTORY as de, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as X, SET_SUGGESTED_QUESTIONS as Ae } from "../actions.js";
|
|
6
|
+
import { QuestionRecord as Ne } from "../records.js";
|
|
7
|
+
import { defaultFormatCitations as Oe, defaultFormatSuggestions as ye } from "../utils/format.js";
|
|
8
|
+
import { getAnswerRequest as Se } from "../utils/request.js";
|
|
9
9
|
import F from "../utils/stream.js";
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
contentAnswers:
|
|
13
|
-
createSessionRequest:
|
|
10
|
+
const Le = /Too Many Requests/i, Y = "Agent not found";
|
|
11
|
+
function Fe({
|
|
12
|
+
contentAnswers: i,
|
|
13
|
+
createSessionRequest: d,
|
|
14
14
|
dispatchStateUpdate: o,
|
|
15
15
|
enterpriseId: D,
|
|
16
|
-
fetchTimeout:
|
|
17
|
-
formatCitations: v =
|
|
18
|
-
getAnswerStreaming:
|
|
19
|
-
getAnswer:
|
|
20
|
-
getSuggestedQuestions:
|
|
21
|
-
isStopResponseEnabled:
|
|
22
|
-
isStreamingEnabled:
|
|
23
|
-
itemID:
|
|
24
|
-
items:
|
|
25
|
-
onSuggestedQuestionsFetched:
|
|
26
|
-
sendErrorLog:
|
|
27
|
-
shouldPreinitSession:
|
|
28
|
-
userId:
|
|
16
|
+
fetchTimeout: g,
|
|
17
|
+
formatCitations: v = Oe,
|
|
18
|
+
getAnswerStreaming: w,
|
|
19
|
+
getAnswer: j,
|
|
20
|
+
getSuggestedQuestions: k,
|
|
21
|
+
isStopResponseEnabled: x,
|
|
22
|
+
isStreamingEnabled: O,
|
|
23
|
+
itemID: u,
|
|
24
|
+
items: l,
|
|
25
|
+
onSuggestedQuestionsFetched: K,
|
|
26
|
+
sendErrorLog: m,
|
|
27
|
+
shouldPreinitSession: R = !0,
|
|
28
|
+
userId: P
|
|
29
29
|
}) {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
(
|
|
33
|
-
|
|
34
|
-
type:
|
|
35
|
-
itemID:
|
|
36
|
-
fileVersionID:
|
|
30
|
+
const A = r.useRef(null), W = ae(), y = ce(() => Array.isArray(l) && l.length > 1, [l]), $ = ue((e) => Array.isArray(e) ? v(e) : null, [v]);
|
|
31
|
+
r.useEffect(
|
|
32
|
+
(e) => {
|
|
33
|
+
u && u !== i.item.id && o({
|
|
34
|
+
type: fe,
|
|
35
|
+
itemID: u,
|
|
36
|
+
fileVersionID: e
|
|
37
37
|
});
|
|
38
38
|
},
|
|
39
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
40
|
-
[
|
|
40
|
+
[u]
|
|
41
41
|
);
|
|
42
|
-
const c =
|
|
42
|
+
const c = r.useCallback((e, s) => {
|
|
43
43
|
o({
|
|
44
|
-
type:
|
|
45
|
-
newQuestion:
|
|
46
|
-
session:
|
|
47
|
-
}),
|
|
48
|
-
}, [o]),
|
|
44
|
+
type: Ce,
|
|
45
|
+
newQuestion: e,
|
|
46
|
+
session: s
|
|
47
|
+
}), A.current = e;
|
|
48
|
+
}, [o]), B = r.useCallback((e) => {
|
|
49
49
|
o({
|
|
50
|
-
type:
|
|
51
|
-
error:
|
|
50
|
+
type: _e,
|
|
51
|
+
error: e
|
|
52
52
|
});
|
|
53
|
-
}, [o]),
|
|
53
|
+
}, [o]), I = r.useCallback((e, s, t) => {
|
|
54
54
|
const {
|
|
55
|
-
answer:
|
|
56
|
-
thinkingAnswer:
|
|
55
|
+
answer: a,
|
|
56
|
+
thinkingAnswer: E,
|
|
57
57
|
error: n,
|
|
58
|
-
citations:
|
|
59
|
-
createdAt:
|
|
58
|
+
citations: f = [],
|
|
59
|
+
createdAt: T = null,
|
|
60
60
|
encodedSession: C = void 0,
|
|
61
|
-
contextSession:
|
|
62
|
-
} =
|
|
63
|
-
answer:
|
|
64
|
-
thinkingAnswer:
|
|
61
|
+
contextSession: b = void 0
|
|
62
|
+
} = e, M = s.set("citations", $(f)).merge({
|
|
63
|
+
answer: a,
|
|
64
|
+
thinkingAnswer: E,
|
|
65
65
|
error: n,
|
|
66
|
-
created_at:
|
|
66
|
+
created_at: T,
|
|
67
67
|
isLoading: !1,
|
|
68
|
-
isCompleted:
|
|
68
|
+
isCompleted: t
|
|
69
69
|
});
|
|
70
|
-
let
|
|
71
|
-
C && (
|
|
70
|
+
let N;
|
|
71
|
+
C && (N = {
|
|
72
72
|
encodedSession: C
|
|
73
|
-
}),
|
|
74
|
-
contextSession:
|
|
75
|
-
}), c(
|
|
76
|
-
}, [c,
|
|
73
|
+
}), b && (N = {
|
|
74
|
+
contextSession: b
|
|
75
|
+
}), c(M, N);
|
|
76
|
+
}, [c, $]), G = r.useCallback(
|
|
77
77
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
78
|
-
(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
error: R,
|
|
78
|
+
(e, s) => {
|
|
79
|
+
const t = e?.message || "", a = e?.response?.status === 429 || Le.test(t), E = e?.code === Y || e?.errorCode === Y, n = e?.response?.status === 204, f = e?.response?.status === 412, T = n ? _.NO_CONTENT : a ? _.RATE_LIMITING : f ? _.PRECONDITION_FAILED : E ? _.AGENT_NOT_FOUND : _.GENERAL, C = s.merge({
|
|
80
|
+
error: T,
|
|
82
81
|
isLoading: !1,
|
|
83
82
|
isCompleted: !0
|
|
84
83
|
});
|
|
85
84
|
c(C, void 0);
|
|
86
85
|
},
|
|
87
86
|
[c]
|
|
88
|
-
),
|
|
87
|
+
), S = r.useCallback(async (e, s) => {
|
|
89
88
|
try {
|
|
90
|
-
const
|
|
91
|
-
prompt:
|
|
92
|
-
aiAgent:
|
|
93
|
-
userId:
|
|
89
|
+
const t = {
|
|
90
|
+
prompt: e.prompt,
|
|
91
|
+
aiAgent: s || void 0,
|
|
92
|
+
userId: P,
|
|
94
93
|
enterpriseId: D
|
|
95
|
-
},
|
|
96
|
-
let
|
|
97
|
-
|
|
98
|
-
const n = await
|
|
99
|
-
|
|
94
|
+
}, a = `content-answers-${e.id}`;
|
|
95
|
+
let E;
|
|
96
|
+
O && (E = F.createAbortRequest(a));
|
|
97
|
+
const n = await Se(t, O, a, u, l, i, j, w, E, g, m);
|
|
98
|
+
O ? F.receiveStreamedResponse(a, n, (f) => {
|
|
100
99
|
const {
|
|
101
|
-
code:
|
|
100
|
+
code: T,
|
|
102
101
|
data: C,
|
|
103
|
-
error:
|
|
104
|
-
citations:
|
|
105
|
-
contextSession:
|
|
106
|
-
isCompleted:
|
|
107
|
-
createdAt:
|
|
108
|
-
thinkingAnswer:
|
|
109
|
-
} =
|
|
110
|
-
thinkingAnswer:
|
|
102
|
+
error: b,
|
|
103
|
+
citations: M,
|
|
104
|
+
contextSession: N,
|
|
105
|
+
isCompleted: oe,
|
|
106
|
+
createdAt: re,
|
|
107
|
+
thinkingAnswer: ne
|
|
108
|
+
} = f, te = {
|
|
109
|
+
thinkingAnswer: ne,
|
|
111
110
|
answer: C,
|
|
112
|
-
citations:
|
|
113
|
-
error:
|
|
114
|
-
contextSession:
|
|
115
|
-
createdAt:
|
|
111
|
+
citations: M,
|
|
112
|
+
error: b,
|
|
113
|
+
contextSession: N,
|
|
114
|
+
createdAt: re
|
|
116
115
|
};
|
|
117
|
-
n.ok && n.status === 200 ?
|
|
118
|
-
...
|
|
119
|
-
},
|
|
116
|
+
n.ok && n.status === 200 ? I({
|
|
117
|
+
...te
|
|
118
|
+
}, e, oe) : G({
|
|
120
119
|
response: n,
|
|
121
|
-
code:
|
|
122
|
-
},
|
|
123
|
-
}, void 0,
|
|
124
|
-
const C =
|
|
125
|
-
delete n[
|
|
126
|
-
}),
|
|
127
|
-
} catch (
|
|
128
|
-
if (
|
|
129
|
-
const
|
|
130
|
-
error:
|
|
120
|
+
code: T
|
|
121
|
+
}, e);
|
|
122
|
+
}, void 0, g, m) : (Object.entries(n).forEach(([f, T]) => {
|
|
123
|
+
const C = ie(f);
|
|
124
|
+
delete n[f], n[C] = T;
|
|
125
|
+
}), I(n, e, !0));
|
|
126
|
+
} catch (t) {
|
|
127
|
+
if (x && t instanceof Error && t.name === "AbortError") {
|
|
128
|
+
const a = e.set("error", []).merge({
|
|
129
|
+
error: _.RESPONSE_STOPPED,
|
|
131
130
|
isLoading: !1,
|
|
132
131
|
isCompleted: !0
|
|
133
132
|
});
|
|
134
|
-
c(
|
|
133
|
+
c(a);
|
|
135
134
|
} else
|
|
136
|
-
|
|
135
|
+
G(t, e);
|
|
137
136
|
}
|
|
138
|
-
}, [
|
|
137
|
+
}, [P, D, O, u, l, i, j, w, g, m, I, G, x, c]), H = r.useCallback((e) => {
|
|
139
138
|
const {
|
|
140
|
-
encoded_session:
|
|
139
|
+
encoded_session: s,
|
|
141
140
|
metadata: {
|
|
142
|
-
is_large_file:
|
|
141
|
+
is_large_file: t
|
|
143
142
|
} = {
|
|
144
143
|
is_large_file: !1
|
|
145
144
|
}
|
|
146
|
-
} =
|
|
145
|
+
} = e;
|
|
147
146
|
o({
|
|
148
|
-
type:
|
|
149
|
-
encodedSession:
|
|
150
|
-
isLargeFile:
|
|
147
|
+
type: Te,
|
|
148
|
+
encodedSession: s,
|
|
149
|
+
isLargeFile: t
|
|
151
150
|
});
|
|
152
|
-
}, [o]),
|
|
151
|
+
}, [o]), Q = r.useCallback(async (e = !0, s = !0) => {
|
|
153
152
|
try {
|
|
154
|
-
|
|
155
|
-
type:
|
|
153
|
+
e && o({
|
|
154
|
+
type: V,
|
|
156
155
|
isLoading: !0
|
|
157
156
|
});
|
|
158
|
-
const
|
|
159
|
-
items:
|
|
160
|
-
},
|
|
161
|
-
|
|
157
|
+
const t = await d({
|
|
158
|
+
items: l
|
|
159
|
+
}, u);
|
|
160
|
+
H(t);
|
|
162
161
|
} catch {
|
|
163
|
-
if (
|
|
164
|
-
type:
|
|
162
|
+
if (s && B(Ee.GENERAL), !R && (o({
|
|
163
|
+
type: V,
|
|
165
164
|
isLoading: !1
|
|
166
|
-
}),
|
|
167
|
-
const
|
|
165
|
+
}), A.current)) {
|
|
166
|
+
const a = A.current.set("error", _.GENERAL).merge({
|
|
168
167
|
isLoading: !1,
|
|
169
168
|
isCompleted: !0
|
|
170
169
|
});
|
|
171
|
-
c(
|
|
170
|
+
c(a);
|
|
172
171
|
}
|
|
173
172
|
}
|
|
174
|
-
}, [
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
const n = new
|
|
178
|
-
return c(n),
|
|
179
|
-
}, [
|
|
173
|
+
}, [d, l, u, H, o, R, B, c]), p = r.useCallback((e, s, t = !0) => {
|
|
174
|
+
const a = !i.isLoading && !i.encodedSession && !y && d, E = i?.questions || [];
|
|
175
|
+
t && (e.id = `${E.length}`), !R && a && (e.error = _.GENERAL, e.isLoading = !1, e.isCompleted = !0);
|
|
176
|
+
const n = new Ne(e);
|
|
177
|
+
return c(n), R || i.encodedSession ? S(n, s) : !i.isLoading && !R && d && Q(!0, !1), n;
|
|
178
|
+
}, [i.encodedSession, i.isLoading, i?.questions, Q, d, y, S, R, c]), z = r.useCallback((e, s) => {
|
|
180
179
|
o({
|
|
181
|
-
type:
|
|
182
|
-
questionId:
|
|
183
|
-
feedbackValue:
|
|
180
|
+
type: Re,
|
|
181
|
+
questionId: e,
|
|
182
|
+
feedbackValue: s
|
|
184
183
|
});
|
|
185
|
-
}, [o]),
|
|
184
|
+
}, [o]), Z = r.useCallback(() => {
|
|
186
185
|
o({
|
|
187
|
-
type:
|
|
186
|
+
type: de
|
|
188
187
|
});
|
|
189
|
-
}, [o]),
|
|
190
|
-
|
|
191
|
-
...
|
|
188
|
+
}, [o]), q = r.useCallback(async (e, s) => {
|
|
189
|
+
p({
|
|
190
|
+
...e.toJS(),
|
|
192
191
|
answer: "",
|
|
193
192
|
isLoading: !0,
|
|
194
193
|
isCompleted: !1,
|
|
195
194
|
error: null
|
|
196
|
-
},
|
|
197
|
-
}, [
|
|
198
|
-
let
|
|
199
|
-
|
|
200
|
-
}, []), U =
|
|
201
|
-
|
|
202
|
-
type:
|
|
203
|
-
id:
|
|
204
|
-
ask:
|
|
195
|
+
}, s, !1);
|
|
196
|
+
}, [p]), h = r.useCallback((e) => {
|
|
197
|
+
let s;
|
|
198
|
+
e ? s = e.id : A.current && (s = A.current.id), s && F.abortRequest(`content-answers-${s}`, !0);
|
|
199
|
+
}, []), U = r.useCallback(async (e) => {
|
|
200
|
+
e && W({
|
|
201
|
+
type: le.SET_ASK_CONFIG,
|
|
202
|
+
id: e.id,
|
|
203
|
+
ask: e?.ask
|
|
205
204
|
});
|
|
206
|
-
}, [
|
|
207
|
-
|
|
208
|
-
if (!
|
|
205
|
+
}, [W]), [L, ee] = r.useState("");
|
|
206
|
+
r.useEffect(() => {
|
|
207
|
+
if (!l || l.length === 0)
|
|
209
208
|
return;
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
}, [
|
|
213
|
-
const
|
|
214
|
-
if (!(!
|
|
209
|
+
const e = l.map((s) => s.id).join(",");
|
|
210
|
+
e !== L && ee(e);
|
|
211
|
+
}, [l, L]);
|
|
212
|
+
const se = r.useCallback(async () => {
|
|
213
|
+
if (!(!L || !k || y)) {
|
|
215
214
|
o({
|
|
216
|
-
type:
|
|
217
|
-
requestState:
|
|
215
|
+
type: X,
|
|
216
|
+
requestState: J.IN_PROGRESS
|
|
218
217
|
});
|
|
219
218
|
try {
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
type:
|
|
223
|
-
suggestedQuestions:
|
|
219
|
+
const e = ye(await k(u, l));
|
|
220
|
+
K && K(e), o({
|
|
221
|
+
type: Ae,
|
|
222
|
+
suggestedQuestions: e
|
|
224
223
|
});
|
|
225
224
|
} catch {
|
|
226
225
|
o({
|
|
227
|
-
type:
|
|
228
|
-
requestState:
|
|
226
|
+
type: X,
|
|
227
|
+
requestState: J.ERROR
|
|
229
228
|
});
|
|
230
229
|
}
|
|
231
230
|
}
|
|
232
|
-
}, [o,
|
|
231
|
+
}, [o, k, y, u, L]);
|
|
233
232
|
return {
|
|
234
|
-
clearConversation:
|
|
235
|
-
createSession:
|
|
233
|
+
clearConversation: Z,
|
|
234
|
+
createSession: Q,
|
|
236
235
|
fetchAgentConfig: U,
|
|
237
|
-
fetchSuggestedQuestions:
|
|
238
|
-
retryQuestion:
|
|
239
|
-
sendQuestion:
|
|
240
|
-
sendQuestionAnswerRequest:
|
|
241
|
-
setAnswerFeedback:
|
|
236
|
+
fetchSuggestedQuestions: se,
|
|
237
|
+
retryQuestion: q,
|
|
238
|
+
sendQuestion: p,
|
|
239
|
+
sendQuestionAnswerRequest: S,
|
|
240
|
+
setAnswerFeedback: z,
|
|
242
241
|
stopQuestion: h,
|
|
243
242
|
updateQuestionInState: c
|
|
244
243
|
};
|
|
245
244
|
}
|
|
246
245
|
export {
|
|
247
|
-
|
|
246
|
+
Fe as useContentAnswers
|
|
248
247
|
};
|
|
@@ -26,7 +26,7 @@ const O = (t, s) => {
|
|
|
26
26
|
} = t, {
|
|
27
27
|
newQuestion: n,
|
|
28
28
|
session: u
|
|
29
|
-
} = s, r = [...e], i =
|
|
29
|
+
} = s, r = [...e], i = e?.findIndex((o) => o.id === n.id) ?? -1;
|
|
30
30
|
i >= 0 ? r[i] = n : r.push(n);
|
|
31
31
|
const {
|
|
32
32
|
isCompleted: S
|