@box/box-ai-content-answers 0.68.0 → 0.69.1

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.
@@ -1,110 +1,113 @@
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
- createSessionRequest: f,
10
- getAgentConfig: m,
11
- getAIStudioAgents: S,
12
- fetchTimeout: g,
13
- formatCitations: A,
14
- getAnswer: p,
15
- getAnswerStreaming: C,
1
+ import { useReducer as M, useEffect as V } from "react";
2
+ import { R as d } from "../../../../chunks/types.js";
3
+ import { useContentAnswers as W } from "./hooks/useContentAnswers.js";
4
+ import { ContentAnswersRecord as X, ContentAnswersItemRecord as Y } from "./records.js";
5
+ import Z from "./reducer.js";
6
+ import { jsx as $ } from "react/jsx-runtime";
7
+ const re = ({
8
+ WrappedComponent: f,
9
+ createSessionRequest: m,
10
+ getAgentConfig: S,
11
+ getAIStudioAgents: g,
12
+ fetchTimeout: A,
13
+ formatCitations: p,
14
+ getAnswer: C,
15
+ getAnswerStreaming: R,
16
16
  getSuggestedQuestions: e,
17
- hostAppName: R,
18
- isAgentSelectorEnabled: w,
19
- isAIStudioAgentSelectorEnabled: Q,
17
+ hostAppName: w,
18
+ isAgentSelectorEnabled: Q,
19
+ isAIStudioAgentSelectorEnabled: T,
20
20
  isCitationsEnabled: n,
21
- isDebugModeEnabled: T,
22
- isMarkdownEnabled: h,
21
+ isDebugModeEnabled: h,
22
+ isMarkdownEnabled: l,
23
23
  isOpen: s,
24
- isResetChatEnabled: l,
25
- isStopResponseEnabled: q,
24
+ isResetChatEnabled: q,
25
+ isStopResponseEnabled: E,
26
26
  isStreamingEnabled: r,
27
27
  itemID: o,
28
- onCloseModal: E,
29
- shouldRenderProviders: j = !0,
30
- suggestedQuestions: U,
31
- warningNotice: _,
32
- warningNoticeAriaLabel: v
28
+ itemIDs: u,
29
+ onCloseModal: j,
30
+ shouldRenderProviders: U = !0,
31
+ suggestedQuestions: _,
32
+ warningNotice: v,
33
+ warningNoticeAriaLabel: x
33
34
  }) => {
34
- const [u, x] = I(W, new M({
35
- item: new V({
35
+ const [c, y] = M(Z, new X({
36
+ item: new Y({
36
37
  id: o
37
38
  })
38
39
  })), {
39
- clearConversation: y,
40
- createSession: L,
41
- fetchAgentConfig: c,
42
- fetchSuggestedQuestions: i,
43
- retryQuestion: N,
44
- sendQuestion: O,
45
- stopQuestion: P
46
- } = K({
47
- contentAnswers: u,
48
- createSessionRequest: f,
49
- dispatchStateUpdate: x,
50
- fetchTimeout: g,
51
- formatCitations: A,
52
- getAgentConfig: m,
53
- getAnswerStreaming: C,
54
- getAnswer: p,
40
+ clearConversation: L,
41
+ createSession: N,
42
+ fetchAgentConfig: i,
43
+ fetchSuggestedQuestions: a,
44
+ retryQuestion: O,
45
+ sendQuestion: P,
46
+ stopQuestion: b
47
+ } = W({
48
+ contentAnswers: c,
49
+ createSessionRequest: m,
50
+ dispatchStateUpdate: y,
51
+ fetchTimeout: A,
52
+ formatCitations: p,
53
+ getAgentConfig: S,
54
+ getAnswerStreaming: R,
55
+ getAnswer: C,
55
56
  getSuggestedQuestions: e,
56
57
  isCitationsEnabled: n,
57
- isStopResponseEnabled: q,
58
+ isStopResponseEnabled: E,
58
59
  isStreamingEnabled: r,
59
- itemID: o
60
+ itemID: o,
61
+ itemIDs: u
60
62
  }), {
61
- encodedSession: b,
62
- error: k,
63
- isLoading: z,
64
- hasRequestInProgress: B = !1,
65
- questions: D,
63
+ encodedSession: k,
64
+ error: z,
65
+ isLoading: B,
66
+ hasRequestInProgress: F = !1,
67
+ questions: G,
66
68
  suggestedQuestions: t
67
- } = u;
68
- J(() => {
69
- s && t.requestState === a.NOT_STARTED && i();
70
- }, [s, i, t.requestState]);
71
- const F = {
72
- createSession: L,
73
- encodedSession: b,
74
- error: k,
75
- getAIStudioAgents: S,
76
- hostAppName: R,
69
+ } = c;
70
+ V(() => {
71
+ s && t.requestState === d.NOT_STARTED && a();
72
+ }, [s, a, t.requestState]);
73
+ const H = {
74
+ createSession: N,
75
+ encodedSession: k,
76
+ error: z,
77
+ getAIStudioAgents: g,
78
+ hostAppName: w,
77
79
  hasCustomSuggestedQuestions: !!e,
78
- hasRequestInProgress: B,
79
- isAgentSelectorEnabled: w,
80
- isAIStudioAgentSelectorEnabled: Q,
80
+ hasRequestInProgress: F,
81
+ isAgentSelectorEnabled: Q,
82
+ isAIStudioAgentSelectorEnabled: T,
81
83
  isCitationsEnabled: n,
82
- isDebugModeEnabled: T,
83
- isMarkdownEnabled: h,
84
- isLoading: z,
84
+ isDebugModeEnabled: h,
85
+ isMarkdownEnabled: l,
86
+ isLoading: B,
85
87
  isOpen: s,
86
- isResetChatEnabled: l,
88
+ isResetChatEnabled: q,
87
89
  isStreamingEnabled: r,
88
90
  itemID: o,
89
- onClearAction: y,
90
- onCloseModal: E,
91
- onSelectAgent: c,
92
- onAgentEditorToggle: c,
93
- questions: D,
94
- retryQuestion: N,
95
- sendQuestion: O,
96
- shouldRenderProviders: j,
97
- stopQuestion: P,
98
- suggestedQuestionsRequestState: e ? t.requestState : a.SUCCESS,
99
- suggestedQuestions: e ? t.suggestions : U,
100
- warningNotice: _,
101
- warningNoticeAriaLabel: v
102
- }, G = Object.fromEntries(Object.entries(F).filter(([Y, H]) => H !== void 0));
103
- return /* @__PURE__ */ X(d, {
104
- ...G
91
+ itemIDs: u,
92
+ onClearAction: L,
93
+ onCloseModal: j,
94
+ onSelectAgent: i,
95
+ onAgentEditorToggle: i,
96
+ questions: G,
97
+ retryQuestion: O,
98
+ sendQuestion: P,
99
+ shouldRenderProviders: U,
100
+ stopQuestion: b,
101
+ suggestedQuestionsRequestState: e ? t.requestState : d.SUCCESS,
102
+ suggestedQuestions: e ? t.suggestions : _,
103
+ warningNotice: v,
104
+ warningNoticeAriaLabel: x
105
+ }, J = Object.fromEntries(Object.entries(H).filter(([D, K]) => K !== void 0));
106
+ return /* @__PURE__ */ $(f, {
107
+ ...J
105
108
  });
106
109
  };
107
110
  export {
108
- ne as ContentAnswersComponent,
109
- ne as default
111
+ re as ContentAnswersComponent,
112
+ re as default
110
113
  };
@@ -1,33 +1,34 @@
1
1
  import B from "lodash/camelCase";
2
- import o, { useCallback as Z } from "react";
3
- import { useAgentsDispatch as h } from "../../../contexts/AgentsContext.js";
4
- import { A as T, C as w, R as q } from "../../../../../chunks/types.js";
5
- import { SET_NEW_ITEM as U, UPDATE_QUESTION as ss, SET_MODAL_ERROR as es, SET_MODAL_SUCCESS as ts, SET_IS_LOADING as os, CLEAR_CONVERSATION_HISTORY as ns, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as D, SET_SUGGESTED_QUESTIONS as as } from "../actions.js";
6
- import { QuestionRecord as is } from "../records.js";
7
- import { defaultFormatSuggestions as us, defaultFormatCitations as ls } from "../utils/format.js";
8
- import { getAnswerRequest as cs } from "../utils/request.js";
9
- import Q from "../utils/stream.js";
10
- const Es = /Too Many Requests/i, j = "Agent not found";
11
- function ds({
2
+ import t, { useCallback as Z } from "react";
3
+ import { useAgentsDispatch as w } from "../../../contexts/AgentsContext.js";
4
+ import { A as T, C as U, R as j } from "../../../../../chunks/types.js";
5
+ import { SET_NEW_ITEM as ss, UPDATE_QUESTION as es, SET_MODAL_ERROR as os, SET_MODAL_SUCCESS as ts, SET_IS_LOADING as ns, CLEAR_CONVERSATION_HISTORY as as, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as x, SET_SUGGESTED_QUESTIONS as is } from "../actions.js";
6
+ import { QuestionRecord as us } from "../records.js";
7
+ import { defaultFormatSuggestions as ls, defaultFormatCitations as cs } from "../utils/format.js";
8
+ import { getAnswerRequest as rs } from "../utils/request.js";
9
+ import G from "../utils/stream.js";
10
+ const Es = /Too Many Requests/i, $ = "Agent not found";
11
+ function ms({
12
12
  contentAnswers: i,
13
- createSessionRequest: G,
14
- dispatchStateUpdate: t,
15
- fetchTimeout: m,
16
- getAgentConfig: S,
13
+ createSessionRequest: g,
14
+ dispatchStateUpdate: o,
15
+ fetchTimeout: S,
16
+ getAgentConfig: y,
17
17
  getAnswerStreaming: k,
18
- getAnswer: g,
19
- getSuggestedQuestions: d,
20
- isCitationsEnabled: rs,
21
- isStopResponseEnabled: p,
22
- isStreamingEnabled: O,
18
+ getAnswer: p,
19
+ getSuggestedQuestions: m,
20
+ isCitationsEnabled: fs,
21
+ isStopResponseEnabled: M,
22
+ isStreamingEnabled: N,
23
23
  itemID: l,
24
- formatCitations: I = ls
24
+ itemIDs: O,
25
+ formatCitations: F = cs
25
26
  }) {
26
- const x = o.useRef(null), M = h(), F = Z((s) => Array.isArray(s) ? I(s) : null, [I]);
27
- o.useEffect(
27
+ const V = t.useRef(null), I = w(), P = Z((s) => Array.isArray(s) ? F(s) : null, [F]);
28
+ t.useEffect(
28
29
  (s) => {
29
- l && l !== i.item.id && t({
30
- type: U,
30
+ l && l !== i.item.id && o({
31
+ type: ss,
31
32
  itemID: l,
32
33
  fileVersionID: s
33
34
  });
@@ -35,29 +36,29 @@ function ds({
35
36
  // eslint-disable-next-line react-hooks/exhaustive-deps
36
37
  [l]
37
38
  );
38
- const E = o.useCallback((s, e) => {
39
- t({
40
- type: ss,
39
+ const r = t.useCallback((s, e) => {
40
+ o({
41
+ type: es,
41
42
  newQuestion: s,
42
43
  session: e
43
- }), x.current = s;
44
- }, [t]), P = o.useCallback((s) => {
45
- t({
46
- type: es,
44
+ }), V.current = s;
45
+ }, [o]), v = t.useCallback((s) => {
46
+ o({
47
+ type: os,
47
48
  error: s
48
49
  });
49
- }, [t]), y = o.useCallback((s, e, n) => {
50
+ }, [o]), A = t.useCallback((s, e, n) => {
50
51
  const {
51
52
  answer: u,
52
53
  error: c,
53
54
  citations: a = [],
54
- createdAt: r = null,
55
+ createdAt: E = null,
55
56
  encodedSession: f = void 0,
56
57
  contextSession: _ = void 0
57
- } = s, R = e.set("citations", F(a)).merge({
58
+ } = s, R = e.set("citations", P(a)).merge({
58
59
  answer: u,
59
60
  error: c,
60
- created_at: r,
61
+ created_at: E,
61
62
  isLoading: !1,
62
63
  isCompleted: n
63
64
  });
@@ -66,71 +67,71 @@ function ds({
66
67
  encodedSession: f
67
68
  }), _ && (C = {
68
69
  contextSession: _
69
- }), E(R, C);
70
- }, [E, F]), b = o.useCallback(
70
+ }), r(R, C);
71
+ }, [r, P]), b = t.useCallback(
71
72
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
73
  (s, e) => {
73
- var R, C, N;
74
- const n = (s == null ? void 0 : s.message) || "", u = ((R = s == null ? void 0 : s.response) == null ? void 0 : R.status) === 429 || Es.test(n), c = (s == null ? void 0 : s.code) === j || (s == null ? void 0 : s.errorCode) === j, a = ((C = s == null ? void 0 : s.response) == null ? void 0 : C.status) === 204, r = ((N = s == null ? void 0 : s.response) == null ? void 0 : N.status) === 412, f = a ? T.NO_CONTENT : u ? T.RATE_LIMITING : r ? T.PRECONDITION_FAILED : c ? T.AGENT_NOT_FOUND : T.GENERAL, _ = e.merge({
74
+ var R, C, d;
75
+ const n = (s == null ? void 0 : s.message) || "", u = ((R = s == null ? void 0 : s.response) == null ? void 0 : R.status) === 429 || Es.test(n), c = (s == null ? void 0 : s.code) === $ || (s == null ? void 0 : s.errorCode) === $, a = ((C = s == null ? void 0 : s.response) == null ? void 0 : C.status) === 204, E = ((d = s == null ? void 0 : s.response) == null ? void 0 : d.status) === 412, f = a ? T.NO_CONTENT : u ? T.RATE_LIMITING : E ? T.PRECONDITION_FAILED : c ? T.AGENT_NOT_FOUND : T.GENERAL, _ = e.merge({
75
76
  error: f,
76
77
  isLoading: !1,
77
78
  isCompleted: !0
78
79
  });
79
- E(_, void 0);
80
+ r(_, void 0);
80
81
  },
81
- [E]
82
- ), A = o.useCallback(async (s, e) => {
82
+ [r]
83
+ ), L = t.useCallback(async (s, e) => {
83
84
  try {
84
85
  const n = {
85
86
  prompt: s.prompt,
86
87
  aiAgent: e || void 0
87
88
  }, u = `content-answers-${s.id}`;
88
89
  let c;
89
- O && (c = Q.createAbortRequest(u));
90
- const a = await cs(n, O, u, l, i, g, k, c, m);
91
- O ? Q.receiveStreamedResponse(u, a, (r) => {
90
+ N && (c = G.createAbortRequest(u));
91
+ const a = await rs(n, N, u, l, O, i, p, k, c, S);
92
+ N ? G.receiveStreamedResponse(u, a, (E) => {
92
93
  const {
93
94
  code: f,
94
95
  data: _,
95
96
  error: R,
96
97
  citations: C,
97
- contextSession: N,
98
- isCompleted: X,
99
- createdAt: Y
100
- } = r, z = {
98
+ contextSession: d,
99
+ isCompleted: Y,
100
+ createdAt: h
101
+ } = E, z = {
101
102
  answer: _,
102
103
  citations: C,
103
104
  error: R,
104
- contextSession: N,
105
- createdAt: Y
105
+ contextSession: d,
106
+ createdAt: h
106
107
  };
107
- a.ok && a.status === 200 ? y({
108
+ a.ok && a.status === 200 ? A({
108
109
  ...z
109
- }, s, X) : b({
110
+ }, s, Y) : b({
110
111
  response: a,
111
112
  code: f
112
113
  }, s);
113
- }, void 0, m) : (Object.entries(a).forEach(([r, f]) => {
114
- const _ = B(r);
115
- delete a[r], a[_] = f;
116
- }), y(a, s, !0));
114
+ }, void 0, S) : (Object.entries(a).forEach(([E, f]) => {
115
+ const _ = B(E);
116
+ delete a[E], a[_] = f;
117
+ }), A(a, s, !0));
117
118
  } catch (n) {
118
- if (p && n instanceof Error && n.name === "AbortError") {
119
+ if (M && n instanceof Error && n.name === "AbortError") {
119
120
  const u = s.set("error", []).merge({
120
121
  error: T.RESPONSE_STOPPED,
121
122
  isLoading: !1,
122
123
  isCompleted: !0
123
124
  });
124
- E(u);
125
+ r(u);
125
126
  } else
126
127
  b(n, s);
127
128
  }
128
- }, [O, l, i, g, k, m, y, b, p, E]), L = o.useCallback((s, e, n = !0) => {
129
+ }, [N, l, O, i, p, k, S, A, b, M, r]), Q = t.useCallback((s, e, n = !0) => {
129
130
  const u = (i == null ? void 0 : i.questions) || [];
130
131
  n && (s.id = `${u.length}`);
131
- const c = new is(s);
132
- return E(c), A(c, e), c;
133
- }, [i == null ? void 0 : i.questions, A, E]), v = o.useCallback((s) => {
132
+ const c = new us(s);
133
+ return r(c), L(c, e), c;
134
+ }, [i == null ? void 0 : i.questions, L, r]), q = t.useCallback((s) => {
134
135
  const {
135
136
  encoded_session: e,
136
137
  metadata: {
@@ -139,81 +140,82 @@ function ds({
139
140
  is_large_file: !1
140
141
  }
141
142
  } = s;
142
- t({
143
+ o({
143
144
  type: ts,
144
145
  encodedSession: e,
145
146
  isLargeFile: n
146
147
  });
147
- }, [t]), $ = o.useCallback(async () => {
148
+ }, [o]), W = t.useCallback(async () => {
148
149
  try {
149
- t({
150
- type: os,
150
+ o({
151
+ type: ns,
151
152
  isLoading: !0
152
153
  });
153
- const s = await G({
154
+ const s = await g({
154
155
  items: [i.item]
155
156
  }, l);
156
- v(s);
157
+ q(s);
157
158
  } catch {
158
- P(w.GENERAL);
159
+ v(U.GENERAL);
159
160
  }
160
- }, [t, G, i.item, l, v, P]), V = o.useCallback(() => {
161
- t({
162
- type: ns
161
+ }, [o, g, i.item, l, q, v]), D = t.useCallback(() => {
162
+ o({
163
+ type: as
163
164
  });
164
- }, [t]), W = o.useCallback(async (s, e) => {
165
- L({
165
+ }, [o]), H = t.useCallback(async (s, e) => {
166
+ Q({
166
167
  ...s.toJS(),
167
168
  answer: "",
168
169
  isLoading: !0,
169
170
  isCompleted: !1,
170
171
  error: null
171
172
  }, e, !1);
172
- }, [L]), H = o.useCallback((s) => {
173
- Q.abortRequest(`content-answers-${s.id}`, !0);
174
- }, []), J = o.useCallback(async (s) => {
175
- if (S)
173
+ }, [Q]), J = t.useCallback((s) => {
174
+ G.abortRequest(`content-answers-${s.id}`, !0);
175
+ }, []), K = t.useCallback(async (s) => {
176
+ if (y)
176
177
  try {
177
- const e = await S(s);
178
- M({
178
+ const e = await y(s);
179
+ I({
179
180
  type: "OVERRIDE_AGENT_CONFIG",
180
181
  agentName: s.name,
181
182
  agentConfig: e
182
183
  });
183
184
  } catch {
184
185
  }
185
- }, [M, S]), K = o.useCallback(async () => {
186
- if (d) {
187
- t({
188
- type: D,
189
- requestState: q.IN_PROGRESS
186
+ }, [I, y]), X = t.useCallback(async () => {
187
+ const s = Array.isArray(O) && O.length > 1;
188
+ if (!(!m || s)) {
189
+ o({
190
+ type: x,
191
+ requestState: j.IN_PROGRESS
190
192
  });
191
193
  try {
192
- const s = us(await d(l));
193
- t({
194
- type: as,
195
- suggestedQuestions: s
194
+ const e = ls(await m(l));
195
+ o({
196
+ type: is,
197
+ suggestedQuestions: e
196
198
  });
197
199
  } catch {
198
- t({
199
- type: D,
200
- requestState: q.ERROR
200
+ o({
201
+ type: x,
202
+ requestState: j.ERROR
201
203
  });
202
204
  }
203
205
  }
204
- }, [t, d, l]);
206
+ }, [o, m, l, O]);
205
207
  return {
206
- clearConversation: V,
207
- createSession: $,
208
- fetchAgentConfig: J,
209
- fetchSuggestedQuestions: K,
210
- retryQuestion: W,
211
- sendQuestion: L,
212
- sendQuestionAnswerRequest: A,
213
- stopQuestion: H,
214
- updateQuestionInState: E
208
+ clearConversation: D,
209
+ createSession: W,
210
+ fetchAgentConfig: K,
211
+ fetchSuggestedQuestions: X,
212
+ retryQuestion: H,
213
+ sendQuestion: Q,
214
+ sendQuestionAnswerRequest: L,
215
+ stopQuestion: J,
216
+ updateQuestionInState: r
215
217
  };
216
218
  }
217
219
  export {
218
- ds as useContentAnswers
220
+ ms as useContentAnswers
219
221
  };
@@ -1,11 +1,11 @@
1
- import b, { FETCH_TIMEOUT as m } from "./stream.js";
2
- const p = (i, s) => setTimeout(() => {
3
- b.abortRequest(i);
4
- }, s), E = async (i, s = !1, l, a, o, r, e, u, t) => {
1
+ import p, { FETCH_TIMEOUT as q } from "./stream.js";
2
+ const E = (i, s) => setTimeout(() => {
3
+ p.abortRequest(i);
4
+ }, s), m = async (i, s = !1, u, a, o, r, e, l, T, t) => {
5
5
  let n;
6
- const T = (t == null ? void 0 : t.initial) || m.initial, w = p(l, T);
7
- return s && e ? n = await e(i, a, u, o) : r && (n = await r(i, a, o)), clearTimeout(w), n;
6
+ const w = (t == null ? void 0 : t.initial) || q.initial, b = E(u, w);
7
+ return s && l ? n = await l(i, a, o, T, r) : e && (n = await e(i, a, o, r)), clearTimeout(b), n;
8
8
  };
9
9
  export {
10
- E as getAnswerRequest
10
+ m as getAnswerRequest
11
11
  };
@@ -1,43 +1,43 @@
1
1
  import "../../../../styles/suggested-questions.css";
2
- import { Text as u, LoadingIndicator as E } from "@box/blueprint-web";
3
- import { AlertTriangle as O } from "@box/blueprint-web-assets/icons/Line";
4
- import { Gray65 as R, Size4 as d } from "@box/blueprint-web-assets/tokens/tokens";
5
- import m from "clsx";
6
- import * as b from "react";
7
- import { useIntl as h } from "react-intl";
2
+ import { Text as E, LoadingIndicator as O } from "@box/blueprint-web";
3
+ import { AlertTriangle as R } from "@box/blueprint-web-assets/icons/Line";
4
+ import { Gray65 as b, Size4 as m } from "@box/blueprint-web-assets/tokens/tokens";
5
+ import g from "clsx";
6
+ import * as h from "react";
7
+ import { useIntl as u } from "react-intl";
8
8
  import { Suggestions as v } from "./suggestions.js";
9
9
  import { R as r } from "../../../../chunks/types.js";
10
- import { LOGGER_BASE_CONFIG as C } from "../common/constants.js";
10
+ import { LOGGER_BASE_CONFIG as N } from "../common/constants.js";
11
11
  import i from "./messages.js";
12
- import { jsxs as N, jsx as o } from "react/jsx-runtime";
13
- const w = "_wrapper_10vng_1", x = "_isSidebarOpen_10vng_5", G = "_label_10vng_9", T = "_loadingIndicator_10vng_20", y = "_alertIcon_10vng_28", a = {
14
- wrapper: w,
15
- isSidebarOpen: x,
12
+ import { jsxs as w, jsx as n } from "react/jsx-runtime";
13
+ const x = "_wrapper_10vng_1", C = "_isSidebarOpen_10vng_5", G = "_label_10vng_9", T = "_loadingIndicator_10vng_20", y = "_alertIcon_10vng_28", a = {
14
+ wrapper: x,
15
+ isSidebarOpen: C,
16
16
  label: G,
17
17
  loadingIndicator: T,
18
18
  alertIcon: y
19
19
  }, H = ({
20
- askSuggestedQuestion: g,
21
- hasCustomSuggestedQuestions: p,
20
+ askSuggestedQuestion: p,
21
+ hasCustomSuggestedQuestions: d,
22
22
  isLoading: _,
23
23
  isSidebarOpen: t = !1,
24
24
  recordAction: s,
25
25
  setAskSuggestedQuestion: l,
26
- suggestedQuestions: S,
27
- suggestedQuestionsRequestState: n = r.SUCCESS
26
+ suggestedQuestions: f,
27
+ suggestedQuestionsRequestState: o = r.SUCCESS
28
28
  }) => {
29
29
  const {
30
30
  formatMessage: e
31
- } = h(), f = b.useCallback((c) => {
31
+ } = u(), S = h.useCallback((c) => {
32
32
  l && (l(c), s && c && s({
33
- ...C,
33
+ ...N,
34
34
  target: "suggested_questions",
35
35
  data: {
36
- selectedQuestion: p ? "dynamic" : c
36
+ selectedQuestion: d ? "dynamic" : c
37
37
  }
38
38
  }));
39
- }, [l, s]), I = () => {
40
- switch (n) {
39
+ }, [l, s, d]), I = () => {
40
+ switch (o) {
41
41
  case r.IN_PROGRESS:
42
42
  return e(i.loadingSuggestedQuestions);
43
43
  case r.ERROR:
@@ -46,33 +46,33 @@ const w = "_wrapper_10vng_1", x = "_isSidebarOpen_10vng_5", G = "_label_10vng_9"
46
46
  return e(i.suggestedQuestions);
47
47
  }
48
48
  };
49
- return /* @__PURE__ */ N("div", {
50
- className: m(a.wrapper, t && a.isSidebarOpen),
51
- children: [/* @__PURE__ */ o(u, {
49
+ return /* @__PURE__ */ w("div", {
50
+ className: g(a.wrapper, t && a.isSidebarOpen),
51
+ children: [/* @__PURE__ */ n(E, {
52
52
  as: "p",
53
- className: m(a.label, t && a.isSidebarOpen),
53
+ className: g(a.label, t && a.isSidebarOpen),
54
54
  color: "textOnLightSecondary",
55
55
  children: I()
56
- }), n === r.SUCCESS && /* @__PURE__ */ o(v, {
57
- askSuggestedQuestion: g,
56
+ }), o === r.SUCCESS && /* @__PURE__ */ n(v, {
57
+ askSuggestedQuestion: p,
58
58
  isLoading: _,
59
59
  isSidebarOpen: t,
60
- onSuggestedQuestionClick: f,
61
- suggestedQuestions: S
62
- }), n === r.IN_PROGRESS && /* @__PURE__ */ o("div", {
60
+ onSuggestedQuestionClick: S,
61
+ suggestedQuestions: f
62
+ }), o === r.IN_PROGRESS && /* @__PURE__ */ n("div", {
63
63
  className: a.loadingIndicator,
64
- children: /* @__PURE__ */ o(E, {
64
+ children: /* @__PURE__ */ n(O, {
65
65
  "aria-label": e(i.loadingSuggestedQuestions),
66
66
  className: a.loadingIndicator,
67
67
  variant: "dark"
68
68
  })
69
- }), n === r.ERROR && /* @__PURE__ */ o(O, {
69
+ }), o === r.ERROR && /* @__PURE__ */ n(R, {
70
70
  className: a.alertIcon,
71
- color: R,
71
+ color: b,
72
72
  "data-testid": "content-answers-suggested-questions-failed-alert-icon",
73
- height: d,
73
+ height: m,
74
74
  role: "presentation",
75
- width: d
75
+ width: m
76
76
  })]
77
77
  });
78
78
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/box-ai-content-answers",
3
- "version": "0.68.0",
3
+ "version": "0.69.1",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",
@@ -54,5 +54,5 @@
54
54
  "**/*.css"
55
55
  ],
56
56
  "license": "SEE LICENSE IN LICENSE",
57
- "gitHead": "8371b326ea09e2a07955fb57e63e15e9b14abc4c"
57
+ "gitHead": "be7f7c7fdf17d8843ca75e4d28e6d8e3109dc9ee"
58
58
  }
@@ -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, 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;
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, itemIDs, onCloseModal, shouldRenderProviders, suggestedQuestions, warningNotice, warningNoticeAriaLabel, }: ContentAnswersComponentProps) => import("react/jsx-runtime").JSX.Element;
6
6
  export default ContentAnswersComponent;
@@ -1,7 +1,7 @@
1
1
  import { type AgentType, type QuestionType } from '../../../types';
2
2
  import { type QuestionRecordType } from '../records';
3
3
  import { type UseContentAnswersProps } from '../types';
4
- export declare function useContentAnswers({ contentAnswers, createSessionRequest, dispatchStateUpdate, fetchTimeout, getAgentConfig, getAnswerStreaming, getAnswer, getSuggestedQuestions, isCitationsEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, formatCitations, }: UseContentAnswersProps): {
4
+ export declare function useContentAnswers({ contentAnswers, createSessionRequest, dispatchStateUpdate, fetchTimeout, getAgentConfig, getAnswerStreaming, getAnswer, getSuggestedQuestions, isCitationsEnabled, isStopResponseEnabled, isStreamingEnabled, itemID, itemIDs, formatCitations, }: UseContentAnswersProps): {
5
5
  clearConversation: () => void;
6
6
  createSession: () => Promise<void>;
7
7
  fetchAgentConfig: (agent: AgentType) => Promise<void>;
@@ -43,8 +43,8 @@ export type PremissionsResponse = {
43
43
  };
44
44
  export type agentFetcherType = (payload: Record<string, unknown>) => Promise<unknown>;
45
45
  export type SuggestedQuestionFetcherType = (itemID?: string) => Promise<SuggestedQuestionsResponse>;
46
- export type fetcherType = (payload: Record<string, unknown>, itemID?: string, state?: ContentAnswersRecordType) => Promise<unknown>;
47
- export type fetcherStreamingType = (payload: Record<string, unknown>, itemID?: string, abortController?: AbortController, state?: ContentAnswersRecordType) => Promise<unknown>;
46
+ export type fetcherType = (payload: Record<string, unknown>, itemID?: string, itemIDs?: Array<string>, state?: ContentAnswersRecordType) => Promise<unknown>;
47
+ export type fetcherStreamingType = (payload: Record<string, unknown>, itemID?: string, itemIDs?: Array<string>, abortController?: AbortController, state?: ContentAnswersRecordType) => Promise<unknown>;
48
48
  export type fetchError = {
49
49
  message?: string;
50
50
  response?: {
@@ -76,7 +76,13 @@ export type ApiWrapperProps = {
76
76
  isMarkdownEnabled?: boolean;
77
77
  isOpen?: boolean;
78
78
  isStreamingEnabled?: boolean;
79
+ /**
80
+ * Item ID for the content answers
81
+ * Prefer passing itemIDs instead since this prop will be removed soon
82
+ * @deprecated
83
+ */
79
84
  itemID?: string;
85
+ itemIDs?: Array<string>;
80
86
  onCloseModal?: () => void;
81
87
  shouldRenderProviders?: boolean;
82
88
  suggestedQuestionsRequestState?: REQUEST_STATE;
@@ -1,4 +1,4 @@
1
1
  import { type ContentAnswersRecordType } from '../records';
2
2
  import { type fetcherStreamingType, type fetcherType, type StreamResponseTimeout } from '../types';
3
- declare const getAnswerRequest: (payload: Record<string, unknown>, isStreamingRequest: boolean, requestID: string, itemID?: string, state?: ContentAnswersRecordType, fetcher?: fetcherType, fetcherStreaming?: fetcherStreamingType, abortController?: AbortController, fetchTimeout?: StreamResponseTimeout) => Promise<any>;
3
+ declare const getAnswerRequest: (payload: Record<string, unknown>, isStreamingRequest: boolean, requestID: string, itemID?: string, itemIDs?: Array<string>, state?: ContentAnswersRecordType, fetcher?: fetcherType, fetcherStreaming?: fetcherStreamingType, abortController?: AbortController, fetchTimeout?: StreamResponseTimeout) => Promise<any>;
4
4
  export { getAnswerRequest };