@box/box-ai-content-answers 0.154.4 → 0.156.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/esm/lib/components/answer/constants.js +3 -3
- package/dist/esm/lib/components/answer/feedback-tooltip.js +87 -84
- package/dist/esm/lib/components/answer/messages.js +1 -1
- package/dist/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +113 -109
- package/dist/esm/lib/components/api-wrapper/records.js +10 -8
- package/dist/esm/lib/components/api-wrapper/utils/stream.js +27 -27
- package/dist/esm/lib/components/chat/chat.js +90 -84
- package/dist/esm/lib/components/thinkingBubble/boxAILoadingIndicator.js +235 -0
- package/dist/esm/lib/components/thinkingBubble/messages.js +26 -0
- package/dist/esm/lib/components/thinkingBubble/thinkingBubble.js +122 -0
- package/dist/i18n/bn-IN.js +5 -0
- package/dist/i18n/da-DK.js +5 -0
- package/dist/i18n/de-DE.js +5 -0
- package/dist/i18n/en-AU.js +5 -0
- package/dist/i18n/en-CA.js +5 -0
- package/dist/i18n/en-GB.js +5 -0
- package/dist/i18n/en-US.js +6 -1
- package/dist/i18n/en-US.properties +12 -2
- package/dist/i18n/en-x-pseudo.js +5 -0
- package/dist/i18n/es-419.js +5 -0
- package/dist/i18n/es-ES.js +5 -0
- package/dist/i18n/fi-FI.js +5 -0
- package/dist/i18n/fr-CA.js +5 -0
- package/dist/i18n/fr-FR.js +5 -0
- package/dist/i18n/hi-IN.js +5 -0
- package/dist/i18n/it-IT.js +5 -0
- package/dist/i18n/ja-JP.js +5 -0
- package/dist/i18n/json/src/lib/components/answer/messages.json +1 -1
- package/dist/i18n/json/src/lib/components/thinkingBubble/messages.json +1 -0
- package/dist/i18n/ko-KR.js +5 -0
- package/dist/i18n/nb-NO.js +5 -0
- package/dist/i18n/nl-NL.js +5 -0
- package/dist/i18n/pl-PL.js +5 -0
- package/dist/i18n/pt-BR.js +5 -0
- package/dist/i18n/ru-RU.js +5 -0
- package/dist/i18n/sv-SE.js +5 -0
- package/dist/i18n/tr-TR.js +5 -0
- package/dist/i18n/zh-CN.js +5 -0
- package/dist/i18n/zh-TW.js +5 -0
- package/dist/styles/boxAILoadingIndicator.css +1 -0
- package/dist/styles/feedback-tooltip.css +1 -1
- package/dist/styles/thinkingBubble.css +1 -0
- package/dist/types/lib/components/answer/constants.d.ts +1 -1
- package/dist/types/lib/components/api-wrapper/records.d.ts +1 -0
- package/dist/types/lib/components/api-wrapper/types.d.ts +1 -0
- package/dist/types/lib/components/thinkingBubble/boxAILoadingIndicator.d.ts +3 -0
- package/dist/types/lib/components/thinkingBubble/messages.d.ts +28 -0
- package/dist/types/lib/components/thinkingBubble/thinkingBubble.d.ts +26 -0
- package/dist/types/lib/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
import { Formik as
|
|
2
|
-
import { GuidedTooltip as l, Radio as c, TextArea as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import { F as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { jsx as e, jsxs as
|
|
9
|
-
import '../../../../styles/feedback-tooltip.css';const
|
|
10
|
-
feedbackTooltip:
|
|
11
|
-
feedbackTooltipForm:
|
|
12
|
-
feedbackTooltipTitle:
|
|
13
|
-
feedbackTooltipTextarea:
|
|
1
|
+
import { Formik as y, Form as F } from "formik";
|
|
2
|
+
import { GuidedTooltip as l, Radio as c, TextArea as g, Checkbox as x, Text as I, Link as L } from "@box/blueprint-web";
|
|
3
|
+
import { useIntl as P, FormattedMessage as v } from "react-intl";
|
|
4
|
+
import { F as p } from "../../../../chunks/types.js";
|
|
5
|
+
import { ABUSE_FORM_PATH as N } from "./constants.js";
|
|
6
|
+
import R from "../../messages.js";
|
|
7
|
+
import t from "./messages.js";
|
|
8
|
+
import { jsx as e, jsxs as r, Fragment as w } from "react/jsx-runtime";
|
|
9
|
+
import '../../../../styles/feedback-tooltip.css';const B = "_feedbackTooltip_1y93t_1", D = "_feedbackTooltipForm_1y93t_8", E = "_feedbackTooltipTitle_1y93t_12", U = "_feedbackTooltipTextarea_1y93t_15", O = "_feedbackTooltipSubmitBtn_1y93t_18", M = "_feedbackTooltipPromptShareConsent_1y93t_21", $ = "_feedbackTooltipAbuseDisclaimer_1y93t_24", j = "_feedbackTooltipAbuseLink_1y93t_28", a = {
|
|
10
|
+
feedbackTooltip: B,
|
|
11
|
+
feedbackTooltipForm: D,
|
|
12
|
+
feedbackTooltipTitle: E,
|
|
13
|
+
feedbackTooltipTextarea: U,
|
|
14
14
|
feedbackTooltipSubmitBtn: O,
|
|
15
15
|
feedbackTooltipPromptShareConsent: M,
|
|
16
|
-
feedbackTooltipAbuseDisclaimer:
|
|
17
|
-
feedbackTooltipAbuseLink:
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
feedbackTooltipAbuseDisclaimer: $,
|
|
17
|
+
feedbackTooltipAbuseLink: j
|
|
18
|
+
}, z = (s) => {
|
|
19
|
+
const n = encodeURIComponent(window.location.href);
|
|
20
|
+
return /* @__PURE__ */ e(L, {
|
|
21
|
+
className: a.feedbackTooltipAbuseLink,
|
|
22
|
+
href: `${N}/${n}`,
|
|
23
|
+
rel: "noopener noreferrer",
|
|
24
|
+
target: "_blank",
|
|
25
|
+
children: s
|
|
26
|
+
});
|
|
27
|
+
}, X = ({
|
|
28
|
+
children: s,
|
|
29
|
+
isOpen: n,
|
|
30
|
+
onOpenChange: T,
|
|
31
|
+
onSubmit: f,
|
|
32
|
+
shouldIncludeFeedbackText: m,
|
|
33
|
+
shouldIncludePromptShareConsent: u,
|
|
34
|
+
shouldShow: h
|
|
26
35
|
}) => {
|
|
27
36
|
const {
|
|
28
37
|
formatMessage: o
|
|
29
|
-
} =
|
|
30
|
-
if (!
|
|
31
|
-
return
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
}, A = (
|
|
35
|
-
|
|
38
|
+
} = P();
|
|
39
|
+
if (!h)
|
|
40
|
+
return s;
|
|
41
|
+
const _ = () => {
|
|
42
|
+
T(!1);
|
|
43
|
+
}, A = (d) => {
|
|
44
|
+
f(d);
|
|
36
45
|
};
|
|
37
46
|
return /* @__PURE__ */ e(l, {
|
|
38
47
|
align: "end",
|
|
39
|
-
className:
|
|
40
|
-
closeLabel: o(
|
|
41
|
-
content: /* @__PURE__ */ e(
|
|
48
|
+
className: a.feedbackTooltip,
|
|
49
|
+
closeLabel: o(R.closeButtonText),
|
|
50
|
+
content: /* @__PURE__ */ e(y, {
|
|
42
51
|
initialValues: {
|
|
43
52
|
feedback: "",
|
|
44
53
|
feedbackPromptShareConsent: !0,
|
|
@@ -47,97 +56,91 @@ import '../../../../styles/feedback-tooltip.css';const R = "_feedbackTooltip_hjx
|
|
|
47
56
|
},
|
|
48
57
|
onSubmit: A,
|
|
49
58
|
children: ({
|
|
50
|
-
submitForm:
|
|
51
|
-
setFieldValue:
|
|
59
|
+
submitForm: d,
|
|
60
|
+
setFieldValue: b,
|
|
52
61
|
values: {
|
|
53
62
|
feedback: C,
|
|
54
63
|
feedbackPromptShareConsent: S,
|
|
55
|
-
issueType:
|
|
64
|
+
issueType: k
|
|
56
65
|
}
|
|
57
|
-
}) => /* @__PURE__ */
|
|
58
|
-
children: [/* @__PURE__ */
|
|
66
|
+
}) => /* @__PURE__ */ r(w, {
|
|
67
|
+
children: [/* @__PURE__ */ r(l.Body, {
|
|
59
68
|
children: [/* @__PURE__ */ e(l.Title, {
|
|
60
|
-
className:
|
|
61
|
-
children: o(
|
|
62
|
-
}), /* @__PURE__ */
|
|
63
|
-
className:
|
|
69
|
+
className: a.feedbackTooltipTitle,
|
|
70
|
+
children: o(t.feedbackTooltipTitle)
|
|
71
|
+
}), /* @__PURE__ */ r(F, {
|
|
72
|
+
className: a.feedbackTooltipForm,
|
|
64
73
|
children: [/* @__PURE__ */ e(c.Legend, {
|
|
65
|
-
header: o(
|
|
66
|
-
children: /* @__PURE__ */
|
|
74
|
+
header: o(t.feedbackTooltipIssueTypeLabel),
|
|
75
|
+
children: /* @__PURE__ */ r(c.Group, {
|
|
67
76
|
defaultValue: "",
|
|
68
77
|
loop: !0,
|
|
69
78
|
name: "issueType",
|
|
70
|
-
onValueChange: (i) =>
|
|
79
|
+
onValueChange: (i) => b("issueType", i),
|
|
71
80
|
orientation: "vertical",
|
|
72
|
-
value:
|
|
81
|
+
value: k,
|
|
73
82
|
children: [/* @__PURE__ */ e(c.Item, {
|
|
74
|
-
label: o(
|
|
75
|
-
value:
|
|
83
|
+
label: o(t.feedbackTooltipIssueTypeAnswer1),
|
|
84
|
+
value: p.INACCURATE_ANSWER
|
|
76
85
|
}), /* @__PURE__ */ e(c.Item, {
|
|
77
|
-
label: o(
|
|
78
|
-
value:
|
|
86
|
+
label: o(t.feedbackTooltipIssueTypeAnswer2),
|
|
87
|
+
value: p.DID_NOT_FOLLOW_REQUEST
|
|
79
88
|
}), /* @__PURE__ */ e(c.Item, {
|
|
80
|
-
label: o(
|
|
81
|
-
value:
|
|
89
|
+
label: o(t.feedbackTooltipIssueTypeAnswer3),
|
|
90
|
+
value: p.OTHER
|
|
82
91
|
})]
|
|
83
92
|
})
|
|
84
|
-
}),
|
|
85
|
-
className:
|
|
86
|
-
label: o(
|
|
93
|
+
}), m && /* @__PURE__ */ e(g, {
|
|
94
|
+
className: a.feedbackTooltipTextarea,
|
|
95
|
+
label: o(t.feedbackTooltipFeedbackLabel),
|
|
87
96
|
maxRows: 4,
|
|
88
97
|
minRows: 4,
|
|
89
|
-
onChange: (i) =>
|
|
90
|
-
placeholder: o(
|
|
98
|
+
onChange: (i) => b("feedback", i.target.value),
|
|
99
|
+
placeholder: o(t.feedbackTooltipFeedbackPlaceholder),
|
|
91
100
|
value: C
|
|
92
|
-
}),
|
|
101
|
+
}), u && /* @__PURE__ */ e(x.Item, {
|
|
93
102
|
checked: S,
|
|
94
|
-
className:
|
|
103
|
+
className: a.feedbackTooltipPromptShareConsent,
|
|
95
104
|
"data-target-id": "Checkbox.Item-boxAiFeedbackPromptShareConsent",
|
|
96
|
-
label: o(
|
|
105
|
+
label: o(t.feedbackTooltipPromptShareConsent),
|
|
97
106
|
onCheckedChange: (i) => {
|
|
98
|
-
|
|
107
|
+
b("feedbackPromptShareConsent", i);
|
|
99
108
|
},
|
|
100
109
|
value: "feedbackPromptShareConsent"
|
|
101
|
-
}),
|
|
110
|
+
}), m && /* @__PURE__ */ e(I, {
|
|
102
111
|
as: "p",
|
|
103
|
-
className:
|
|
112
|
+
className: a.feedbackTooltipAbuseDisclaimer,
|
|
104
113
|
variant: "caption",
|
|
105
|
-
children: /* @__PURE__ */ e(
|
|
106
|
-
...
|
|
114
|
+
children: /* @__PURE__ */ e(v, {
|
|
115
|
+
...t.feedbackTooltipAbuseDisclaimer,
|
|
107
116
|
values: {
|
|
108
|
-
|
|
109
|
-
className: t.feedbackTooltipAbuseLink,
|
|
110
|
-
href: `mailto:${k}`,
|
|
111
|
-
rel: "noopener noreferrer",
|
|
112
|
-
target: "_blank",
|
|
113
|
-
children: k
|
|
114
|
-
})
|
|
117
|
+
abuseFormLink: z
|
|
115
118
|
}
|
|
116
119
|
})
|
|
117
120
|
})]
|
|
118
121
|
})]
|
|
119
|
-
}), /* @__PURE__ */
|
|
122
|
+
}), /* @__PURE__ */ r(l.Footer, {
|
|
120
123
|
children: [/* @__PURE__ */ e(l.Footer.SecondaryAction, {
|
|
121
|
-
onClick:
|
|
124
|
+
onClick: _,
|
|
122
125
|
size: "large",
|
|
123
|
-
children: o(
|
|
126
|
+
children: o(t.feedbackTooltipCancel)
|
|
124
127
|
}), /* @__PURE__ */ e(l.Footer.PrimaryAction, {
|
|
125
|
-
className:
|
|
126
|
-
disabled: !
|
|
127
|
-
onClick: () =>
|
|
128
|
+
className: a.feedbackTooltipSubmitBtn,
|
|
129
|
+
disabled: !k,
|
|
130
|
+
onClick: () => d(),
|
|
128
131
|
size: "large",
|
|
129
|
-
children: o(
|
|
132
|
+
children: o(t.feedbackTooltipSubmit)
|
|
130
133
|
})]
|
|
131
134
|
})]
|
|
132
135
|
})
|
|
133
136
|
}),
|
|
134
|
-
onOpenChange:
|
|
135
|
-
open:
|
|
137
|
+
onOpenChange: T,
|
|
138
|
+
open: n,
|
|
136
139
|
side: "left",
|
|
137
|
-
children:
|
|
140
|
+
children: s
|
|
138
141
|
});
|
|
139
142
|
};
|
|
140
143
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
144
|
+
X as FeedbackTooltip,
|
|
145
|
+
X as default
|
|
143
146
|
};
|
|
@@ -38,7 +38,7 @@ const t = e({
|
|
|
38
38
|
},
|
|
39
39
|
feedbackTooltipAbuseDisclaimer: {
|
|
40
40
|
id: "boxAI.contentAnswers.feedbackTooltipAbuseDisclaimer",
|
|
41
|
-
defaultMessage: "To report inappropriate content,
|
|
41
|
+
defaultMessage: "To report inappropriate content, submit <abuseFormLink>this form</abuseFormLink>."
|
|
42
42
|
},
|
|
43
43
|
feedbackTooltipFeedbackLabel: {
|
|
44
44
|
id: "boxAI.contentAnswers.feedbackTooltipFeedback",
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { useAgentsDispatch as as, ACTIONS as
|
|
1
|
+
import { useAgentsDispatch as as, ACTIONS as is } from "@box/box-ai-agent-selector";
|
|
2
2
|
import us from "lodash/camelCase";
|
|
3
|
-
import t, { useMemo as
|
|
4
|
-
import { A as
|
|
5
|
-
import { SET_NEW_ITEM as
|
|
6
|
-
import { QuestionRecord as
|
|
7
|
-
import { defaultFormatSuggestions as
|
|
8
|
-
import { getAnswerRequest as
|
|
3
|
+
import t, { useMemo as cs, useCallback as Es } from "react";
|
|
4
|
+
import { A as T, C as fs, R as V } from "../../../../../chunks/types.js";
|
|
5
|
+
import { SET_NEW_ITEM as rs, UPDATE_QUESTION as Cs, SET_MODAL_ERROR as _s, SET_MODAL_SUCCESS as Ts, SET_IS_LOADING as X, SET_ANSWER_FEEDBACK as Rs, CLEAR_CONVERSATION_HISTORY as ds, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as Y, SET_SUGGESTED_QUESTIONS as Ns } from "../actions.js";
|
|
6
|
+
import { QuestionRecord as Os } from "../records.js";
|
|
7
|
+
import { defaultFormatSuggestions as ys, defaultFormatCitations as Ss } from "../utils/format.js";
|
|
8
|
+
import { getAnswerRequest as As } from "../utils/request.js";
|
|
9
9
|
import F from "../utils/stream.js";
|
|
10
10
|
const Ls = /Too Many Requests/i, z = "Agent not found";
|
|
11
|
-
function
|
|
12
|
-
contentAnswers:
|
|
13
|
-
createSessionRequest:
|
|
11
|
+
function Fs({
|
|
12
|
+
contentAnswers: a,
|
|
13
|
+
createSessionRequest: y,
|
|
14
14
|
dispatchStateUpdate: o,
|
|
15
15
|
enterpriseId: D,
|
|
16
|
-
fetchTimeout:
|
|
17
|
-
formatCitations: v =
|
|
16
|
+
fetchTimeout: m,
|
|
17
|
+
formatCitations: v = Ss,
|
|
18
18
|
getAnswerStreaming: j,
|
|
19
19
|
getAnswer: x,
|
|
20
20
|
getSuggestedQuestions: I,
|
|
21
21
|
isStopResponseEnabled: K,
|
|
22
|
-
isStreamingEnabled:
|
|
22
|
+
isStreamingEnabled: A,
|
|
23
23
|
itemID: E,
|
|
24
|
-
items:
|
|
24
|
+
items: u,
|
|
25
25
|
onSuggestedQuestionsFetched: P,
|
|
26
|
-
sendErrorLog:
|
|
27
|
-
shouldPreinitSession:
|
|
26
|
+
sendErrorLog: g,
|
|
27
|
+
shouldPreinitSession: N = !0,
|
|
28
28
|
userId: W
|
|
29
29
|
}) {
|
|
30
|
-
const
|
|
30
|
+
const S = t.useRef(null), $ = as(), L = cs(() => Array.isArray(u) && u.length > 1, [u]), B = Es((s) => Array.isArray(s) ? v(s) : null, [v]);
|
|
31
31
|
t.useEffect(
|
|
32
32
|
(s) => {
|
|
33
|
-
E && E !==
|
|
34
|
-
type:
|
|
33
|
+
E && E !== a.item.id && o({
|
|
34
|
+
type: rs,
|
|
35
35
|
itemID: E,
|
|
36
36
|
fileVersionID: s
|
|
37
37
|
});
|
|
@@ -41,109 +41,113 @@ function Ms({
|
|
|
41
41
|
);
|
|
42
42
|
const c = t.useCallback((s, e) => {
|
|
43
43
|
o({
|
|
44
|
-
type:
|
|
44
|
+
type: Cs,
|
|
45
45
|
newQuestion: s,
|
|
46
46
|
session: e
|
|
47
|
-
}),
|
|
47
|
+
}), S.current = s;
|
|
48
48
|
}, [o]), H = t.useCallback((s) => {
|
|
49
49
|
o({
|
|
50
|
-
type:
|
|
50
|
+
type: _s,
|
|
51
51
|
error: s
|
|
52
52
|
});
|
|
53
|
-
}, [o]),
|
|
53
|
+
}, [o]), G = t.useCallback((s, e, l) => {
|
|
54
54
|
const {
|
|
55
|
-
answer:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
answer: i,
|
|
56
|
+
thinkingAnswer: f,
|
|
57
|
+
error: n,
|
|
58
|
+
citations: r = [],
|
|
59
|
+
createdAt: R = null,
|
|
59
60
|
encodedSession: C = void 0,
|
|
60
|
-
contextSession:
|
|
61
|
-
} = s,
|
|
62
|
-
answer:
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
contextSession: d = void 0
|
|
62
|
+
} = s, O = e.set("citations", B(r)).merge({
|
|
63
|
+
answer: i,
|
|
64
|
+
thinkingAnswer: f,
|
|
65
|
+
error: n,
|
|
66
|
+
created_at: R,
|
|
65
67
|
isLoading: !1,
|
|
66
|
-
isCompleted:
|
|
68
|
+
isCompleted: l
|
|
67
69
|
});
|
|
68
|
-
let
|
|
69
|
-
C && (
|
|
70
|
+
let _;
|
|
71
|
+
C && (_ = {
|
|
70
72
|
encodedSession: C
|
|
71
|
-
}),
|
|
72
|
-
contextSession:
|
|
73
|
-
}), c(
|
|
74
|
-
}, [c, B]),
|
|
73
|
+
}), d && (_ = {
|
|
74
|
+
contextSession: d
|
|
75
|
+
}), c(O, _);
|
|
76
|
+
}, [c, B]), Q = t.useCallback(
|
|
75
77
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
78
|
(s, e) => {
|
|
77
|
-
var
|
|
78
|
-
const
|
|
79
|
-
error:
|
|
79
|
+
var d, O, _;
|
|
80
|
+
const l = (s == null ? void 0 : s.message) || "", i = ((d = s == null ? void 0 : s.response) == null ? void 0 : d.status) === 429 || Ls.test(l), f = (s == null ? void 0 : s.code) === z || (s == null ? void 0 : s.errorCode) === z, n = ((O = s == null ? void 0 : s.response) == null ? void 0 : O.status) === 204, r = ((_ = s == null ? void 0 : s.response) == null ? void 0 : _.status) === 412, R = n ? T.NO_CONTENT : i ? T.RATE_LIMITING : r ? T.PRECONDITION_FAILED : f ? T.AGENT_NOT_FOUND : T.GENERAL, C = e.merge({
|
|
81
|
+
error: R,
|
|
80
82
|
isLoading: !1,
|
|
81
83
|
isCompleted: !0
|
|
82
84
|
});
|
|
83
|
-
c(
|
|
85
|
+
c(C, void 0);
|
|
84
86
|
},
|
|
85
87
|
[c]
|
|
86
|
-
),
|
|
88
|
+
), b = t.useCallback(async (s, e) => {
|
|
87
89
|
try {
|
|
88
|
-
const
|
|
90
|
+
const l = {
|
|
89
91
|
prompt: s.prompt,
|
|
90
92
|
aiAgent: e || void 0,
|
|
91
93
|
userId: W,
|
|
92
94
|
enterpriseId: D
|
|
93
|
-
},
|
|
95
|
+
}, i = `content-answers-${s.id}`;
|
|
94
96
|
let f;
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
97
|
+
A && (f = F.createAbortRequest(i));
|
|
98
|
+
const n = await As(l, A, i, E, u, a, x, j, f, m, g);
|
|
99
|
+
A ? F.receiveStreamedResponse(i, n, (r) => {
|
|
98
100
|
const {
|
|
99
|
-
code:
|
|
100
|
-
data:
|
|
101
|
-
error:
|
|
102
|
-
citations:
|
|
103
|
-
contextSession:
|
|
101
|
+
code: R,
|
|
102
|
+
data: C,
|
|
103
|
+
error: d,
|
|
104
|
+
citations: O,
|
|
105
|
+
contextSession: _,
|
|
104
106
|
isCompleted: os,
|
|
105
|
-
createdAt: ts
|
|
107
|
+
createdAt: ts,
|
|
108
|
+
thinkingAnswer: ns
|
|
106
109
|
} = r, ls = {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
110
|
+
thinkingAnswer: ns,
|
|
111
|
+
answer: C,
|
|
112
|
+
citations: O,
|
|
113
|
+
error: d,
|
|
114
|
+
contextSession: _,
|
|
111
115
|
createdAt: ts
|
|
112
116
|
};
|
|
113
|
-
|
|
117
|
+
n.ok && n.status === 200 ? G({
|
|
114
118
|
...ls
|
|
115
|
-
}, s, os) :
|
|
116
|
-
response:
|
|
117
|
-
code:
|
|
119
|
+
}, s, os) : Q({
|
|
120
|
+
response: n,
|
|
121
|
+
code: R
|
|
118
122
|
}, s);
|
|
119
|
-
}, void 0,
|
|
120
|
-
const
|
|
121
|
-
delete
|
|
122
|
-
}),
|
|
123
|
-
} catch (
|
|
124
|
-
if (K &&
|
|
125
|
-
const
|
|
126
|
-
error:
|
|
123
|
+
}, void 0, m, g) : (Object.entries(n).forEach(([r, R]) => {
|
|
124
|
+
const C = us(r);
|
|
125
|
+
delete n[r], n[C] = R;
|
|
126
|
+
}), G(n, s, !0));
|
|
127
|
+
} catch (l) {
|
|
128
|
+
if (K && l instanceof Error && l.name === "AbortError") {
|
|
129
|
+
const i = s.set("error", []).merge({
|
|
130
|
+
error: T.RESPONSE_STOPPED,
|
|
127
131
|
isLoading: !1,
|
|
128
132
|
isCompleted: !0
|
|
129
133
|
});
|
|
130
|
-
c(
|
|
134
|
+
c(i);
|
|
131
135
|
} else
|
|
132
|
-
|
|
136
|
+
Q(l, s);
|
|
133
137
|
}
|
|
134
|
-
}, [W, D,
|
|
138
|
+
}, [W, D, A, E, u, a, x, j, m, g, G, Q, K, c]), J = t.useCallback((s) => {
|
|
135
139
|
const {
|
|
136
140
|
encoded_session: e,
|
|
137
141
|
metadata: {
|
|
138
|
-
is_large_file:
|
|
142
|
+
is_large_file: l
|
|
139
143
|
} = {
|
|
140
144
|
is_large_file: !1
|
|
141
145
|
}
|
|
142
146
|
} = s;
|
|
143
147
|
o({
|
|
144
|
-
type:
|
|
148
|
+
type: Ts,
|
|
145
149
|
encodedSession: e,
|
|
146
|
-
isLargeFile:
|
|
150
|
+
isLargeFile: l
|
|
147
151
|
});
|
|
148
152
|
}, [o]), p = t.useCallback(async (s = !0, e = !0) => {
|
|
149
153
|
try {
|
|
@@ -151,36 +155,36 @@ function Ms({
|
|
|
151
155
|
type: X,
|
|
152
156
|
isLoading: !0
|
|
153
157
|
});
|
|
154
|
-
const
|
|
155
|
-
items:
|
|
158
|
+
const l = await y({
|
|
159
|
+
items: u
|
|
156
160
|
}, E);
|
|
157
|
-
J(
|
|
161
|
+
J(l);
|
|
158
162
|
} catch {
|
|
159
|
-
if (e && H(
|
|
163
|
+
if (e && H(fs.GENERAL), !N && (o({
|
|
160
164
|
type: X,
|
|
161
165
|
isLoading: !1
|
|
162
|
-
}),
|
|
163
|
-
const
|
|
166
|
+
}), S.current)) {
|
|
167
|
+
const i = S.current.set("error", T.GENERAL).merge({
|
|
164
168
|
isLoading: !1,
|
|
165
169
|
isCompleted: !0
|
|
166
170
|
});
|
|
167
|
-
c(
|
|
171
|
+
c(i);
|
|
168
172
|
}
|
|
169
173
|
}
|
|
170
|
-
}, [
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
return c(
|
|
175
|
-
}, [
|
|
174
|
+
}, [y, u, E, J, o, N, H, c]), M = t.useCallback((s, e, l = !0) => {
|
|
175
|
+
const i = !a.isLoading && !a.encodedSession && !L && y, f = (a == null ? void 0 : a.questions) || [];
|
|
176
|
+
l && (s.id = `${f.length}`), !N && i && (s.error = T.GENERAL, s.isLoading = !1, s.isCompleted = !0);
|
|
177
|
+
const n = new Os(s);
|
|
178
|
+
return c(n), N || a.encodedSession ? b(n, e) : !a.isLoading && !N && y && p(!0, !1), n;
|
|
179
|
+
}, [a.encodedSession, a.isLoading, a == null ? void 0 : a.questions, p, y, L, b, N, c]), Z = t.useCallback((s, e) => {
|
|
176
180
|
o({
|
|
177
|
-
type:
|
|
181
|
+
type: Rs,
|
|
178
182
|
questionId: s,
|
|
179
183
|
feedbackValue: e
|
|
180
184
|
});
|
|
181
185
|
}, [o]), q = t.useCallback(() => {
|
|
182
186
|
o({
|
|
183
|
-
type:
|
|
187
|
+
type: ds
|
|
184
188
|
});
|
|
185
189
|
}, [o]), w = t.useCallback(async (s, e) => {
|
|
186
190
|
M({
|
|
@@ -190,32 +194,32 @@ function Ms({
|
|
|
190
194
|
isCompleted: !1,
|
|
191
195
|
error: null
|
|
192
196
|
}, e, !1);
|
|
193
|
-
}, [M]),
|
|
197
|
+
}, [M]), h = t.useCallback((s) => {
|
|
194
198
|
let e;
|
|
195
|
-
s ? e = s.id :
|
|
196
|
-
}, []),
|
|
199
|
+
s ? e = s.id : S.current && (e = S.current.id), e && F.abortRequest(`content-answers-${e}`, !0);
|
|
200
|
+
}, []), U = t.useCallback(async (s) => {
|
|
197
201
|
s && $({
|
|
198
|
-
type:
|
|
202
|
+
type: is.SET_ASK_CONFIG,
|
|
199
203
|
id: s.id,
|
|
200
204
|
ask: s == null ? void 0 : s.ask
|
|
201
205
|
});
|
|
202
|
-
}, [$]), [
|
|
206
|
+
}, [$]), [k, ss] = t.useState("");
|
|
203
207
|
t.useEffect(() => {
|
|
204
|
-
if (!
|
|
208
|
+
if (!u || u.length === 0)
|
|
205
209
|
return;
|
|
206
|
-
const s =
|
|
207
|
-
s !==
|
|
208
|
-
}, [
|
|
210
|
+
const s = u.map((e) => e.id).join(",");
|
|
211
|
+
s !== k && ss(s);
|
|
212
|
+
}, [u, k]);
|
|
209
213
|
const es = t.useCallback(async () => {
|
|
210
|
-
if (!(!
|
|
214
|
+
if (!(!k || !I || L)) {
|
|
211
215
|
o({
|
|
212
216
|
type: Y,
|
|
213
217
|
requestState: V.IN_PROGRESS
|
|
214
218
|
});
|
|
215
219
|
try {
|
|
216
|
-
const s =
|
|
220
|
+
const s = ys(await I(E, u));
|
|
217
221
|
P && P(s), o({
|
|
218
|
-
type:
|
|
222
|
+
type: Ns,
|
|
219
223
|
suggestedQuestions: s
|
|
220
224
|
});
|
|
221
225
|
} catch {
|
|
@@ -225,20 +229,20 @@ function Ms({
|
|
|
225
229
|
});
|
|
226
230
|
}
|
|
227
231
|
}
|
|
228
|
-
}, [o, I, L, E,
|
|
232
|
+
}, [o, I, L, E, k]);
|
|
229
233
|
return {
|
|
230
234
|
clearConversation: q,
|
|
231
235
|
createSession: p,
|
|
232
|
-
fetchAgentConfig:
|
|
236
|
+
fetchAgentConfig: U,
|
|
233
237
|
fetchSuggestedQuestions: es,
|
|
234
238
|
retryQuestion: w,
|
|
235
239
|
sendQuestion: M,
|
|
236
|
-
sendQuestionAnswerRequest:
|
|
240
|
+
sendQuestionAnswerRequest: b,
|
|
237
241
|
setAnswerFeedback: Z,
|
|
238
|
-
stopQuestion:
|
|
242
|
+
stopQuestion: h,
|
|
239
243
|
updateQuestionInState: c
|
|
240
244
|
};
|
|
241
245
|
}
|
|
242
246
|
export {
|
|
243
|
-
|
|
247
|
+
Fs as useContentAnswers
|
|
244
248
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { Record as e } from "immutable";
|
|
2
|
-
import { R as
|
|
2
|
+
import { R as n, U as s } from "../../../../chunks/types.js";
|
|
3
3
|
const o = e({
|
|
4
4
|
has_streamed_responses: !0,
|
|
5
|
-
has_citations_enabled: !1
|
|
5
|
+
has_citations_enabled: !1,
|
|
6
|
+
has_thinking_enabled: !1
|
|
6
7
|
}), t = e({
|
|
7
8
|
type: "file",
|
|
8
9
|
id: null,
|
|
9
10
|
version_id: null
|
|
10
11
|
}), r = e({
|
|
11
12
|
suggestions: [],
|
|
12
|
-
requestState:
|
|
13
|
-
}),
|
|
13
|
+
requestState: n.NOT_STARTED
|
|
14
|
+
}), a = e({
|
|
14
15
|
config: new o(),
|
|
15
16
|
encodedSession: null,
|
|
16
17
|
contextSession: null,
|
|
@@ -21,22 +22,23 @@ const o = e({
|
|
|
21
22
|
questions: [],
|
|
22
23
|
shouldShowLandingPage: !0,
|
|
23
24
|
suggestedQuestions: new r()
|
|
24
|
-
}),
|
|
25
|
+
}), u = e({
|
|
25
26
|
answer: null,
|
|
26
27
|
citations: [],
|
|
27
28
|
created_at: null,
|
|
28
29
|
id: null,
|
|
29
30
|
isCompleted: !1,
|
|
31
|
+
thinkingAnswer: null,
|
|
30
32
|
isLoading: !0,
|
|
31
33
|
error: null,
|
|
32
34
|
prompt: null,
|
|
33
35
|
feedbackValue: "none",
|
|
34
|
-
promptType:
|
|
36
|
+
promptType: s
|
|
35
37
|
});
|
|
36
38
|
export {
|
|
37
39
|
o as ContentAnswersConfigRecord,
|
|
38
40
|
t as ContentAnswersItemRecord,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
a as ContentAnswersRecord,
|
|
42
|
+
u as QuestionRecord,
|
|
41
43
|
r as SuggestedQuestionsRecord
|
|
42
44
|
};
|