@box/box-ai-content-answers 0.58.6 → 0.60.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/esm/lib/box-ai-content-answers.js +33 -31
- package/esm/lib/components/api-wrapper/content-answers-component.js +47 -45
- package/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +109 -100
- package/esm/lib/components/footer/footer-actions.js +19 -18
- package/esm/lib/components/footer/footer.js +42 -40
- package/esm/lib/components/modal/modal.js +49 -47
- package/i18n/bn-IN.js +1 -1
- package/i18n/bn-IN.properties +1 -1
- package/i18n/da-DK.js +1 -1
- package/i18n/da-DK.properties +1 -1
- package/i18n/de-DE.js +1 -1
- package/i18n/de-DE.properties +1 -1
- package/i18n/en-x-pseudo.js +50 -50
- package/i18n/en-x-pseudo.properties +50 -50
- package/i18n/es-419.js +1 -1
- package/i18n/es-419.properties +1 -1
- package/i18n/es-ES.js +1 -1
- package/i18n/es-ES.properties +1 -1
- package/i18n/fi-FI.js +1 -1
- package/i18n/fi-FI.properties +1 -1
- package/i18n/fr-CA.js +1 -1
- package/i18n/fr-CA.properties +1 -1
- package/i18n/fr-FR.js +1 -1
- package/i18n/fr-FR.properties +1 -1
- package/i18n/hi-IN.js +1 -1
- package/i18n/hi-IN.properties +1 -1
- package/i18n/it-IT.js +1 -1
- package/i18n/it-IT.properties +1 -1
- package/i18n/ja-JP.js +2 -2
- package/i18n/ja-JP.properties +2 -2
- package/i18n/ko-KR.js +1 -1
- package/i18n/ko-KR.properties +1 -1
- package/i18n/nb-NO.js +1 -1
- package/i18n/nb-NO.properties +1 -1
- package/i18n/nl-NL.js +1 -1
- package/i18n/nl-NL.properties +1 -1
- package/i18n/pl-PL.js +1 -1
- package/i18n/pl-PL.properties +1 -1
- package/i18n/pt-BR.js +1 -1
- package/i18n/pt-BR.properties +1 -1
- package/i18n/ru-RU.js +1 -1
- package/i18n/ru-RU.properties +1 -1
- package/i18n/sv-SE.js +1 -1
- package/i18n/sv-SE.properties +1 -1
- package/i18n/tr-TR.js +1 -1
- package/i18n/tr-TR.properties +1 -1
- package/i18n/zh-CN.js +1 -1
- package/i18n/zh-CN.properties +1 -1
- package/i18n/zh-TW.js +1 -1
- package/i18n/zh-TW.properties +1 -1
- package/package.json +3 -3
- package/types/lib/components/api-wrapper/content-answers-component.d.ts +1 -1
- package/types/lib/components/api-wrapper/hooks/useContentAnswers.d.ts +1 -1
- package/types/lib/components/api-wrapper/types.d.ts +1 -0
- package/types/lib/components/footer/footer-actions.d.ts +2 -1
- package/types/lib/components/footer/footer.d.ts +3 -1
- package/types/lib/components/modal/modal.d.ts +1 -0
- package/types/lib/types.d.ts +2 -0
|
@@ -1,42 +1,43 @@
|
|
|
1
1
|
import "../../styles/box-ai-content-answers.css";
|
|
2
|
-
import
|
|
2
|
+
import k from "clsx";
|
|
3
3
|
import * as s from "react";
|
|
4
|
-
import { AgentEditor as
|
|
5
|
-
import { Content as
|
|
6
|
-
import { Footer as
|
|
7
|
-
import { jsx as n, jsxs as
|
|
8
|
-
const
|
|
9
|
-
container:
|
|
10
|
-
contentAnswers:
|
|
11
|
-
},
|
|
4
|
+
import { AgentEditor as C } from "./components/agents/agent-editor.js";
|
|
5
|
+
import { Content as F } from "./components/content/content.js";
|
|
6
|
+
import { Footer as N } from "./components/footer/footer.js";
|
|
7
|
+
import { jsx as n, jsxs as y } from "react/jsx-runtime";
|
|
8
|
+
const B = "_container_hi5vt_1", R = "_contentAnswers_hi5vt_5", w = {
|
|
9
|
+
container: B,
|
|
10
|
+
contentAnswers: R
|
|
11
|
+
}, U = ({
|
|
12
12
|
className: S,
|
|
13
13
|
contentType: u,
|
|
14
14
|
error: t,
|
|
15
15
|
hasRequestInProgress: c,
|
|
16
16
|
isAgentSelectorEnabled: h,
|
|
17
17
|
isDebugModeEnabled: A,
|
|
18
|
+
isStopResponseEnabled: M,
|
|
18
19
|
isStreamingEnabled: o,
|
|
19
20
|
userInfo: l,
|
|
20
21
|
questions: i,
|
|
21
22
|
recordAction: r,
|
|
22
|
-
retryQuestion:
|
|
23
|
+
retryQuestion: Q,
|
|
23
24
|
showLoadingIndicator: a,
|
|
24
|
-
stopQuestion:
|
|
25
|
-
submitQuestion:
|
|
26
|
-
suggestedQuestions:
|
|
27
|
-
useAnimation:
|
|
28
|
-
onAgentEditorToggle:
|
|
29
|
-
...
|
|
25
|
+
stopQuestion: _,
|
|
26
|
+
submitQuestion: x,
|
|
27
|
+
suggestedQuestions: b,
|
|
28
|
+
useAnimation: v,
|
|
29
|
+
onAgentEditorToggle: D,
|
|
30
|
+
...E
|
|
30
31
|
}) => {
|
|
31
|
-
const [m, g] = s.useState(null), [f, d] = s.useState(t != null), [e, p] = s.useState(!1),
|
|
32
|
+
const [m, g] = s.useState(null), [f, d] = s.useState(t != null), [e, p] = s.useState(!1), j = !f && !a;
|
|
32
33
|
return s.useEffect(() => {
|
|
33
34
|
d(t != null);
|
|
34
35
|
}, [t]), /* @__PURE__ */ n("div", {
|
|
35
|
-
className:
|
|
36
|
-
children: /* @__PURE__ */
|
|
36
|
+
className: k(S, w.container),
|
|
37
|
+
children: /* @__PURE__ */ y("div", {
|
|
37
38
|
className: w.contentAnswers,
|
|
38
|
-
children: [!e && /* @__PURE__ */ n(
|
|
39
|
-
...
|
|
39
|
+
children: [!e && /* @__PURE__ */ n(F, {
|
|
40
|
+
...E,
|
|
40
41
|
askSuggestedQuestion: m,
|
|
41
42
|
contentType: u,
|
|
42
43
|
error: t,
|
|
@@ -48,26 +49,27 @@ const y = "_container_hi5vt_1", B = "_contentAnswers_hi5vt_5", w = {
|
|
|
48
49
|
setAskSuggestedQuestion: g,
|
|
49
50
|
setIsErrorMessageShown: d,
|
|
50
51
|
showLoadingIndicator: a,
|
|
51
|
-
suggestedQuestions:
|
|
52
|
-
useAnimation: o &&
|
|
52
|
+
suggestedQuestions: b,
|
|
53
|
+
useAnimation: o && v,
|
|
53
54
|
userInfo: l
|
|
54
|
-
}), e && /* @__PURE__ */ n(
|
|
55
|
-
onAgentEditorToggle:
|
|
55
|
+
}), e && /* @__PURE__ */ n(C, {
|
|
56
|
+
onAgentEditorToggle: D,
|
|
56
57
|
recordAction: r,
|
|
57
58
|
setIsDebugModeShown: p
|
|
58
|
-
}),
|
|
59
|
+
}), j && /* @__PURE__ */ n(N, {
|
|
59
60
|
askSuggestedQuestion: m,
|
|
60
61
|
contentType: u,
|
|
61
62
|
enableDebugMode: A,
|
|
62
63
|
hasRequestInProgress: c,
|
|
63
64
|
isAgentSelectorEnabled: h,
|
|
64
65
|
isDebugModeShown: e,
|
|
66
|
+
isStopResponseEnabled: M,
|
|
65
67
|
isStreamingEnabled: o,
|
|
66
68
|
lastQuestion: i[i.length - 1],
|
|
67
|
-
onRetryQuestion:
|
|
68
|
-
onStopQuestion:
|
|
69
|
+
onRetryQuestion: Q,
|
|
70
|
+
onStopQuestion: _,
|
|
69
71
|
recordAction: r,
|
|
70
|
-
sendQuestion:
|
|
72
|
+
sendQuestion: x,
|
|
71
73
|
setAskSuggestedQuestion: g,
|
|
72
74
|
toggleDebugMode: () => {
|
|
73
75
|
p(!e);
|
|
@@ -78,6 +80,6 @@ const y = "_container_hi5vt_1", B = "_contentAnswers_hi5vt_5", w = {
|
|
|
78
80
|
});
|
|
79
81
|
};
|
|
80
82
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
U as BoxAiContentAnswers,
|
|
84
|
+
U as default
|
|
83
85
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { useReducer as
|
|
1
|
+
import { useReducer as F, useEffect as G } from "react";
|
|
2
2
|
import { R as d } from "../../../../chunks/types.js";
|
|
3
|
-
import { useContentAnswers as
|
|
4
|
-
import { ContentAnswersRecord as
|
|
5
|
-
import
|
|
6
|
-
import { jsx as
|
|
7
|
-
const
|
|
3
|
+
import { useContentAnswers as H } from "./hooks/useContentAnswers.js";
|
|
4
|
+
import { ContentAnswersRecord as I, ContentAnswersItemRecord as J } from "./records.js";
|
|
5
|
+
import K from "./reducer.js";
|
|
6
|
+
import { jsx as M } from "react/jsx-runtime";
|
|
7
|
+
const te = ({
|
|
8
8
|
WrappedComponent: a,
|
|
9
9
|
createSessionRequest: f,
|
|
10
10
|
getAgentConfig: m,
|
|
@@ -20,29 +20,30 @@ const ee = ({
|
|
|
20
20
|
isMarkdownEnabled: w,
|
|
21
21
|
isOpen: s,
|
|
22
22
|
isResetChatEnabled: Q,
|
|
23
|
+
isStopResponseEnabled: T,
|
|
23
24
|
isStreamingEnabled: r,
|
|
24
25
|
itemID: o,
|
|
25
|
-
onCloseModal:
|
|
26
|
-
suggestedQuestions:
|
|
27
|
-
warningNotice:
|
|
28
|
-
warningNoticeAriaLabel:
|
|
26
|
+
onCloseModal: h,
|
|
27
|
+
suggestedQuestions: q,
|
|
28
|
+
warningNotice: E,
|
|
29
|
+
warningNoticeAriaLabel: j
|
|
29
30
|
}) => {
|
|
30
|
-
const [c,
|
|
31
|
-
item: new
|
|
31
|
+
const [c, v] = F(K, new I({
|
|
32
|
+
item: new J({
|
|
32
33
|
id: o
|
|
33
34
|
})
|
|
34
35
|
})), {
|
|
35
|
-
clearConversation:
|
|
36
|
-
createSession:
|
|
36
|
+
clearConversation: U,
|
|
37
|
+
createSession: _,
|
|
37
38
|
fetchAgentConfig: u,
|
|
38
39
|
fetchSuggestedQuestions: i,
|
|
39
|
-
retryQuestion:
|
|
40
|
-
sendQuestion:
|
|
41
|
-
stopQuestion:
|
|
42
|
-
} =
|
|
40
|
+
retryQuestion: x,
|
|
41
|
+
sendQuestion: P,
|
|
42
|
+
stopQuestion: y
|
|
43
|
+
} = H({
|
|
43
44
|
contentAnswers: c,
|
|
44
45
|
createSessionRequest: f,
|
|
45
|
-
dispatchStateUpdate:
|
|
46
|
+
dispatchStateUpdate: v,
|
|
46
47
|
fetchTimeout: g,
|
|
47
48
|
formatCitations: S,
|
|
48
49
|
getAgentConfig: m,
|
|
@@ -50,53 +51,54 @@ const ee = ({
|
|
|
50
51
|
getAnswer: A,
|
|
51
52
|
getSuggestedQuestions: t,
|
|
52
53
|
isCitationsEnabled: n,
|
|
54
|
+
isStopResponseEnabled: T,
|
|
53
55
|
isStreamingEnabled: r,
|
|
54
56
|
itemID: o
|
|
55
57
|
}), {
|
|
56
|
-
encodedSession:
|
|
57
|
-
error:
|
|
58
|
-
isLoading:
|
|
59
|
-
hasRequestInProgress:
|
|
60
|
-
questions:
|
|
58
|
+
encodedSession: L,
|
|
59
|
+
error: N,
|
|
60
|
+
isLoading: O,
|
|
61
|
+
hasRequestInProgress: b = !1,
|
|
62
|
+
questions: k,
|
|
61
63
|
suggestedQuestions: e
|
|
62
64
|
} = c;
|
|
63
|
-
|
|
65
|
+
G(() => {
|
|
64
66
|
s && e.requestState === d.NOT_STARTED && i();
|
|
65
67
|
}, [s, i, e.requestState]);
|
|
66
|
-
const
|
|
67
|
-
createSession:
|
|
68
|
-
encodedSession:
|
|
69
|
-
error:
|
|
68
|
+
const z = {
|
|
69
|
+
createSession: _,
|
|
70
|
+
encodedSession: L,
|
|
71
|
+
error: N,
|
|
70
72
|
hostAppName: R,
|
|
71
|
-
hasRequestInProgress:
|
|
73
|
+
hasRequestInProgress: b,
|
|
72
74
|
isAgentSelectorEnabled: C,
|
|
73
75
|
isCitationsEnabled: n,
|
|
74
76
|
isDebugModeEnabled: l,
|
|
75
77
|
isMarkdownEnabled: w,
|
|
76
|
-
isLoading:
|
|
78
|
+
isLoading: O,
|
|
77
79
|
isOpen: s,
|
|
78
80
|
isResetChatEnabled: Q,
|
|
79
81
|
isStreamingEnabled: r,
|
|
80
82
|
itemID: o,
|
|
81
|
-
onClearAction:
|
|
82
|
-
onCloseModal:
|
|
83
|
+
onClearAction: U,
|
|
84
|
+
onCloseModal: h,
|
|
83
85
|
onSelectAgent: u,
|
|
84
86
|
onAgentEditorToggle: u,
|
|
85
|
-
questions:
|
|
86
|
-
retryQuestion:
|
|
87
|
-
sendQuestion:
|
|
87
|
+
questions: k,
|
|
88
|
+
retryQuestion: x,
|
|
89
|
+
sendQuestion: P,
|
|
88
90
|
shouldRenderProviders: !1,
|
|
89
|
-
stopQuestion:
|
|
91
|
+
stopQuestion: y,
|
|
90
92
|
suggestedQuestionsRequestState: t ? e.requestState : d.SUCCESS,
|
|
91
|
-
suggestedQuestions: t ? e.suggestions :
|
|
92
|
-
warningNotice:
|
|
93
|
-
warningNoticeAriaLabel:
|
|
94
|
-
},
|
|
95
|
-
return /* @__PURE__ */
|
|
96
|
-
...
|
|
93
|
+
suggestedQuestions: t ? e.suggestions : q,
|
|
94
|
+
warningNotice: E,
|
|
95
|
+
warningNoticeAriaLabel: j
|
|
96
|
+
}, B = Object.fromEntries(Object.entries(z).filter(([V, D]) => D !== void 0));
|
|
97
|
+
return /* @__PURE__ */ M(a, {
|
|
98
|
+
...B
|
|
97
99
|
});
|
|
98
100
|
};
|
|
99
101
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
te as ContentAnswersComponent,
|
|
103
|
+
te as default
|
|
102
104
|
};
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t, { useCallback as
|
|
3
|
-
import { useAgentsDispatch as
|
|
4
|
-
import { A as
|
|
5
|
-
import { SET_NEW_ITEM as
|
|
6
|
-
import { QuestionRecord as
|
|
7
|
-
import { defaultFormatSuggestions as
|
|
8
|
-
import { getAnswerRequest as
|
|
9
|
-
import
|
|
1
|
+
import X from "lodash/camelCase";
|
|
2
|
+
import t, { useCallback as Y } from "react";
|
|
3
|
+
import { useAgentsDispatch as z } from "../../../contexts/AgentsContext.js";
|
|
4
|
+
import { A as T, C as B, R as F } from "../../../../../chunks/types.js";
|
|
5
|
+
import { SET_NEW_ITEM as Z, UPDATE_QUESTION as h, SET_MODAL_ERROR as w, SET_MODAL_SUCCESS as U, SET_IS_LOADING as ss, CLEAR_CONVERSATION_HISTORY as es, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as q, SET_SUGGESTED_QUESTIONS as os } from "../actions.js";
|
|
6
|
+
import { QuestionRecord as ts } from "../records.js";
|
|
7
|
+
import { defaultFormatSuggestions as as, defaultFormatCitations as ns } from "../utils/format.js";
|
|
8
|
+
import { getAnswerRequest as rs } from "../utils/request.js";
|
|
9
|
+
import Q from "../utils/stream.js";
|
|
10
10
|
const is = /Too Many Requests/i;
|
|
11
|
-
function
|
|
12
|
-
contentAnswers:
|
|
13
|
-
createSessionRequest:
|
|
11
|
+
function Ss({
|
|
12
|
+
contentAnswers: r,
|
|
13
|
+
createSessionRequest: p,
|
|
14
14
|
dispatchStateUpdate: o,
|
|
15
15
|
fetchTimeout: O,
|
|
16
|
-
getAgentConfig:
|
|
16
|
+
getAgentConfig: S,
|
|
17
17
|
getAnswerStreaming: k,
|
|
18
|
-
getAnswer:
|
|
19
|
-
getSuggestedQuestions:
|
|
18
|
+
getAnswer: A,
|
|
19
|
+
getSuggestedQuestions: d,
|
|
20
20
|
isCitationsEnabled: us,
|
|
21
|
-
|
|
21
|
+
isStopResponseEnabled: G,
|
|
22
|
+
isStreamingEnabled: m,
|
|
22
23
|
itemID: u,
|
|
23
24
|
formatCitations: I = ns
|
|
24
25
|
}) {
|
|
25
|
-
const
|
|
26
|
+
const j = t.useRef(null), g = z(), P = Y((s) => Array.isArray(s) ? I(s) : null, [I]);
|
|
26
27
|
t.useEffect(
|
|
27
28
|
(s) => {
|
|
28
|
-
u && u !==
|
|
29
|
-
type:
|
|
29
|
+
u && u !== r.item.id && o({
|
|
30
|
+
type: Z,
|
|
30
31
|
itemID: u,
|
|
31
32
|
fileVersionID: s
|
|
32
33
|
});
|
|
@@ -34,121 +35,129 @@ function Os({
|
|
|
34
35
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
35
36
|
[u]
|
|
36
37
|
);
|
|
37
|
-
const
|
|
38
|
+
const E = t.useCallback((s, e) => {
|
|
38
39
|
o({
|
|
39
|
-
type:
|
|
40
|
+
type: h,
|
|
40
41
|
newQuestion: s,
|
|
41
42
|
session: e
|
|
42
|
-
}),
|
|
43
|
+
}), j.current = s;
|
|
43
44
|
}, [o]), M = t.useCallback((s) => {
|
|
44
45
|
o({
|
|
45
|
-
type:
|
|
46
|
+
type: w,
|
|
46
47
|
error: s
|
|
47
48
|
});
|
|
48
|
-
}, [o]),
|
|
49
|
+
}, [o]), N = t.useCallback((s, e, a) => {
|
|
49
50
|
const {
|
|
50
|
-
answer:
|
|
51
|
+
answer: i,
|
|
51
52
|
error: l,
|
|
52
53
|
citations: n = [],
|
|
53
|
-
createdAt:
|
|
54
|
-
encodedSession:
|
|
54
|
+
createdAt: f = null,
|
|
55
|
+
encodedSession: C = void 0,
|
|
55
56
|
contextSession: c = void 0
|
|
56
|
-
} = s,
|
|
57
|
-
answer:
|
|
57
|
+
} = s, R = e.set("citations", P(n)).merge({
|
|
58
|
+
answer: i,
|
|
58
59
|
error: l,
|
|
59
|
-
created_at:
|
|
60
|
+
created_at: f,
|
|
60
61
|
isLoading: !1,
|
|
61
|
-
isCompleted:
|
|
62
|
+
isCompleted: a
|
|
62
63
|
});
|
|
63
|
-
let
|
|
64
|
-
|
|
65
|
-
encodedSession:
|
|
66
|
-
}), c && (
|
|
64
|
+
let _;
|
|
65
|
+
C && (_ = {
|
|
66
|
+
encodedSession: C
|
|
67
|
+
}), c && (_ = {
|
|
67
68
|
contextSession: c
|
|
68
|
-
}), R
|
|
69
|
-
}, [
|
|
69
|
+
}), E(R, _);
|
|
70
|
+
}, [E, P]), y = t.useCallback(
|
|
70
71
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
71
72
|
(s, e) => {
|
|
72
|
-
var c,
|
|
73
|
-
const
|
|
74
|
-
error:
|
|
73
|
+
var c, R, _;
|
|
74
|
+
const a = (s == null ? void 0 : s.message) || "", i = ((c = s == null ? void 0 : s.response) == null ? void 0 : c.status) === 429 || is.test(a), l = ((R = s == null ? void 0 : s.response) == null ? void 0 : R.status) === 204, n = ((_ = s == null ? void 0 : s.response) == null ? void 0 : _.status) === 412, f = l ? T.NO_CONTENT : i ? T.RATE_LIMITING : n ? T.PRECONDITION_FAILED : T.GENERAL, C = e.merge({
|
|
75
|
+
error: f,
|
|
75
76
|
isLoading: !1,
|
|
76
77
|
isCompleted: !0
|
|
77
78
|
});
|
|
78
|
-
|
|
79
|
+
E(C, void 0);
|
|
79
80
|
},
|
|
80
|
-
[
|
|
81
|
+
[E]
|
|
81
82
|
), b = t.useCallback(async (s, e) => {
|
|
82
83
|
try {
|
|
83
|
-
const
|
|
84
|
+
const a = {
|
|
84
85
|
prompt: s.prompt,
|
|
85
86
|
aiAgent: e || void 0
|
|
86
|
-
},
|
|
87
|
+
}, i = `content-answers-${s.id}`;
|
|
87
88
|
let l;
|
|
88
|
-
|
|
89
|
-
const n = await
|
|
90
|
-
|
|
89
|
+
m && (l = Q.createAbortRequest(i));
|
|
90
|
+
const n = await rs(a, m, i, u, r, A, k, l, O);
|
|
91
|
+
m ? n.ok && n.status === 200 ? Q.receiveStreamedResponse(i, n, (f) => {
|
|
91
92
|
const {
|
|
92
|
-
data:
|
|
93
|
+
data: C,
|
|
93
94
|
error: c,
|
|
94
|
-
citations:
|
|
95
|
-
contextSession:
|
|
96
|
-
isCompleted:
|
|
97
|
-
createdAt:
|
|
98
|
-
} =
|
|
99
|
-
|
|
95
|
+
citations: R,
|
|
96
|
+
contextSession: _,
|
|
97
|
+
isCompleted: J,
|
|
98
|
+
createdAt: K
|
|
99
|
+
} = f;
|
|
100
|
+
N({
|
|
100
101
|
...{
|
|
101
|
-
answer:
|
|
102
|
-
citations:
|
|
102
|
+
answer: C,
|
|
103
|
+
citations: R,
|
|
103
104
|
error: c,
|
|
104
|
-
contextSession:
|
|
105
|
-
createdAt:
|
|
105
|
+
contextSession: _,
|
|
106
|
+
createdAt: K
|
|
106
107
|
}
|
|
107
|
-
}, s,
|
|
108
|
-
}, void 0, O) :
|
|
108
|
+
}, s, J);
|
|
109
|
+
}, void 0, O) : y({
|
|
109
110
|
response: n
|
|
110
|
-
}, s) : (Object.entries(n).forEach(([
|
|
111
|
-
const c =
|
|
112
|
-
delete n[
|
|
113
|
-
}),
|
|
114
|
-
} catch (
|
|
115
|
-
|
|
111
|
+
}, s) : (Object.entries(n).forEach(([f, C]) => {
|
|
112
|
+
const c = X(f);
|
|
113
|
+
delete n[f], n[c] = C;
|
|
114
|
+
}), N(n, s, !0));
|
|
115
|
+
} catch (a) {
|
|
116
|
+
if (G && a instanceof Error && a.name === "AbortError") {
|
|
117
|
+
const i = s.set("error", []).merge({
|
|
118
|
+
error: T.RESPONSE_STOPPED,
|
|
119
|
+
isLoading: !1,
|
|
120
|
+
isCompleted: !0
|
|
121
|
+
});
|
|
122
|
+
E(i);
|
|
123
|
+
} else
|
|
124
|
+
y(a, s);
|
|
116
125
|
}
|
|
117
|
-
}, [
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
const l = new
|
|
121
|
-
return
|
|
122
|
-
}, [
|
|
126
|
+
}, [m, u, r, A, k, O, N, y, G]), L = t.useCallback((s, e, a = !0) => {
|
|
127
|
+
const i = (r == null ? void 0 : r.questions) || [];
|
|
128
|
+
a && (s.id = `${i.length}`);
|
|
129
|
+
const l = new ts(s);
|
|
130
|
+
return E(l), b(l, e), l;
|
|
131
|
+
}, [r == null ? void 0 : r.questions, b, E]), v = t.useCallback((s) => {
|
|
123
132
|
const {
|
|
124
133
|
encoded_session: e,
|
|
125
134
|
metadata: {
|
|
126
|
-
is_large_file:
|
|
135
|
+
is_large_file: a
|
|
127
136
|
} = {
|
|
128
137
|
is_large_file: !1
|
|
129
138
|
}
|
|
130
139
|
} = s;
|
|
131
140
|
o({
|
|
132
|
-
type:
|
|
141
|
+
type: U,
|
|
133
142
|
encodedSession: e,
|
|
134
|
-
isLargeFile:
|
|
143
|
+
isLargeFile: a
|
|
135
144
|
});
|
|
136
|
-
}, [o]),
|
|
145
|
+
}, [o]), x = t.useCallback(async () => {
|
|
137
146
|
try {
|
|
138
147
|
o({
|
|
139
|
-
type:
|
|
148
|
+
type: ss,
|
|
140
149
|
isLoading: !0
|
|
141
150
|
});
|
|
142
|
-
const s = await
|
|
143
|
-
items: [
|
|
151
|
+
const s = await p({
|
|
152
|
+
items: [r.item]
|
|
144
153
|
}, u);
|
|
145
154
|
v(s);
|
|
146
155
|
} catch {
|
|
147
|
-
M(
|
|
156
|
+
M(B.GENERAL);
|
|
148
157
|
}
|
|
149
|
-
}, [o,
|
|
158
|
+
}, [o, p, r.item, u, v, M]), D = t.useCallback(() => {
|
|
150
159
|
o({
|
|
151
|
-
type:
|
|
160
|
+
type: es
|
|
152
161
|
});
|
|
153
162
|
}, [o]), $ = t.useCallback(async (s, e) => {
|
|
154
163
|
L({
|
|
@@ -158,29 +167,29 @@ function Os({
|
|
|
158
167
|
isCompleted: !1,
|
|
159
168
|
error: null
|
|
160
169
|
}, e, !1);
|
|
161
|
-
}, [L]),
|
|
162
|
-
|
|
163
|
-
}, []),
|
|
164
|
-
if (
|
|
170
|
+
}, [L]), V = t.useCallback((s) => {
|
|
171
|
+
Q.abortRequest(`content-answers-${s.id}`, !0);
|
|
172
|
+
}, []), W = t.useCallback(async (s) => {
|
|
173
|
+
if (S)
|
|
165
174
|
try {
|
|
166
|
-
const e = await
|
|
167
|
-
|
|
175
|
+
const e = await S(s);
|
|
176
|
+
g({
|
|
168
177
|
type: "OVERRIDE_AGENT_CONFIG",
|
|
169
178
|
agentName: s.name,
|
|
170
179
|
agentConfig: e
|
|
171
180
|
});
|
|
172
181
|
} catch {
|
|
173
182
|
}
|
|
174
|
-
}, [
|
|
175
|
-
if (
|
|
183
|
+
}, [g, S]), H = t.useCallback(async () => {
|
|
184
|
+
if (d) {
|
|
176
185
|
o({
|
|
177
186
|
type: q,
|
|
178
187
|
requestState: F.IN_PROGRESS
|
|
179
188
|
});
|
|
180
189
|
try {
|
|
181
|
-
const s =
|
|
190
|
+
const s = as(await d(u));
|
|
182
191
|
o({
|
|
183
|
-
type:
|
|
192
|
+
type: os,
|
|
184
193
|
suggestedQuestions: s
|
|
185
194
|
});
|
|
186
195
|
} catch {
|
|
@@ -190,19 +199,19 @@ function Os({
|
|
|
190
199
|
});
|
|
191
200
|
}
|
|
192
201
|
}
|
|
193
|
-
}, [o,
|
|
202
|
+
}, [o, d, u]);
|
|
194
203
|
return {
|
|
195
|
-
clearConversation:
|
|
196
|
-
createSession:
|
|
197
|
-
fetchAgentConfig:
|
|
198
|
-
fetchSuggestedQuestions:
|
|
204
|
+
clearConversation: D,
|
|
205
|
+
createSession: x,
|
|
206
|
+
fetchAgentConfig: W,
|
|
207
|
+
fetchSuggestedQuestions: H,
|
|
199
208
|
retryQuestion: $,
|
|
200
209
|
sendQuestion: L,
|
|
201
210
|
sendQuestionAnswerRequest: b,
|
|
202
|
-
stopQuestion:
|
|
203
|
-
updateQuestionInState:
|
|
211
|
+
stopQuestion: V,
|
|
212
|
+
updateQuestionInState: E
|
|
204
213
|
};
|
|
205
214
|
}
|
|
206
215
|
export {
|
|
207
|
-
|
|
216
|
+
Ss as useContentAnswers
|
|
208
217
|
};
|
|
@@ -1,50 +1,51 @@
|
|
|
1
1
|
import "../../../../styles/footer-actions.css";
|
|
2
2
|
import { Button as l } from "@box/blueprint-web";
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useIntl as
|
|
3
|
+
import { useRef as O, useCallback as p, useEffect as w } from "react";
|
|
4
|
+
import { useIntl as y } from "react-intl";
|
|
5
5
|
import { A as m } from "../../../../chunks/types.js";
|
|
6
6
|
import { LOGGER_BASE_CONFIG as u, LOGGER_ACTION_CLICK as R } from "../common/constants.js";
|
|
7
7
|
import d from "./messages.js";
|
|
8
|
-
import { jsxs as
|
|
9
|
-
const
|
|
10
|
-
footerActions:
|
|
11
|
-
footerActionButton:
|
|
12
|
-
},
|
|
13
|
-
|
|
8
|
+
import { jsxs as g, jsx as E } from "react/jsx-runtime";
|
|
9
|
+
const k = "_footerActions_poeou_1", v = "_footerActionButton_poeou_11", a = {
|
|
10
|
+
footerActions: k,
|
|
11
|
+
footerActionButton: v
|
|
12
|
+
}, z = ({
|
|
13
|
+
isStopResponseEnabled: _ = !1,
|
|
14
|
+
isStreamingEnabled: B = !1,
|
|
14
15
|
lastQuestion: o,
|
|
15
16
|
onRetryQuestion: s,
|
|
16
17
|
onStopQuestion: c,
|
|
17
18
|
recordAction: t
|
|
18
19
|
}) => {
|
|
19
20
|
const {
|
|
20
|
-
answer:
|
|
21
|
+
answer: S,
|
|
21
22
|
error: n,
|
|
22
|
-
isCompleted:
|
|
23
|
-
} = o, e = s && n && n !== m.RESPONSE_STOPPED && n !== m.RESPONSE_INTERRUPTED, i =
|
|
23
|
+
isCompleted: h
|
|
24
|
+
} = o, e = s && n && n !== m.RESPONSE_STOPPED && n !== m.RESPONSE_INTERRUPTED, i = B && !h && (_ || S), A = i || e, r = O(null), {
|
|
24
25
|
formatMessage: f
|
|
25
|
-
} =
|
|
26
|
+
} = y(), C = p(() => {
|
|
26
27
|
t && t({
|
|
27
28
|
...u,
|
|
28
29
|
action: R,
|
|
29
30
|
target: "stopResponse"
|
|
30
31
|
}), c(o);
|
|
31
|
-
}, [o, c, t]),
|
|
32
|
+
}, [o, c, t]), N = p(() => {
|
|
32
33
|
t && t({
|
|
33
34
|
...u,
|
|
34
35
|
action: R,
|
|
35
36
|
target: "retryResponse"
|
|
36
37
|
}), s(o);
|
|
37
38
|
}, [o, s, t]);
|
|
38
|
-
return
|
|
39
|
+
return w(() => {
|
|
39
40
|
e && r.current && r.current.focus();
|
|
40
|
-
}, [e]),
|
|
41
|
+
}, [e]), A ? /* @__PURE__ */ g("div", {
|
|
41
42
|
className: a.footerActions,
|
|
42
43
|
"data-testid": "content-answers-modal-footer-actions",
|
|
43
44
|
children: [i && /* @__PURE__ */ E(l, {
|
|
44
45
|
"aria-live": "polite",
|
|
45
46
|
className: a.footerActionButton,
|
|
46
47
|
"data-testid": "content-answers-stop-response-button",
|
|
47
|
-
onClick:
|
|
48
|
+
onClick: C,
|
|
48
49
|
size: "large",
|
|
49
50
|
variant: "secondary",
|
|
50
51
|
children: f(d.stopResponse)
|
|
@@ -53,7 +54,7 @@ const g = "_footerActions_poeou_1", k = "_footerActionButton_poeou_11", a = {
|
|
|
53
54
|
"aria-live": "polite",
|
|
54
55
|
className: a.footerActionButton,
|
|
55
56
|
"data-testid": "content-answers-retry-response-button",
|
|
56
|
-
onClick:
|
|
57
|
+
onClick: N,
|
|
57
58
|
size: "large",
|
|
58
59
|
variant: "secondary",
|
|
59
60
|
children: f(d.retryResponse)
|
|
@@ -61,5 +62,5 @@ const g = "_footerActions_poeou_1", k = "_footerActionButton_poeou_11", a = {
|
|
|
61
62
|
}) : null;
|
|
62
63
|
};
|
|
63
64
|
export {
|
|
64
|
-
|
|
65
|
+
z as FooterActions
|
|
65
66
|
};
|