@box/box-ai-content-answers 0.64.2 → 0.65.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 +37 -35
- package/esm/lib/components/api-wrapper/constants.js +6 -4
- package/esm/lib/components/api-wrapper/content-answers-component.js +71 -66
- package/esm/lib/components/common/agentUtils.js +9 -0
- package/esm/lib/components/footer/footer.js +97 -87
- package/esm/lib/components/modal/modal.js +104 -87
- package/package.json +6 -4
- package/styles/modal.css +1 -1
- package/types/lib/components/api-wrapper/content-answers-component.d.ts +1 -1
- package/types/lib/components/api-wrapper/types.d.ts +9 -0
- package/types/lib/components/common/agentUtils.d.ts +1 -0
- package/types/lib/components/common/constants.d.ts +2 -5
- package/types/lib/components/footer/footer.d.ts +8 -2
- package/types/lib/components/modal/modal.d.ts +10 -1
- package/types/lib/types.d.ts +19 -4
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
import "../../styles/box-ai-content-answers.css";
|
|
2
|
-
import
|
|
2
|
+
import C 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 F } from "./components/agents/agent-editor.js";
|
|
5
|
+
import { Content as N } from "./components/content/content.js";
|
|
6
|
+
import { Footer as y } from "./components/footer/footer.js";
|
|
7
|
+
import { jsx as n, jsxs as B } from "react/jsx-runtime";
|
|
8
|
+
const R = "_container_hi5vt_1", z = "_contentAnswers_hi5vt_5", w = {
|
|
9
|
+
container: R,
|
|
10
|
+
contentAnswers: z
|
|
11
|
+
}, V = ({
|
|
12
12
|
className: S,
|
|
13
13
|
contentType: u,
|
|
14
14
|
error: t,
|
|
15
15
|
hasRequestInProgress: c,
|
|
16
16
|
isAgentSelectorEnabled: h,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
isAIStudioAgentSelectorEnabled: A,
|
|
18
|
+
isDebugModeEnabled: M,
|
|
19
|
+
isStopResponseEnabled: Q,
|
|
19
20
|
isStreamingEnabled: o,
|
|
20
21
|
userInfo: l,
|
|
21
22
|
questions: i,
|
|
22
23
|
recordAction: r,
|
|
23
|
-
retryQuestion:
|
|
24
|
+
retryQuestion: _,
|
|
24
25
|
showLoadingIndicator: a,
|
|
25
|
-
stopQuestion:
|
|
26
|
-
submitQuestion:
|
|
27
|
-
suggestedQuestions:
|
|
28
|
-
useAnimation:
|
|
29
|
-
onAgentEditorToggle:
|
|
30
|
-
...
|
|
26
|
+
stopQuestion: x,
|
|
27
|
+
submitQuestion: b,
|
|
28
|
+
suggestedQuestions: v,
|
|
29
|
+
useAnimation: D,
|
|
30
|
+
onAgentEditorToggle: E,
|
|
31
|
+
...j
|
|
31
32
|
}) => {
|
|
32
|
-
const [m, g] = s.useState(null), [f, d] = s.useState(t != null), [e, p] = s.useState(!1),
|
|
33
|
+
const [m, g] = s.useState(null), [f, d] = s.useState(t != null), [e, p] = s.useState(!1), k = !f && !a;
|
|
33
34
|
return s.useEffect(() => {
|
|
34
35
|
d(t != null);
|
|
35
36
|
}, [t]), /* @__PURE__ */ n("div", {
|
|
36
|
-
className:
|
|
37
|
-
children: /* @__PURE__ */
|
|
37
|
+
className: C(S, w.container),
|
|
38
|
+
children: /* @__PURE__ */ B("div", {
|
|
38
39
|
className: w.contentAnswers,
|
|
39
|
-
children: [!e && /* @__PURE__ */ n(
|
|
40
|
-
...
|
|
40
|
+
children: [!e && /* @__PURE__ */ n(N, {
|
|
41
|
+
...j,
|
|
41
42
|
askSuggestedQuestion: m,
|
|
42
43
|
contentType: u,
|
|
43
44
|
error: t,
|
|
@@ -49,27 +50,28 @@ const B = "_container_hi5vt_1", R = "_contentAnswers_hi5vt_5", w = {
|
|
|
49
50
|
setAskSuggestedQuestion: g,
|
|
50
51
|
setIsErrorMessageShown: d,
|
|
51
52
|
showLoadingIndicator: a,
|
|
52
|
-
suggestedQuestions:
|
|
53
|
-
useAnimation: o &&
|
|
53
|
+
suggestedQuestions: v,
|
|
54
|
+
useAnimation: o && D,
|
|
54
55
|
userInfo: l
|
|
55
|
-
}), e && /* @__PURE__ */ n(
|
|
56
|
-
onAgentEditorToggle:
|
|
56
|
+
}), e && /* @__PURE__ */ n(F, {
|
|
57
|
+
onAgentEditorToggle: E,
|
|
57
58
|
recordAction: r,
|
|
58
59
|
setIsDebugModeShown: p
|
|
59
|
-
}),
|
|
60
|
+
}), k && /* @__PURE__ */ n(y, {
|
|
60
61
|
askSuggestedQuestion: m,
|
|
61
62
|
contentType: u,
|
|
62
|
-
enableDebugMode:
|
|
63
|
+
enableDebugMode: M,
|
|
63
64
|
hasRequestInProgress: c,
|
|
64
65
|
isAgentSelectorEnabled: h,
|
|
66
|
+
isAIStudioAgentSelectorEnabled: A,
|
|
65
67
|
isDebugModeShown: e,
|
|
66
|
-
isStopResponseEnabled:
|
|
68
|
+
isStopResponseEnabled: Q,
|
|
67
69
|
isStreamingEnabled: o,
|
|
68
70
|
lastQuestion: i[i.length - 1],
|
|
69
|
-
onRetryQuestion:
|
|
70
|
-
onStopQuestion:
|
|
71
|
+
onRetryQuestion: _,
|
|
72
|
+
onStopQuestion: x,
|
|
71
73
|
recordAction: r,
|
|
72
|
-
sendQuestion:
|
|
74
|
+
sendQuestion: b,
|
|
73
75
|
setAskSuggestedQuestion: g,
|
|
74
76
|
toggleDebugMode: () => {
|
|
75
77
|
p(!e);
|
|
@@ -80,6 +82,6 @@ const B = "_container_hi5vt_1", R = "_contentAnswers_hi5vt_5", w = {
|
|
|
80
82
|
});
|
|
81
83
|
};
|
|
82
84
|
export {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
V as BoxAiContentAnswers,
|
|
86
|
+
V as default
|
|
85
87
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const i = (e) => ({
|
|
2
2
|
ask: {
|
|
3
3
|
type: "ai_agent_ask",
|
|
4
4
|
longText: {
|
|
@@ -15,15 +15,17 @@ const o = (e) => ({
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}), t = (e, _ = null, n = !1) => ({
|
|
18
|
+
id: _,
|
|
18
19
|
name: e,
|
|
19
|
-
config: _ ?
|
|
20
|
+
config: _ ? i(_) : null,
|
|
20
21
|
isDefault: n,
|
|
22
|
+
isEnterpriseDefault: n,
|
|
21
23
|
isSelected: n
|
|
22
|
-
}), a = [t("Box (default)", null, !0), t("Box (gpt-3.5-turbo)", "azure__openai__gpt_3_5_turbo_16k"), t("Box (gpt-4o)", "openai__gpt_4o_2024_05_13"), t("Box (gemini 1.5 flash", "google__gemini_1_5_flash_001"), t("Box (gemini 1.5 pro)", "google__gemini_1_5_pro_001"), t("Box (claude 3 sonnet)", "aws__claude_3_sonnet"), t("Box (claude 3.5 sonnet)", "aws__claude_3_5_sonnet"), t("Box (claude 3 haiku)", "aws__claude_3_haiku"), t("Box (titan text lite)", "aws__titan_text_lite"), t("Box (titan text express)", "aws__titan_text_express")],
|
|
24
|
+
}), a = [t("Box (default)", null, !0), t("Box (gpt-3.5-turbo)", "azure__openai__gpt_3_5_turbo_16k"), t("Box (gpt-4o)", "openai__gpt_4o_2024_05_13"), t("Box (gemini 1.5 flash", "google__gemini_1_5_flash_001"), t("Box (gemini 1.5 pro)", "google__gemini_1_5_pro_001"), t("Box (claude 3 sonnet)", "aws__claude_3_sonnet"), t("Box (claude 3.5 sonnet)", "aws__claude_3_5_sonnet"), t("Box (claude 3 haiku)", "aws__claude_3_haiku"), t("Box (titan text lite)", "aws__titan_text_lite"), t("Box (titan text express)", "aws__titan_text_express")], o = {
|
|
23
25
|
agents: a,
|
|
24
26
|
selectedAgent: a.find((e) => e.isSelected)
|
|
25
27
|
};
|
|
26
28
|
export {
|
|
27
29
|
a as agentList,
|
|
28
|
-
|
|
30
|
+
o as agentState
|
|
29
31
|
};
|
|
@@ -1,104 +1,109 @@
|
|
|
1
|
-
import { useReducer as
|
|
2
|
-
import { R as
|
|
3
|
-
import { useContentAnswers as
|
|
4
|
-
import { ContentAnswersRecord as
|
|
5
|
-
import
|
|
6
|
-
import { jsx as
|
|
7
|
-
const
|
|
8
|
-
WrappedComponent:
|
|
1
|
+
import { useReducer as I, useEffect as J } from "react";
|
|
2
|
+
import { R as a } from "../../../../chunks/types.js";
|
|
3
|
+
import { useContentAnswers as K } from "./hooks/useContentAnswers.js";
|
|
4
|
+
import { ContentAnswersRecord as M, ContentAnswersItemRecord as V } from "./records.js";
|
|
5
|
+
import W from "./reducer.js";
|
|
6
|
+
import { jsx as X } from "react/jsx-runtime";
|
|
7
|
+
const ne = ({
|
|
8
|
+
WrappedComponent: d,
|
|
9
9
|
createSessionRequest: f,
|
|
10
10
|
getAgentConfig: m,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
getAIStudioAgents: g,
|
|
12
|
+
fetchTimeout: S,
|
|
13
|
+
formatCitations: A,
|
|
14
|
+
getAnswer: p,
|
|
15
|
+
getAnswerStreaming: C,
|
|
15
16
|
getSuggestedQuestions: t,
|
|
16
17
|
hostAppName: R,
|
|
17
|
-
isAgentSelectorEnabled:
|
|
18
|
+
isAgentSelectorEnabled: w,
|
|
19
|
+
isAIStudioAgentSelectorEnabled: l,
|
|
18
20
|
isCitationsEnabled: n,
|
|
19
|
-
isDebugModeEnabled:
|
|
20
|
-
isMarkdownEnabled:
|
|
21
|
+
isDebugModeEnabled: Q,
|
|
22
|
+
isMarkdownEnabled: T,
|
|
21
23
|
isOpen: s,
|
|
22
|
-
isResetChatEnabled:
|
|
23
|
-
isStopResponseEnabled:
|
|
24
|
+
isResetChatEnabled: q,
|
|
25
|
+
isStopResponseEnabled: E,
|
|
24
26
|
isStreamingEnabled: r,
|
|
25
27
|
itemID: o,
|
|
26
28
|
onCloseModal: h,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
shouldRenderProviders: j = !1,
|
|
30
|
+
suggestedQuestions: U,
|
|
31
|
+
warningNotice: _,
|
|
32
|
+
warningNoticeAriaLabel: v
|
|
30
33
|
}) => {
|
|
31
|
-
const [c,
|
|
32
|
-
item: new
|
|
34
|
+
const [c, x] = I(W, new M({
|
|
35
|
+
item: new V({
|
|
33
36
|
id: o
|
|
34
37
|
})
|
|
35
38
|
})), {
|
|
36
|
-
clearConversation:
|
|
37
|
-
createSession:
|
|
39
|
+
clearConversation: y,
|
|
40
|
+
createSession: L,
|
|
38
41
|
fetchAgentConfig: u,
|
|
39
42
|
fetchSuggestedQuestions: i,
|
|
40
|
-
retryQuestion:
|
|
41
|
-
sendQuestion:
|
|
42
|
-
stopQuestion:
|
|
43
|
-
} =
|
|
43
|
+
retryQuestion: N,
|
|
44
|
+
sendQuestion: O,
|
|
45
|
+
stopQuestion: P
|
|
46
|
+
} = K({
|
|
44
47
|
contentAnswers: c,
|
|
45
48
|
createSessionRequest: f,
|
|
46
|
-
dispatchStateUpdate:
|
|
47
|
-
fetchTimeout:
|
|
48
|
-
formatCitations:
|
|
49
|
+
dispatchStateUpdate: x,
|
|
50
|
+
fetchTimeout: S,
|
|
51
|
+
formatCitations: A,
|
|
49
52
|
getAgentConfig: m,
|
|
50
|
-
getAnswerStreaming:
|
|
51
|
-
getAnswer:
|
|
53
|
+
getAnswerStreaming: C,
|
|
54
|
+
getAnswer: p,
|
|
52
55
|
getSuggestedQuestions: t,
|
|
53
56
|
isCitationsEnabled: n,
|
|
54
|
-
isStopResponseEnabled:
|
|
57
|
+
isStopResponseEnabled: E,
|
|
55
58
|
isStreamingEnabled: r,
|
|
56
59
|
itemID: o
|
|
57
60
|
}), {
|
|
58
|
-
encodedSession:
|
|
59
|
-
error:
|
|
60
|
-
isLoading:
|
|
61
|
-
hasRequestInProgress:
|
|
62
|
-
questions:
|
|
61
|
+
encodedSession: b,
|
|
62
|
+
error: k,
|
|
63
|
+
isLoading: z,
|
|
64
|
+
hasRequestInProgress: B = !1,
|
|
65
|
+
questions: D,
|
|
63
66
|
suggestedQuestions: e
|
|
64
67
|
} = c;
|
|
65
|
-
|
|
66
|
-
s && e.requestState ===
|
|
68
|
+
J(() => {
|
|
69
|
+
s && e.requestState === a.NOT_STARTED && i();
|
|
67
70
|
}, [s, i, e.requestState]);
|
|
68
|
-
const
|
|
69
|
-
createSession:
|
|
70
|
-
encodedSession:
|
|
71
|
-
error:
|
|
71
|
+
const F = {
|
|
72
|
+
createSession: L,
|
|
73
|
+
encodedSession: b,
|
|
74
|
+
error: k,
|
|
75
|
+
getAIStudioAgents: g,
|
|
72
76
|
hostAppName: R,
|
|
73
|
-
hasRequestInProgress:
|
|
74
|
-
isAgentSelectorEnabled:
|
|
77
|
+
hasRequestInProgress: B,
|
|
78
|
+
isAgentSelectorEnabled: w,
|
|
79
|
+
isAIStudioAgentSelectorEnabled: l,
|
|
75
80
|
isCitationsEnabled: n,
|
|
76
|
-
isDebugModeEnabled:
|
|
77
|
-
isMarkdownEnabled:
|
|
78
|
-
isLoading:
|
|
81
|
+
isDebugModeEnabled: Q,
|
|
82
|
+
isMarkdownEnabled: T,
|
|
83
|
+
isLoading: z,
|
|
79
84
|
isOpen: s,
|
|
80
|
-
isResetChatEnabled:
|
|
85
|
+
isResetChatEnabled: q,
|
|
81
86
|
isStreamingEnabled: r,
|
|
82
87
|
itemID: o,
|
|
83
|
-
onClearAction:
|
|
88
|
+
onClearAction: y,
|
|
84
89
|
onCloseModal: h,
|
|
85
90
|
onSelectAgent: u,
|
|
86
91
|
onAgentEditorToggle: u,
|
|
87
|
-
questions:
|
|
88
|
-
retryQuestion:
|
|
89
|
-
sendQuestion:
|
|
90
|
-
shouldRenderProviders:
|
|
91
|
-
stopQuestion:
|
|
92
|
-
suggestedQuestionsRequestState: t ? e.requestState :
|
|
93
|
-
suggestedQuestions: t ? e.suggestions :
|
|
94
|
-
warningNotice:
|
|
95
|
-
warningNoticeAriaLabel:
|
|
96
|
-
},
|
|
97
|
-
return /* @__PURE__ */
|
|
98
|
-
...
|
|
92
|
+
questions: D,
|
|
93
|
+
retryQuestion: N,
|
|
94
|
+
sendQuestion: O,
|
|
95
|
+
shouldRenderProviders: j,
|
|
96
|
+
stopQuestion: P,
|
|
97
|
+
suggestedQuestionsRequestState: t ? e.requestState : a.SUCCESS,
|
|
98
|
+
suggestedQuestions: t ? e.suggestions : U,
|
|
99
|
+
warningNotice: _,
|
|
100
|
+
warningNoticeAriaLabel: v
|
|
101
|
+
}, G = Object.fromEntries(Object.entries(F).filter(([Y, H]) => H !== void 0));
|
|
102
|
+
return /* @__PURE__ */ X(d, {
|
|
103
|
+
...G
|
|
99
104
|
});
|
|
100
105
|
};
|
|
101
106
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
ne as ContentAnswersComponent,
|
|
108
|
+
ne as default
|
|
104
109
|
};
|
|
@@ -1,126 +1,136 @@
|
|
|
1
1
|
import "../../../../styles/footer.css";
|
|
2
2
|
import * as r from "react";
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import { useBreakpoint as
|
|
5
|
-
import { ArrowUp as
|
|
6
|
-
import { useAgents as
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
import { useIntl as z } from "react-intl";
|
|
4
|
+
import { useBreakpoint as D, Breakpoint as Y, Avatar as J, TextArea as Q, Button as S } from "@box/blueprint-web";
|
|
5
|
+
import { ArrowUp as V } from "@box/blueprint-web-assets/icons/Line";
|
|
6
|
+
import { useAgents as Z } from "@box/box-ai-agent-selector";
|
|
7
|
+
import { useAgents as g } from "../../contexts/AgentsContext.js";
|
|
8
|
+
import { FooterActions as q } from "./footer-actions.js";
|
|
9
|
+
import P from "../../messages.js";
|
|
10
|
+
import { getAIAgentConfig as X } from "../common/agentUtils.js";
|
|
11
|
+
import { isDebugModeTrigger as tt, isEnterTrigger as at } from "../common/keyInputUtils.js";
|
|
12
|
+
import { TEXT_AREA as i } from "./constants.js";
|
|
13
|
+
import u from "./messages.js";
|
|
14
|
+
import { LOGGER_BASE_CONFIG as w, LOGGER_ACTION_CLICK as rt, LOGGER_ACTION_KEYPRESS as et } from "../common/constants.js";
|
|
15
|
+
import { jsxs as H, jsx as p } from "react/jsx-runtime";
|
|
16
|
+
const ot = "_questionInput_1pdo1_1", st = "_avatar_1pdo1_11", it = "_submitButton_1pdo1_14", nt = "_textArea_1pdo1_17", mt = "_submitButtonTooltip_1pdo1_26", A = {
|
|
17
|
+
questionInput: ot,
|
|
18
|
+
avatar: st,
|
|
19
|
+
submitButton: it,
|
|
20
|
+
textArea: nt,
|
|
21
|
+
submitButtonTooltip: mt
|
|
22
|
+
}, kt = ({
|
|
23
|
+
askSuggestedQuestion: h,
|
|
24
|
+
contentType: T,
|
|
25
|
+
enableDebugMode: b = !1,
|
|
24
26
|
hasRequestInProgress: e,
|
|
25
27
|
isAgentSelectorEnabled: f,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
isAIStudioAgentSelectorEnabled: _,
|
|
29
|
+
isDebugModeShown: k,
|
|
30
|
+
isStopResponseEnabled: R,
|
|
31
|
+
isStreamingEnabled: y,
|
|
32
|
+
lastQuestion: L,
|
|
33
|
+
onRetryQuestion: E,
|
|
34
|
+
onStopQuestion: I,
|
|
32
35
|
recordAction: o,
|
|
33
|
-
sendQuestion:
|
|
34
|
-
setAskSuggestedQuestion:
|
|
35
|
-
toggleDebugMode:
|
|
36
|
-
user:
|
|
36
|
+
sendQuestion: M,
|
|
37
|
+
setAskSuggestedQuestion: B,
|
|
38
|
+
toggleDebugMode: n,
|
|
39
|
+
user: G
|
|
37
40
|
}) => {
|
|
38
|
-
const
|
|
39
|
-
selectedAgent:
|
|
40
|
-
} =
|
|
41
|
+
const s = z(), K = D(), a = /* @__PURE__ */ r.createRef(), v = K <= Y.Medium, [c, N] = r.useState(!0), [F, O] = r.useState(!1), {
|
|
42
|
+
selectedAgent: d
|
|
43
|
+
} = g(), {
|
|
44
|
+
selectedAgent: C
|
|
45
|
+
} = Z(), x = r.useCallback(() => {
|
|
41
46
|
a.current && a.current.focus();
|
|
42
|
-
}, [a]),
|
|
43
|
-
var
|
|
44
|
-
let t = ((
|
|
45
|
-
a.current && t.length >
|
|
47
|
+
}, [a]), j = r.useCallback(() => {
|
|
48
|
+
var m;
|
|
49
|
+
let t = ((m = a.current) == null ? void 0 : m.value) ?? "";
|
|
50
|
+
a.current && t.length > i.MAX_LENGTH && (a.current.value = t.slice(0, i.MAX_LENGTH), t = a.current.value), O(t.length >= i.MAX_LENGTH), N(t.trim().length === 0);
|
|
46
51
|
}, [a]), l = r.useCallback(() => {
|
|
47
|
-
if (
|
|
52
|
+
if (x(), !e && a.current) {
|
|
48
53
|
const t = {
|
|
49
54
|
prompt: a.current.value
|
|
50
55
|
};
|
|
51
|
-
t.prompt && t.prompt.trim()
|
|
56
|
+
if (t.prompt && t.prompt.trim()) {
|
|
57
|
+
const m = X(f, d, _, C);
|
|
58
|
+
M(t, m), a.current.value = "", N(!0), O(!1);
|
|
59
|
+
}
|
|
60
|
+
k && n && n();
|
|
52
61
|
}
|
|
53
|
-
}, [
|
|
62
|
+
}, [C, x, e, a, _, f, k, d, M, n]), U = r.useCallback((t) => {
|
|
54
63
|
t.preventDefault(), !e && !c && o && o({
|
|
55
|
-
...
|
|
56
|
-
action:
|
|
64
|
+
...w,
|
|
65
|
+
action: rt,
|
|
57
66
|
target: "ask"
|
|
58
67
|
}), l();
|
|
59
|
-
}, [e, c, o, l]),
|
|
60
|
-
|
|
61
|
-
...
|
|
62
|
-
action:
|
|
68
|
+
}, [e, c, o, l]), W = r.useCallback((t) => {
|
|
69
|
+
b && n && tt(t) && n(), at(t) && (t.preventDefault(), !e && !c && o && o({
|
|
70
|
+
...w,
|
|
71
|
+
action: et,
|
|
63
72
|
target: "ask"
|
|
64
73
|
}), l());
|
|
65
|
-
}, [
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
}, [b, e, c, o, l, n]), $ = r.useCallback((t) => {
|
|
75
|
+
const m = X(f, d, _, C);
|
|
76
|
+
E(t, m);
|
|
77
|
+
}, [C, _, f, E, d]);
|
|
68
78
|
return r.useEffect(() => {
|
|
69
|
-
setTimeout(
|
|
79
|
+
setTimeout(x, 0);
|
|
70
80
|
}, []), r.useEffect(() => {
|
|
71
|
-
|
|
72
|
-
}, [
|
|
73
|
-
children: [
|
|
74
|
-
isStopResponseEnabled:
|
|
75
|
-
isStreamingEnabled:
|
|
76
|
-
lastQuestion:
|
|
77
|
-
onRetryQuestion:
|
|
78
|
-
onStopQuestion:
|
|
81
|
+
h && a.current && !e && B && (a.current.value = h, l(), B(null));
|
|
82
|
+
}, [h]), /* @__PURE__ */ H("div", {
|
|
83
|
+
children: [L && /* @__PURE__ */ p(q, {
|
|
84
|
+
isStopResponseEnabled: R,
|
|
85
|
+
isStreamingEnabled: y,
|
|
86
|
+
lastQuestion: L,
|
|
87
|
+
onRetryQuestion: $,
|
|
88
|
+
onStopQuestion: I,
|
|
79
89
|
recordAction: o
|
|
80
|
-
}), /* @__PURE__ */
|
|
81
|
-
className:
|
|
82
|
-
children: [!
|
|
83
|
-
className:
|
|
90
|
+
}), /* @__PURE__ */ H("div", {
|
|
91
|
+
className: A.questionInput,
|
|
92
|
+
children: [!v && /* @__PURE__ */ p("div", {
|
|
93
|
+
className: A.avatar,
|
|
84
94
|
"data-testid": "content-answers-question-input-avatar",
|
|
85
|
-
children: /* @__PURE__ */
|
|
86
|
-
alt:
|
|
95
|
+
children: /* @__PURE__ */ p(J, {
|
|
96
|
+
alt: s.formatMessage(P.userAvatar),
|
|
87
97
|
colorIndex: 0,
|
|
88
|
-
src:
|
|
89
|
-
text:
|
|
98
|
+
src: G.avatarURL,
|
|
99
|
+
text: G.name.charAt(0)
|
|
90
100
|
})
|
|
91
|
-
}), /* @__PURE__ */
|
|
101
|
+
}), /* @__PURE__ */ p(Q, {
|
|
92
102
|
ref: a,
|
|
93
|
-
className:
|
|
103
|
+
className: A.textArea,
|
|
94
104
|
"data-testid": "content-answers-question-input",
|
|
95
|
-
error:
|
|
96
|
-
characterLimit:
|
|
105
|
+
error: F && s.formatMessage(u.maxCharactersReachedError, {
|
|
106
|
+
characterLimit: i.MAX_LENGTH
|
|
97
107
|
}),
|
|
98
108
|
hideLabel: !0,
|
|
99
|
-
label:
|
|
100
|
-
type:
|
|
109
|
+
label: s.formatMessage(u.askQuestionPlaceholder, {
|
|
110
|
+
type: T
|
|
101
111
|
}),
|
|
102
|
-
maxLength:
|
|
103
|
-
maxRows:
|
|
104
|
-
onChange:
|
|
105
|
-
onKeyDown:
|
|
106
|
-
placeholder:
|
|
107
|
-
type:
|
|
112
|
+
maxLength: i.MAX_LENGTH,
|
|
113
|
+
maxRows: v ? i.MAX_ROWS_MOBILE : i.MAX_ROWS,
|
|
114
|
+
onChange: j,
|
|
115
|
+
onKeyDown: W,
|
|
116
|
+
placeholder: s.formatMessage(u.askQuestionPlaceholder, {
|
|
117
|
+
type: T
|
|
108
118
|
})
|
|
109
|
-
}), /* @__PURE__ */
|
|
110
|
-
"aria-label":
|
|
111
|
-
className:
|
|
119
|
+
}), /* @__PURE__ */ p(S, {
|
|
120
|
+
"aria-label": s.formatMessage(u.ask),
|
|
121
|
+
className: A.submitButton,
|
|
112
122
|
"data-testid": "content-answers-submit-button",
|
|
113
123
|
disabled: c || e,
|
|
114
|
-
icon:
|
|
124
|
+
icon: v ? V : void 0,
|
|
115
125
|
loading: e,
|
|
116
|
-
loadingAriaLabel:
|
|
117
|
-
onClick:
|
|
126
|
+
loadingAriaLabel: s.formatMessage(u.askDisabledTooltip),
|
|
127
|
+
onClick: U,
|
|
118
128
|
size: "large",
|
|
119
|
-
children:
|
|
129
|
+
children: v ? void 0 : s.formatMessage(u.ask)
|
|
120
130
|
})]
|
|
121
131
|
})]
|
|
122
132
|
});
|
|
123
133
|
};
|
|
124
134
|
export {
|
|
125
|
-
|
|
135
|
+
kt as Footer
|
|
126
136
|
};
|
|
@@ -1,128 +1,145 @@
|
|
|
1
1
|
import "../../../../styles/modal.css";
|
|
2
|
-
import { useBreakpoint as G, Breakpoint as
|
|
3
|
-
import { Trash as
|
|
4
|
-
import { BoxAiLogo as
|
|
5
|
-
import { Size8 as
|
|
2
|
+
import { useBreakpoint as G, Breakpoint as z, Modal as a, Text as R, Tooltip as j, IconButton as E } from "@box/blueprint-web";
|
|
3
|
+
import { Trash as F } from "@box/blueprint-web-assets/icons/Line";
|
|
4
|
+
import { BoxAiLogo as K } from "@box/blueprint-web-assets/icons/Logo";
|
|
5
|
+
import { Size8 as A } from "@box/blueprint-web-assets/tokens/tokens";
|
|
6
|
+
import { BoxAiAgentSelectorWithApi as W, AgentsProvider as $ } from "@box/box-ai-agent-selector";
|
|
6
7
|
import u from "react";
|
|
7
|
-
import { useIntl as
|
|
8
|
-
import { BoxAiContentAnswers as
|
|
9
|
-
import { AgentsProvider as
|
|
10
|
-
import { AgentSelector as
|
|
11
|
-
import { LOGGER_BASE_CONFIG as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import { jsxs as
|
|
15
|
-
const
|
|
16
|
-
BoxAIIconColor:
|
|
17
|
-
modalHeader:
|
|
18
|
-
contentAnswersModal:
|
|
19
|
-
boxAiContentAnswers:
|
|
20
|
-
clearButton:
|
|
21
|
-
"modal-close-button": "_modal-close-
|
|
22
|
-
contentAnswerModal:
|
|
23
|
-
|
|
8
|
+
import { useIntl as q } from "react-intl";
|
|
9
|
+
import { BoxAiContentAnswers as D } from "../../box-ai-content-answers.js";
|
|
10
|
+
import { AgentsProvider as J } from "../../contexts/AgentsContext.js";
|
|
11
|
+
import { AgentSelector as Q } from "../agents/agent-selector.js";
|
|
12
|
+
import { LOGGER_BASE_CONFIG as h, LOGGER_ACTION_CLICK as U } from "../common/constants.js";
|
|
13
|
+
import V from "./hooks/useStopPropagationOnEsc.js";
|
|
14
|
+
import i from "./messages.js";
|
|
15
|
+
import { jsxs as d, jsx as e } from "react/jsx-runtime";
|
|
16
|
+
const X = "_BoxAIIconColor_1ed3r_1", Y = "_modalHeader_1ed3r_5", Z = "_contentAnswersModal_1ed3r_10", y = "_boxAiContentAnswers_1ed3r_17", ee = "_clearButton_1ed3r_25", te = "_contentAnswerModal_1ed3r_1", oe = "_modalHeaderContainer_1ed3r_54", ne = "_agentSelectorTrigger_1ed3r_62", re = "_agentSelectorContent_1ed3r_73", t = {
|
|
17
|
+
BoxAIIconColor: X,
|
|
18
|
+
modalHeader: Y,
|
|
19
|
+
contentAnswersModal: Z,
|
|
20
|
+
boxAiContentAnswers: y,
|
|
21
|
+
clearButton: ee,
|
|
22
|
+
"modal-close-button": "_modal-close-button_1ed3r_29",
|
|
23
|
+
contentAnswerModal: te,
|
|
24
|
+
modalHeaderContainer: oe,
|
|
25
|
+
agentSelectorTrigger: ne,
|
|
26
|
+
agentSelectorContent: re
|
|
27
|
+
}, we = ({
|
|
24
28
|
children: M,
|
|
29
|
+
getAIStudioAgents: w,
|
|
25
30
|
hostAppName: c,
|
|
26
31
|
isAgentSelectorEnabled: m,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
isAIStudioAgentSelectorEnabled: s,
|
|
33
|
+
isDebugModeEnabled: x,
|
|
34
|
+
isResetChatEnabled: B,
|
|
35
|
+
isStopResponseEnabled: b = !1,
|
|
36
|
+
itemSize: g,
|
|
37
|
+
extension: _,
|
|
38
|
+
onClearAction: C,
|
|
39
|
+
onSelectAgent: v,
|
|
40
|
+
recordAction: o,
|
|
41
|
+
shouldRenderProviders: I = !0,
|
|
42
|
+
stopPropagationOnEsc: T,
|
|
43
|
+
...H
|
|
38
44
|
}) => {
|
|
39
45
|
const {
|
|
40
|
-
open:
|
|
41
|
-
defaultOpen:
|
|
46
|
+
open: f,
|
|
47
|
+
defaultOpen: N,
|
|
42
48
|
onOpenChange: L,
|
|
43
|
-
modal:
|
|
44
|
-
...
|
|
45
|
-
} =
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
}, [c,
|
|
49
|
+
modal: O,
|
|
50
|
+
...S
|
|
51
|
+
} = H, l = q(), k = G() <= z.Medium;
|
|
52
|
+
V(T, f);
|
|
53
|
+
const n = u.useCallback((r) => {
|
|
54
|
+
o && (r.data ?? (r.data = {}), r.data.hostAppName = c, o(r));
|
|
55
|
+
}, [c, o]);
|
|
50
56
|
u.useEffect(() => {
|
|
51
|
-
|
|
52
|
-
...
|
|
57
|
+
n({
|
|
58
|
+
...h,
|
|
53
59
|
target: "loaded",
|
|
54
60
|
data: {
|
|
55
|
-
fileSize:
|
|
56
|
-
fileType:
|
|
61
|
+
fileSize: g,
|
|
62
|
+
fileType: _
|
|
57
63
|
}
|
|
58
64
|
});
|
|
59
|
-
}, [
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
...
|
|
63
|
-
action:
|
|
65
|
+
}, [n, _, g, o]);
|
|
66
|
+
const P = () => {
|
|
67
|
+
C && (C(), n({
|
|
68
|
+
...h,
|
|
69
|
+
action: U,
|
|
64
70
|
target: "clearChat"
|
|
65
71
|
}));
|
|
66
|
-
}, p = /* @__PURE__ */
|
|
67
|
-
defaultOpen:
|
|
68
|
-
modal:
|
|
72
|
+
}, p = /* @__PURE__ */ d(a, {
|
|
73
|
+
defaultOpen: N,
|
|
74
|
+
modal: O,
|
|
69
75
|
onOpenChange: L,
|
|
70
|
-
open:
|
|
76
|
+
open: f,
|
|
71
77
|
children: [/* @__PURE__ */ e(a.Trigger, {
|
|
72
78
|
children: M
|
|
73
|
-
}), /* @__PURE__ */
|
|
74
|
-
className:
|
|
79
|
+
}), /* @__PURE__ */ d(a.Content, {
|
|
80
|
+
className: t.contentAnswersModal,
|
|
75
81
|
"data-testid": "content-answers-modal",
|
|
76
82
|
size: "xlarge",
|
|
77
83
|
children: [/* @__PURE__ */ e(a.Header, {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
className: t.modalHeaderContainer,
|
|
85
|
+
children: /* @__PURE__ */ d("div", {
|
|
86
|
+
className: t.modalHeader,
|
|
87
|
+
children: [!k && /* @__PURE__ */ e(K, {
|
|
88
|
+
className: t.BoxAIIconColor,
|
|
82
89
|
"data-testid": "content-answers-icon-color",
|
|
83
|
-
height:
|
|
84
|
-
width:
|
|
85
|
-
}), /* @__PURE__ */ e(
|
|
90
|
+
height: A,
|
|
91
|
+
width: A
|
|
92
|
+
}), /* @__PURE__ */ e(R, {
|
|
86
93
|
as: "span",
|
|
87
94
|
variant: "titleMedium",
|
|
88
|
-
children:
|
|
89
|
-
}), m && /* @__PURE__ */ e(
|
|
90
|
-
onSelectAgent:
|
|
91
|
-
recordAction:
|
|
95
|
+
children: l.formatMessage(i.contentAnswersTitle)
|
|
96
|
+
}), !s && m && /* @__PURE__ */ e(Q, {
|
|
97
|
+
onSelectAgent: v,
|
|
98
|
+
recordAction: n
|
|
99
|
+
}), s && /* @__PURE__ */ e(W, {
|
|
100
|
+
contentClassName: t.agentSelectorContent,
|
|
101
|
+
fetcher: w,
|
|
102
|
+
hostAppName: c,
|
|
103
|
+
recordAction: o,
|
|
104
|
+
shouldHideAgentSelectorOnLoad: !0,
|
|
105
|
+
triggerChipClassName: t.agentSelectorTrigger
|
|
92
106
|
})]
|
|
93
107
|
})
|
|
94
|
-
}),
|
|
95
|
-
content:
|
|
108
|
+
}), B && /* @__PURE__ */ e(j, {
|
|
109
|
+
content: l.formatMessage(i.clearConversationLabel),
|
|
96
110
|
"data-testid": "clear-conversation-tooltip",
|
|
97
111
|
side: "top",
|
|
98
112
|
variant: "standard",
|
|
99
|
-
children: /* @__PURE__ */ e(
|
|
100
|
-
"aria-label":
|
|
101
|
-
className:
|
|
113
|
+
children: /* @__PURE__ */ e(E, {
|
|
114
|
+
"aria-label": l.formatMessage(i.clearConversationLabel),
|
|
115
|
+
className: t.clearButton,
|
|
102
116
|
"data-testid": "clear-conversation-button",
|
|
103
|
-
icon:
|
|
104
|
-
onClick:
|
|
117
|
+
icon: F,
|
|
118
|
+
onClick: P,
|
|
105
119
|
size: "small"
|
|
106
120
|
})
|
|
107
121
|
}), /* @__PURE__ */ e(a.Close, {
|
|
108
|
-
"aria-label":
|
|
109
|
-
className:
|
|
122
|
+
"aria-label": l.formatMessage(i.closeModalAriaLabel),
|
|
123
|
+
className: t["modal-close-button"],
|
|
110
124
|
size: "small"
|
|
111
|
-
}), /* @__PURE__ */ e(
|
|
112
|
-
className:
|
|
113
|
-
isAgentSelectorEnabled: m,
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
}), /* @__PURE__ */ e(D, {
|
|
126
|
+
className: t.boxAiContentAnswers,
|
|
127
|
+
isAgentSelectorEnabled: !s && m,
|
|
128
|
+
isAIStudioAgentSelectorEnabled: s,
|
|
129
|
+
isDebugModeEnabled: x,
|
|
130
|
+
isStopResponseEnabled: b,
|
|
131
|
+
recordAction: n,
|
|
132
|
+
...S
|
|
118
133
|
})]
|
|
119
134
|
})]
|
|
120
135
|
});
|
|
121
|
-
return
|
|
122
|
-
children:
|
|
136
|
+
return I ? /* @__PURE__ */ e($, {
|
|
137
|
+
children: /* @__PURE__ */ e(J, {
|
|
138
|
+
children: p
|
|
139
|
+
})
|
|
123
140
|
}) : p;
|
|
124
141
|
};
|
|
125
142
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
we as IntelligenceModal,
|
|
144
|
+
we as default
|
|
128
145
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/box-ai-content-answers",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.65.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.8.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
7
|
+
"@box/box-ai-agent-selector": "^0.15.2",
|
|
7
8
|
"highlight.js": "^11.9.0",
|
|
8
9
|
"immutable": "^4.0.0",
|
|
9
10
|
"lodash": "^4.17.15",
|
|
@@ -13,8 +14,9 @@
|
|
|
13
14
|
"remarkable": "^2.0.1"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
|
-
"@box/blueprint-web": "^8.5.
|
|
17
|
-
"@box/blueprint-web-assets": "^4.
|
|
17
|
+
"@box/blueprint-web": "^8.5.3",
|
|
18
|
+
"@box/blueprint-web-assets": "^4.29.0",
|
|
19
|
+
"@box/box-ai-agent-selector": "^0.15.2",
|
|
18
20
|
"@box/storybook-utils": "^0.7.0",
|
|
19
21
|
"@testing-library/react": "^15.0.6",
|
|
20
22
|
"react": "^18.3.0",
|
|
@@ -52,5 +54,5 @@
|
|
|
52
54
|
"**/*.css"
|
|
53
55
|
],
|
|
54
56
|
"license": "SEE LICENSE IN LICENSE",
|
|
55
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "31e23f5c37c183d2237deeab90eb3bc5c2b360e2"
|
|
56
58
|
}
|
package/styles/modal.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._BoxAIIconColor_1ed3r_1{margin-right:.75rem}._modalHeader_1ed3r_5{display:flex;align-items:center}._contentAnswersModal_1ed3r_10{display:flex;flex-basis:0;width:100%;height:100%;max-height:43.875rem}._contentAnswersModal_1ed3r_10 ._boxAiContentAnswers_1ed3r_17{display:flex;flex-direction:column;flex-grow:1;max-height:43.875rem;overflow:hidden;box-shadow:0 -1px 8px #0000000d,0 -1px #e8e8e8}._contentAnswersModal_1ed3r_10 ._clearButton_1ed3r_25{position:absolute;right:60px}._contentAnswersModal_1ed3r_10 ._modal-close-button_1ed3r_29,._contentAnswersModal_1ed3r_10 ._clearButton_1ed3r_25{top:1.25rem}@media (max-width: 374px){._contentAnswersModal_1ed3r_10,#_contentAnswerModal_1ed3r_1{flex-basis:100%;max-height:unset}._contentAnswersModal_1ed3r_10 ._boxAiContentAnswers_1ed3r_17,#_contentAnswerModal_1ed3r_1 ._boxAiContentAnswers_1ed3r_17{display:flex;flex-flow:column;max-height:unset}._contentAnswersModal_1ed3r_10 ._modal-close-button_1ed3r_29,._contentAnswersModal_1ed3r_10 ._clearButton_1ed3r_25,#_contentAnswerModal_1ed3r_1 ._modal-close-button_1ed3r_29,#_contentAnswerModal_1ed3r_1 ._clearButton_1ed3r_25{top:1rem}}@media (max-width: 540px){._contentAnswersModal_1ed3r_10 div:has(._modalHeaderContainer_1ed3r_54){width:100%;box-sizing:border-box}._contentAnswersModal_1ed3r_10 ._modalHeaderContainer_1ed3r_54 ._modalHeader_1ed3r_5{flex-direction:column;align-items:start}._contentAnswersModal_1ed3r_10 ._modalHeaderContainer_1ed3r_54 ._modalHeader_1ed3r_5 ._agentSelectorTrigger_1ed3r_62{margin-inline-start:0;margin-block-start:var(--space-8);width:100%;flex:1}._contentAnswersModal_1ed3r_10 ._modalHeaderContainer_1ed3r_54 ._modalHeader_1ed3r_5 ._agentSelectorTrigger_1ed3r_62 button{width:100%;max-width:100%}}._agentSelectorContent_1ed3r_73{max-height:15rem}
|
|
@@ -2,5 +2,5 @@ import { type ApiWrapperProps } from './types';
|
|
|
2
2
|
export type ContentAnswersComponentProps = ApiWrapperProps & {
|
|
3
3
|
WrappedComponent: React.ComponentType<ApiWrapperProps>;
|
|
4
4
|
};
|
|
5
|
-
export declare const ContentAnswersComponent: ({ WrappedComponent, createSessionRequest, getAgentConfig, fetchTimeout, formatCitations, getAnswer, getAnswerStreaming, getSuggestedQuestions, hostAppName, isAgentSelectorEnabled, isCitationsEnabled, isDebugModeEnabled, isMarkdownEnabled, isOpen, isResetChatEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, onCloseModal, suggestedQuestions, warningNotice, warningNoticeAriaLabel, }: ContentAnswersComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare const ContentAnswersComponent: ({ WrappedComponent, createSessionRequest, getAgentConfig, getAIStudioAgents, fetchTimeout, formatCitations, getAnswer, getAnswerStreaming, getSuggestedQuestions, hostAppName, isAgentSelectorEnabled, isAIStudioAgentSelectorEnabled, isCitationsEnabled, isDebugModeEnabled, isMarkdownEnabled, isOpen, isResetChatEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, onCloseModal, shouldRenderProviders, suggestedQuestions, warningNotice, warningNoticeAriaLabel, }: ContentAnswersComponentProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default ContentAnswersComponent;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type AgentListResponse } from '@box/box-ai-agent-selector';
|
|
1
2
|
import { type AgentType, type CitationResponse, type CitationType, type CONTENT_ERROR, type QuestionType, type REQUEST_STATE, type RetryQuestion, type StopQuestion, type SubmitQuestion, type SuggestedQuestionsResponse, type SuggestedQuestionType } from '../../types';
|
|
2
3
|
import { type ContentAnswersRecordType } from './records';
|
|
3
4
|
export type CreateSessionResponse = {
|
|
@@ -54,11 +55,18 @@ export type ApiWrapperProps = {
|
|
|
54
55
|
fetchTimeout?: StreamResponseTimeout;
|
|
55
56
|
formatCitations?: (citations: Array<CitationResponse>) => Array<CitationType>;
|
|
56
57
|
getAgentConfig?: agentFetcherType;
|
|
58
|
+
getAIStudioAgents?(): Promise<AgentListResponse>;
|
|
57
59
|
getAnswer?: fetcherType;
|
|
58
60
|
getAnswerStreaming?: fetcherStreamingType;
|
|
59
61
|
getSuggestedQuestions?: SuggestedQuestionFetcherType;
|
|
60
62
|
hostAppName?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Flag to enable or disable the agent selector
|
|
65
|
+
* Prefer passing isAIStudioAgentSelectorEnabled and getAIStudioAgents instead since this prop will be removed soon
|
|
66
|
+
* @deprecated
|
|
67
|
+
*/
|
|
61
68
|
isAgentSelectorEnabled?: boolean;
|
|
69
|
+
isAIStudioAgentSelectorEnabled?: boolean;
|
|
62
70
|
isDebugModeEnabled?: boolean;
|
|
63
71
|
isResetChatEnabled?: boolean;
|
|
64
72
|
isStopResponseEnabled?: boolean;
|
|
@@ -69,6 +77,7 @@ export type ApiWrapperProps = {
|
|
|
69
77
|
isStreamingEnabled?: boolean;
|
|
70
78
|
itemID?: string;
|
|
71
79
|
onCloseModal?: () => void;
|
|
80
|
+
shouldRenderProviders?: boolean;
|
|
72
81
|
suggestedQuestionsRequestState?: REQUEST_STATE;
|
|
73
82
|
suggestedQuestions?: SuggestedQuestionType[];
|
|
74
83
|
warningNotice?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getAIAgentConfig: (isAgentSelectorEnabled: any, selectedAgent: any, isAIStudioAgentSelectorEnabled: any, aiStudioSelectedAgent: any) => any;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
+
import { type RecordActionType } from '../../types';
|
|
1
2
|
export declare const LOGGER_COMPONENT = "modal";
|
|
2
3
|
export declare const LOGGER_FEATURE = "answers";
|
|
3
4
|
export declare const LOGGER_ACTION_PROGRAMMATIC = "programmatic";
|
|
4
5
|
export declare const LOGGER_ACTION_CLICK = "click";
|
|
5
6
|
export declare const LOGGER_ACTION_KEYPRESS = "keypress";
|
|
6
|
-
export declare const LOGGER_BASE_CONFIG:
|
|
7
|
-
action: string;
|
|
8
|
-
component: string;
|
|
9
|
-
feature: string;
|
|
10
|
-
};
|
|
7
|
+
export declare const LOGGER_BASE_CONFIG: RecordActionType;
|
|
@@ -8,8 +8,14 @@ export interface FooterProps {
|
|
|
8
8
|
enableDebugMode?: boolean;
|
|
9
9
|
/** Whether to indicate if there is a request in progress like an answer being fetched or streamed */
|
|
10
10
|
hasRequestInProgress: boolean;
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* Flag to enable or disable the agent selector
|
|
13
|
+
* Prefer passing isAIStudioAgentSelectorEnabled instead since this prop will be removed soon
|
|
14
|
+
* @deprecated
|
|
15
|
+
*/
|
|
12
16
|
isAgentSelectorEnabled?: boolean;
|
|
17
|
+
/** Whether to show the AI studio agent selector or not */
|
|
18
|
+
isAIStudioAgentSelectorEnabled?: boolean;
|
|
13
19
|
/** Flag to indicate if the CTRL+SHIFT+X is currently shown */
|
|
14
20
|
isDebugModeShown?: boolean;
|
|
15
21
|
/** Whether to give user a possibility to stop the response before any answer is generated */
|
|
@@ -33,4 +39,4 @@ export interface FooterProps {
|
|
|
33
39
|
/** User information consisting on their name and an optional avatar */
|
|
34
40
|
user: UserInfoType;
|
|
35
41
|
}
|
|
36
|
-
export declare const Footer: ({ askSuggestedQuestion, contentType, enableDebugMode, hasRequestInProgress, isAgentSelectorEnabled, isDebugModeShown, isStopResponseEnabled, isStreamingEnabled, lastQuestion, onRetryQuestion, onStopQuestion, recordAction, sendQuestion, setAskSuggestedQuestion, toggleDebugMode, user, }: FooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare const Footer: ({ askSuggestedQuestion, contentType, enableDebugMode, hasRequestInProgress, isAgentSelectorEnabled, isAIStudioAgentSelectorEnabled, isDebugModeShown, isStopResponseEnabled, isStreamingEnabled, lastQuestion, onRetryQuestion, onStopQuestion, recordAction, sendQuestion, setAskSuggestedQuestion, toggleDebugMode, user, }: FooterProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { type ModalProps } from '@box/blueprint-web';
|
|
2
|
+
import { type AgentListResponse } from '@box/box-ai-agent-selector';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { type BoxAiContentAnswersProps } from '../../box-ai-content-answers';
|
|
4
5
|
import { type AgentType, type RecordActionType } from '../../types';
|
|
5
6
|
export type IntelligenceModalProps = ModalProps & BoxAiContentAnswersProps & {
|
|
7
|
+
/** API callback to send to AI Studio Agent Selector */
|
|
8
|
+
getAIStudioAgents?(): Promise<AgentListResponse>;
|
|
6
9
|
/** Name of the host application */
|
|
7
10
|
hostAppName?: string;
|
|
8
11
|
/** Size of the item used for QA. This is used for log purposes */
|
|
9
12
|
itemSize?: string;
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Flag to enable or disable the agent selector
|
|
15
|
+
* Prefer passing isAIStudioAgentSelectorEnabled and getAIStudioAgents instead since this prop will be removed soon
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
11
18
|
isAgentSelectorEnabled?: boolean;
|
|
19
|
+
/** Flag to enable or disable the AI studio agent selector */
|
|
20
|
+
isAIStudioAgentSelectorEnabled?: boolean;
|
|
12
21
|
/** Flag to enable or disable the debug mode via CTRL+SHIFT+X */
|
|
13
22
|
isDebugModeEnabled?: boolean;
|
|
14
23
|
/** Flag to enable or disable the reset chat button */
|
package/types/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LOGGER_ACTION_CLICK, type LOGGER_ACTION_KEYPRESS, type LOGGER_ACTION_PROGRAMMATIC } from './components/common/constants';
|
|
1
2
|
export declare enum ANSWER_ERROR {
|
|
2
3
|
GENERAL = "general",
|
|
3
4
|
RATE_LIMITING = "rate_limiting",
|
|
@@ -41,8 +42,14 @@ export type ChatProps = WelcomeMessageProps & {
|
|
|
41
42
|
isCitationsEnabled?: boolean;
|
|
42
43
|
/** Whether if the answers supports markdown or not */
|
|
43
44
|
isMarkdownEnabled?: boolean;
|
|
44
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Flag to enable or disable the agent selector
|
|
47
|
+
* Prefer passing isAIStudioAgentSelectorEnabled instead since this prop will be removed soon
|
|
48
|
+
* @deprecated
|
|
49
|
+
*/
|
|
45
50
|
isAgentSelectorEnabled?: boolean;
|
|
51
|
+
/** Whether to show the AI studio agent selector or not */
|
|
52
|
+
isAIStudioAgentSelectorEnabled?: boolean;
|
|
46
53
|
/** Whether to allow CTRL+SHIFT+X feature or not */
|
|
47
54
|
isDebugModeEnabled?: boolean;
|
|
48
55
|
/** Whether to give user a possibility to stop the response before any answer is generated */
|
|
@@ -82,6 +89,7 @@ export type ContentProps = Omit<ChatProps, 'handleScrollToBottom'> & {
|
|
|
82
89
|
setIsErrorMessageShown: ((value: boolean) => void) | null;
|
|
83
90
|
};
|
|
84
91
|
export type AgentType = {
|
|
92
|
+
id: string;
|
|
85
93
|
config: object;
|
|
86
94
|
description?: string;
|
|
87
95
|
isDefault?: boolean;
|
|
@@ -93,11 +101,18 @@ export type AgentState = {
|
|
|
93
101
|
selectedAgent: AgentType;
|
|
94
102
|
};
|
|
95
103
|
export type RecordActionType = {
|
|
96
|
-
action:
|
|
97
|
-
data?:
|
|
104
|
+
action: typeof LOGGER_ACTION_CLICK | typeof LOGGER_ACTION_PROGRAMMATIC | typeof LOGGER_ACTION_KEYPRESS;
|
|
105
|
+
data?: {
|
|
106
|
+
hostAppName?: string;
|
|
107
|
+
agentSelected?: string;
|
|
108
|
+
index?: number;
|
|
109
|
+
count?: number;
|
|
110
|
+
errorType?: string;
|
|
111
|
+
selectedQuestion?: string;
|
|
112
|
+
};
|
|
98
113
|
component: string;
|
|
99
114
|
feature: string;
|
|
100
|
-
target
|
|
115
|
+
target?: string;
|
|
101
116
|
};
|
|
102
117
|
export type QuestionType = {
|
|
103
118
|
answer?: string;
|