@box/box-ai-content-answers 0.53.0 → 0.54.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.
Files changed (54) hide show
  1. package/chunks/types.js +4 -1
  2. package/esm/index.js +10 -9
  3. package/esm/lib/components/api-wrapper/actions.js +6 -4
  4. package/esm/lib/components/api-wrapper/content-answers-component.js +94 -48
  5. package/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +139 -119
  6. package/esm/lib/components/api-wrapper/records.js +13 -7
  7. package/esm/lib/components/api-wrapper/reducer.js +30 -22
  8. package/esm/lib/components/api-wrapper/utils/format.js +6 -2
  9. package/esm/lib/components/chat/chat.js +57 -55
  10. package/esm/lib/components/suggested-questions/messages.js +10 -2
  11. package/esm/lib/components/suggested-questions/suggested-questions.js +60 -44
  12. package/esm/lib/components/suggested-questions/suggestions.js +35 -0
  13. package/i18n/bn-IN.js +2 -0
  14. package/i18n/da-DK.js +2 -0
  15. package/i18n/de-DE.js +2 -0
  16. package/i18n/en-AU.js +2 -0
  17. package/i18n/en-CA.js +2 -0
  18. package/i18n/en-GB.js +2 -0
  19. package/i18n/en-US.js +2 -0
  20. package/i18n/en-US.properties +4 -0
  21. package/i18n/en-x-pseudo.js +2 -0
  22. package/i18n/es-419.js +2 -0
  23. package/i18n/es-ES.js +2 -0
  24. package/i18n/fi-FI.js +2 -0
  25. package/i18n/fr-CA.js +2 -0
  26. package/i18n/fr-FR.js +2 -0
  27. package/i18n/hi-IN.js +2 -0
  28. package/i18n/it-IT.js +2 -0
  29. package/i18n/ja-JP.js +2 -0
  30. package/i18n/json/src/lib/components/suggested-questions/messages.json +1 -1
  31. package/i18n/ko-KR.js +2 -0
  32. package/i18n/nb-NO.js +2 -0
  33. package/i18n/nl-NL.js +2 -0
  34. package/i18n/pl-PL.js +2 -0
  35. package/i18n/pt-BR.js +2 -0
  36. package/i18n/ru-RU.js +2 -0
  37. package/i18n/sv-SE.js +2 -0
  38. package/i18n/tr-TR.js +2 -0
  39. package/i18n/zh-CN.js +2 -0
  40. package/i18n/zh-TW.js +2 -0
  41. package/package.json +2 -2
  42. package/styles/suggested-questions.css +1 -1
  43. package/styles/suggestions.css +1 -0
  44. package/types/lib/components/api-wrapper/actions.d.ts +2 -0
  45. package/types/lib/components/api-wrapper/content-answers-component.d.ts +1 -1
  46. package/types/lib/components/api-wrapper/hooks/useContentAnswers.d.ts +2 -1
  47. package/types/lib/components/api-wrapper/records.d.ts +8 -1
  48. package/types/lib/components/api-wrapper/types.d.ts +14 -3
  49. package/types/lib/components/api-wrapper/utils/format.d.ts +3 -2
  50. package/types/lib/components/chat/chat.d.ts +1 -1
  51. package/types/lib/components/suggested-questions/messages.d.ts +10 -0
  52. package/types/lib/components/suggested-questions/suggested-questions.d.ts +6 -4
  53. package/types/lib/components/suggested-questions/suggestions.d.ts +13 -0
  54. package/types/lib/types.d.ts +13 -0
package/chunks/types.js CHANGED
@@ -2,8 +2,11 @@ let n = /* @__PURE__ */ function(e) {
2
2
  return e.GENERAL = "general", e.RATE_LIMITING = "rate_limiting", e.NO_CONTENT = "no_content", e.RESPONSE_FAILED = "response_failed", e.RESPONSE_INTERRUPTED = "response_interrupted", e.RESPONSE_STOPPED = "response_stopped", e;
3
3
  }({}), r = /* @__PURE__ */ function(e) {
4
4
  return e.LARGE_FILE = "large_file", e.GENERAL = "general", e;
5
+ }({}), t = /* @__PURE__ */ function(e) {
6
+ return e.NOT_STARTED = "not_started", e.IN_PROGRESS = "in_progress", e.SUCCESS = "success", e.ERROR = "error", e.CANCELLED = "cancelled", e;
5
7
  }({});
6
8
  export {
7
9
  n as A,
8
- r as C
10
+ r as C,
11
+ t as R
9
12
  };
package/esm/index.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import { BoxAiContentAnswers as e } from "./lib/box-ai-content-answers.js";
2
- import { AnswerContent as n } from "./lib/components/answer/answer-content.js";
3
- import { withApiWrapper as R } from "./lib/components/api-wrapper/api-wrapper.js";
4
- import { IntelligenceModal as A } from "./lib/components/modal/modal.js";
5
- import { A as m, C as s } from "../chunks/types.js";
2
+ import { AnswerContent as R } from "./lib/components/answer/answer-content.js";
3
+ import { withApiWrapper as p } from "./lib/components/api-wrapper/api-wrapper.js";
4
+ import { IntelligenceModal as E } from "./lib/components/modal/modal.js";
5
+ import { A as x, C as a, R as f } from "../chunks/types.js";
6
6
  export {
7
- m as ANSWER_ERROR,
8
- n as AnswerContent,
7
+ x as ANSWER_ERROR,
8
+ R as AnswerContent,
9
9
  e as BoxAiContentAnswers,
10
- s as CONTENT_ERROR,
11
- A as IntelligenceModal,
12
- R as withApiWrapper
10
+ a as CONTENT_ERROR,
11
+ E as IntelligenceModal,
12
+ f as REQUEST_STATE,
13
+ p as withApiWrapper
13
14
  };
@@ -1,9 +1,11 @@
1
- const E = "CLEAR_CONVERSATION_HISTORY", S = "SET_IS_LOADING", _ = "SET_MODAL_ERROR", T = "SET_MODAL_SUCCESS", O = "SET_NEW_ITEM", A = "UPDATE_QUESTION";
1
+ const E = "CLEAR_CONVERSATION_HISTORY", S = "SET_IS_LOADING", T = "SET_MODAL_ERROR", _ = "SET_MODAL_SUCCESS", O = "SET_NEW_ITEM", I = "UPDATE_QUESTION", U = "SET_SUGGESTED_QUESTIONS", A = "SET_SUGGESTED_QUESTIONS_REQUEST_STATE";
2
2
  export {
3
3
  E as CLEAR_CONVERSATION_HISTORY,
4
4
  S as SET_IS_LOADING,
5
- _ as SET_MODAL_ERROR,
6
- T as SET_MODAL_SUCCESS,
5
+ T as SET_MODAL_ERROR,
6
+ _ as SET_MODAL_SUCCESS,
7
7
  O as SET_NEW_ITEM,
8
- A as UPDATE_QUESTION
8
+ U as SET_SUGGESTED_QUESTIONS,
9
+ A as SET_SUGGESTED_QUESTIONS_REQUEST_STATE,
10
+ I as UPDATE_QUESTION
9
11
  };
@@ -1,56 +1,102 @@
1
- import { useReducer as w } from "react";
2
- import { useContentAnswers as C } from "./hooks/useContentAnswers.js";
3
- import { ContentAnswersRecord as p, ContentAnswersItemRecord as R } from "./records.js";
4
- import h from "./reducer.js";
5
- import { jsx as S } from "react/jsx-runtime";
6
- const j = ({
7
- WrappedComponent: o,
8
- ...e
1
+ import { useReducer as D, useEffect as F } from "react";
2
+ import { R as d } from "../../../../chunks/types.js";
3
+ import { useContentAnswers as G } from "./hooks/useContentAnswers.js";
4
+ import { ContentAnswersRecord as H, ContentAnswersItemRecord as I } from "./records.js";
5
+ import J from "./reducer.js";
6
+ import { jsx as K } from "react/jsx-runtime";
7
+ const ee = ({
8
+ WrappedComponent: a,
9
+ createSessionRequest: f,
10
+ getAgentConfig: m,
11
+ fetchTimeout: g,
12
+ formatCitations: S,
13
+ getAnswer: A,
14
+ getAnswerStreaming: p,
15
+ getSuggestedQuestions: t,
16
+ hostAppName: R,
17
+ isAgentSelectorEnabled: C,
18
+ isCitationsEnabled: n,
19
+ isDebugModeEnabled: l,
20
+ isMarkdownEnabled: w,
21
+ isOpen: s,
22
+ isResetChatEnabled: Q,
23
+ isStreamingEnabled: r,
24
+ itemID: o,
25
+ onCloseModal: T,
26
+ suggestedQuestions: h,
27
+ warningNotice: q,
28
+ warningNoticeAriaLabel: E
9
29
  }) => {
10
- const {
11
- itemID: s
12
- } = e, [t, r] = w(h, new p({
13
- item: new R({
14
- id: s
30
+ const [c, j] = D(J, new H({
31
+ item: new I({
32
+ id: o
15
33
  })
16
34
  })), {
17
- clearConversation: i,
18
- createSession: c,
19
- fetchAgentConfig: n,
20
- retryQuestion: d,
21
- sendQuestion: a,
22
- stopQuestion: m
23
- } = C({
24
- contentAnswers: t,
25
- dispatchStateUpdate: r,
26
- ...e
35
+ clearConversation: v,
36
+ createSession: U,
37
+ fetchAgentConfig: u,
38
+ fetchSuggestedQuestions: i,
39
+ retryQuestion: _,
40
+ sendQuestion: x,
41
+ stopQuestion: P
42
+ } = G({
43
+ contentAnswers: c,
44
+ createSessionRequest: f,
45
+ dispatchStateUpdate: j,
46
+ fetchTimeout: g,
47
+ formatCitations: S,
48
+ getAgentConfig: m,
49
+ getAnswerStreaming: p,
50
+ getAnswer: A,
51
+ getSuggestedQuestions: t,
52
+ isCitationsEnabled: n,
53
+ isStreamingEnabled: r,
54
+ itemID: o
27
55
  }), {
28
- encodedSession: u,
29
- error: f,
30
- isLoading: A,
31
- hasRequestInProgress: g = !1,
32
- questions: l
33
- } = t;
34
- return /* @__PURE__ */ S(o, {
35
- ...{
36
- createSession: c,
37
- encodedSession: u,
38
- error: f,
39
- hasRequestInProgress: g,
40
- isLoading: A,
41
- questions: l,
42
- onClearAction: i,
43
- onSelectAgent: n,
44
- onAgentEditorToggle: n,
45
- retryQuestion: d,
46
- sendQuestion: a,
47
- shouldRenderProviders: !1,
48
- stopQuestion: m
49
- },
50
- ...e
56
+ encodedSession: y,
57
+ error: L,
58
+ isLoading: N,
59
+ hasRequestInProgress: O = !1,
60
+ questions: b,
61
+ suggestedQuestions: e
62
+ } = c;
63
+ F(() => {
64
+ s && e.requestState === d.NOT_STARTED && i();
65
+ }, [s, i, e.requestState]);
66
+ const k = {
67
+ createSession: U,
68
+ encodedSession: y,
69
+ error: L,
70
+ hostAppName: R,
71
+ hasRequestInProgress: O,
72
+ isAgentSelectorEnabled: C,
73
+ isCitationsEnabled: n,
74
+ isDebugModeEnabled: l,
75
+ isMarkdownEnabled: w,
76
+ isLoading: N,
77
+ isOpen: s,
78
+ isResetChatEnabled: Q,
79
+ isStreamingEnabled: r,
80
+ itemID: o,
81
+ onClearAction: v,
82
+ onCloseModal: T,
83
+ onSelectAgent: u,
84
+ onAgentEditorToggle: u,
85
+ questions: b,
86
+ retryQuestion: _,
87
+ sendQuestion: x,
88
+ shouldRenderProviders: !1,
89
+ stopQuestion: P,
90
+ suggestedQuestionsRequestState: t ? e.requestState : d.SUCCESS,
91
+ suggestedQuestions: t ? e.suggestions : h,
92
+ warningNotice: q,
93
+ warningNoticeAriaLabel: E
94
+ }, z = Object.fromEntries(Object.entries(k).filter(([M, B]) => B !== void 0));
95
+ return /* @__PURE__ */ K(a, {
96
+ ...z
51
97
  });
52
98
  };
53
99
  export {
54
- j as ContentAnswersComponent,
55
- j as default
100
+ ee as ContentAnswersComponent,
101
+ ee as default
56
102
  };
@@ -1,154 +1,154 @@
1
- import h from "lodash/camelCase";
2
- import o, { useCallback as V } from "react";
3
- import { useAgentsDispatch as W } from "../../../contexts/AgentsContext.js";
4
- import { A as T, C as H } from "../../../../../chunks/types.js";
5
- import { SET_NEW_ITEM as J, UPDATE_QUESTION as K, SET_MODAL_ERROR as X, SET_MODAL_SUCCESS as Y, SET_IS_LOADING as z, CLEAR_CONVERSATION_HISTORY as B } from "../actions.js";
6
- import { QuestionRecord as D } from "../records.js";
7
- import { defaultFormatCitations as Z } from "../utils/format.js";
8
- import { getAnswerRequest as w } from "../utils/request.js";
9
- import b from "../utils/stream.js";
10
- const U = /Too Many Requests/i;
11
- function Cs({
12
- contentAnswers: a,
13
- createSessionRequest: L,
14
- dispatchStateUpdate: n,
1
+ import K from "lodash/camelCase";
2
+ import t, { useCallback as X } from "react";
3
+ import { useAgentsDispatch as Y } from "../../../contexts/AgentsContext.js";
4
+ import { A as b, C as h, R as q } from "../../../../../chunks/types.js";
5
+ import { SET_NEW_ITEM as z, UPDATE_QUESTION as B, SET_MODAL_ERROR as D, SET_MODAL_SUCCESS as Z, SET_IS_LOADING as w, CLEAR_CONVERSATION_HISTORY as U, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as F, SET_SUGGESTED_QUESTIONS as ss } from "../actions.js";
6
+ import { QuestionRecord as es } from "../records.js";
7
+ import { defaultFormatSuggestions as os, defaultFormatCitations as ts } from "../utils/format.js";
8
+ import { getAnswerRequest as as } from "../utils/request.js";
9
+ import L from "../utils/stream.js";
10
+ const ns = /Too Many Requests/i;
11
+ function ms({
12
+ contentAnswers: n,
13
+ createSessionRequest: Q,
14
+ dispatchStateUpdate: o,
15
15
  fetchTimeout: k,
16
- getAgentConfig: _,
17
- getAnswerStreaming: Q,
18
- getAnswer: g,
19
- isCitationsEnabled: ss,
20
- isStreamingEnabled: R,
21
- itemID: c,
22
- sendLog: es,
23
- formatCitations: S = Z
16
+ getAgentConfig: T,
17
+ getAnswerStreaming: p,
18
+ getAnswer: G,
19
+ getSuggestedQuestions: m,
20
+ isCitationsEnabled: rs,
21
+ isStreamingEnabled: _,
22
+ itemID: u,
23
+ formatCitations: g = ts
24
24
  }) {
25
- const G = o.useRef(null), I = W(), M = V((s) => Array.isArray(s) ? S(s) : null, [S]);
26
- o.useEffect(
25
+ const P = t.useRef(null), A = Y(), I = X((s) => Array.isArray(s) ? g(s) : null, [g]);
26
+ t.useEffect(
27
27
  (s) => {
28
- c && c !== a.item.id && n({
29
- type: J,
30
- itemID: c,
28
+ u && u !== n.item.id && o({
29
+ type: z,
30
+ itemID: u,
31
31
  fileVersionID: s
32
32
  });
33
33
  },
34
34
  // eslint-disable-next-line react-hooks/exhaustive-deps
35
- [c]
35
+ [u]
36
36
  );
37
- const E = o.useCallback((s, e) => {
38
- n({
39
- type: K,
37
+ const C = t.useCallback((s, e) => {
38
+ o({
39
+ type: B,
40
40
  newQuestion: s,
41
41
  session: e
42
- }), G.current = s;
43
- }, [n]), v = o.useCallback((s) => {
44
- n({
45
- type: X,
42
+ }), P.current = s;
43
+ }, [o]), M = t.useCallback((s) => {
44
+ o({
45
+ type: D,
46
46
  error: s
47
47
  });
48
- }, [n]), m = o.useCallback((s, e, i) => {
48
+ }, [o]), y = t.useCallback((s, e, r) => {
49
49
  const {
50
- answer: f,
51
- error: r,
52
- citations: t = [],
53
- createdAt: C = null,
50
+ answer: E,
51
+ error: i,
52
+ citations: a = [],
53
+ createdAt: f = null,
54
54
  encodedSession: l = void 0,
55
- contextSession: u = void 0
56
- } = s, O = e.set("citations", M(t)).merge({
57
- answer: f,
58
- error: r,
59
- created_at: C,
55
+ contextSession: c = void 0
56
+ } = s, d = e.set("citations", I(a)).merge({
57
+ answer: E,
58
+ error: i,
59
+ created_at: f,
60
60
  isLoading: !1,
61
- isCompleted: i
61
+ isCompleted: r
62
62
  });
63
- let d;
64
- l && (d = {
63
+ let R;
64
+ l && (R = {
65
65
  encodedSession: l
66
- }), u && (d = {
67
- contextSession: u
68
- }), E(O, d);
69
- }, [E, M]), p = o.useCallback(
66
+ }), c && (R = {
67
+ contextSession: c
68
+ }), C(d, R);
69
+ }, [C, I]), S = t.useCallback(
70
70
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
71
  (s, e) => {
72
- var l, u;
73
- const i = (s == null ? void 0 : s.message) || "", f = ((l = s == null ? void 0 : s.response) == null ? void 0 : l.status) === 429 || U.test(i), r = ((u = s == null ? void 0 : s.response) == null ? void 0 : u.status) === 204, t = r ? T.NO_CONTENT : f ? T.RATE_LIMITING : T.GENERAL, C = e.merge({
74
- error: t,
72
+ var l, c;
73
+ const r = (s == null ? void 0 : s.message) || "", E = ((l = s == null ? void 0 : s.response) == null ? void 0 : l.status) === 429 || ns.test(r), i = ((c = s == null ? void 0 : s.response) == null ? void 0 : c.status) === 204, a = i ? b.NO_CONTENT : E ? b.RATE_LIMITING : b.GENERAL, f = e.merge({
74
+ error: a,
75
75
  isLoading: !1,
76
76
  isCompleted: !0
77
77
  });
78
- E(C, void 0);
78
+ C(f, void 0);
79
79
  },
80
- [E]
81
- ), y = o.useCallback(async (s, e) => {
80
+ [C]
81
+ ), O = t.useCallback(async (s, e) => {
82
82
  try {
83
- const i = {
83
+ const r = {
84
84
  prompt: s.prompt,
85
85
  aiAgent: e || void 0
86
- }, f = `content-answers-${s.id}`;
87
- let r;
88
- R && (r = b.createAbortRequest(f));
89
- const t = await w(i, R, c, a, g, Q, r);
90
- R ? t.ok && t.status === 200 ? b.receiveStreamedResponse(f, t, (C) => {
86
+ }, E = `content-answers-${s.id}`;
87
+ let i;
88
+ _ && (i = L.createAbortRequest(E));
89
+ const a = await as(r, _, u, n, G, p, i);
90
+ _ ? a.ok && a.status === 200 ? L.receiveStreamedResponse(E, a, (f) => {
91
91
  const {
92
92
  data: l,
93
- error: u,
94
- citations: O,
95
- contextSession: d,
96
- isCompleted: $
97
- } = C;
98
- m({
93
+ error: c,
94
+ citations: d,
95
+ contextSession: R,
96
+ isCompleted: J
97
+ } = f;
98
+ y({
99
99
  ...{
100
100
  answer: l,
101
- citations: O,
102
- error: u,
103
- contextSession: d
101
+ citations: d,
102
+ error: c,
103
+ contextSession: R
104
104
  }
105
- }, s, $);
106
- }, void 0, k) : p({
107
- response: t
108
- }, s) : (Object.entries(t).forEach(([C, l]) => {
109
- const u = h(C);
110
- delete t[C], t[u] = l;
111
- }), m(t, s, !0));
112
- } catch (i) {
113
- p(i, s);
105
+ }, s, J);
106
+ }, void 0, k) : S({
107
+ response: a
108
+ }, s) : (Object.entries(a).forEach(([f, l]) => {
109
+ const c = K(f);
110
+ delete a[f], a[c] = l;
111
+ }), y(a, s, !0));
112
+ } catch (r) {
113
+ S(r, s);
114
114
  }
115
- }, [R, c, a, g, Q, k, m, p]), N = o.useCallback((s, e, i = !0) => {
116
- const f = (a == null ? void 0 : a.questions) || [];
117
- i && (s.id = `${f.length}`);
118
- const r = new D(s);
119
- return E(r), y(r, e), r;
120
- }, [a == null ? void 0 : a.questions, y, E]), A = o.useCallback((s) => {
115
+ }, [_, u, n, G, p, k, y, S]), N = t.useCallback((s, e, r = !0) => {
116
+ const E = (n == null ? void 0 : n.questions) || [];
117
+ r && (s.id = `${E.length}`);
118
+ const i = new es(s);
119
+ return C(i), O(i, e), i;
120
+ }, [n == null ? void 0 : n.questions, O, C]), v = t.useCallback((s) => {
121
121
  const {
122
122
  encoded_session: e,
123
123
  metadata: {
124
- is_large_file: i
124
+ is_large_file: r
125
125
  } = {
126
126
  is_large_file: !1
127
127
  }
128
128
  } = s;
129
- n({
130
- type: Y,
129
+ o({
130
+ type: Z,
131
131
  encodedSession: e,
132
- isLargeFile: i
132
+ isLargeFile: r
133
133
  });
134
- }, [n]), q = o.useCallback(async () => {
134
+ }, [o]), j = t.useCallback(async () => {
135
135
  try {
136
- n({
137
- type: z,
136
+ o({
137
+ type: w,
138
138
  isLoading: !0
139
139
  });
140
- const s = await L({
141
- items: [a.item]
142
- }, c);
143
- A(s);
140
+ const s = await Q({
141
+ items: [n.item]
142
+ }, u);
143
+ v(s);
144
144
  } catch {
145
- v(H.GENERAL);
145
+ M(h.GENERAL);
146
146
  }
147
- }, [n, L, a.item, c, A, v]), F = o.useCallback(() => {
148
- n({
149
- type: B
147
+ }, [o, Q, n.item, u, v, M]), x = t.useCallback(() => {
148
+ o({
149
+ type: U
150
150
  });
151
- }, [n]), j = o.useCallback(async (s, e) => {
151
+ }, [o]), $ = t.useCallback(async (s, e) => {
152
152
  N({
153
153
  ...s.toJS(),
154
154
  answer: "",
@@ -156,31 +156,51 @@ function Cs({
156
156
  isCompleted: !1,
157
157
  error: null
158
158
  }, e, !1);
159
- }, [N]), x = o.useCallback((s) => {
160
- b.abortRequest(`content-answers-${s.id}`, !0);
161
- }, []), P = o.useCallback(async (s) => {
162
- if (_)
159
+ }, [N]), V = t.useCallback((s) => {
160
+ L.abortRequest(`content-answers-${s.id}`, !0);
161
+ }, []), W = t.useCallback(async (s) => {
162
+ if (T)
163
163
  try {
164
- const e = await _(s);
165
- I({
164
+ const e = await T(s);
165
+ A({
166
166
  type: "OVERRIDE_AGENT_CONFIG",
167
167
  agentName: s.name,
168
168
  agentConfig: e
169
169
  });
170
170
  } catch {
171
171
  }
172
- }, [I, _]);
172
+ }, [A, T]), H = t.useCallback(async () => {
173
+ if (m) {
174
+ o({
175
+ type: F,
176
+ requestState: q.IN_PROGRESS
177
+ });
178
+ try {
179
+ const s = os(await m(u));
180
+ o({
181
+ type: ss,
182
+ suggestedQuestions: s
183
+ });
184
+ } catch {
185
+ o({
186
+ type: F,
187
+ requestState: q.ERROR
188
+ });
189
+ }
190
+ }
191
+ }, [o, m, u]);
173
192
  return {
174
- clearConversation: F,
175
- createSession: q,
176
- fetchAgentConfig: P,
177
- retryQuestion: j,
193
+ clearConversation: x,
194
+ createSession: j,
195
+ fetchAgentConfig: W,
196
+ fetchSuggestedQuestions: H,
197
+ retryQuestion: $,
178
198
  sendQuestion: N,
179
- sendQuestionAnswerRequest: y,
180
- stopQuestion: x,
181
- updateQuestionInState: E
199
+ sendQuestionAnswerRequest: O,
200
+ stopQuestion: V,
201
+ updateQuestionInState: C
182
202
  };
183
203
  }
184
204
  export {
185
- Cs as useContentAnswers
205
+ ms as useContentAnswers
186
206
  };
@@ -1,21 +1,26 @@
1
1
  import { Record as e } from "immutable";
2
+ import { R as s } from "../../../../chunks/types.js";
2
3
  const n = e({
3
4
  has_streamed_responses: !0,
4
5
  has_citations_enabled: !1
5
- }), s = e({
6
+ }), o = e({
6
7
  type: "file",
7
8
  id: null,
8
9
  version_id: null
9
10
  }), t = e({
11
+ suggestions: [],
12
+ requestState: s.NOT_STARTED
13
+ }), i = e({
10
14
  config: new n(),
11
15
  encodedSession: null,
12
16
  contextSession: null,
13
17
  error: null,
14
18
  isLoading: !1,
15
19
  hasRequestInProgress: !1,
16
- item: new s(),
17
- questions: []
18
- }), l = e({
20
+ item: new o(),
21
+ questions: [],
22
+ suggestedQuestions: new t()
23
+ }), u = e({
19
24
  answer: null,
20
25
  citations: [],
21
26
  created_at: null,
@@ -27,7 +32,8 @@ const n = e({
27
32
  });
28
33
  export {
29
34
  n as ContentAnswersConfigRecord,
30
- s as ContentAnswersItemRecord,
31
- t as ContentAnswersRecord,
32
- l as QuestionRecord
35
+ o as ContentAnswersItemRecord,
36
+ i as ContentAnswersRecord,
37
+ u as QuestionRecord,
38
+ t as SuggestedQuestionsRecord
33
39
  };
@@ -1,46 +1,54 @@
1
- import { C as S } from "../../../../chunks/types.js";
2
- import { SET_MODAL_SUCCESS as E, SET_MODAL_ERROR as I, UPDATE_QUESTION as R, CLEAR_CONVERSATION_HISTORY as _, SET_IS_LOADING as c, SET_NEW_ITEM as l } from "./actions.js";
3
- import { ContentAnswersRecord as f, ContentAnswersItemRecord as m } from "./records.js";
4
- const L = (n, s) => {
1
+ import { R as E, C as d } from "../../../../chunks/types.js";
2
+ import { SET_SUGGESTED_QUESTIONS as T, SET_SUGGESTED_QUESTIONS_REQUEST_STATE as _, SET_MODAL_SUCCESS as I, SET_MODAL_ERROR as g, UPDATE_QUESTION as R, CLEAR_CONVERSATION_HISTORY as w, SET_IS_LOADING as c, SET_NEW_ITEM as l } from "./actions.js";
3
+ import { ContentAnswersRecord as A, ContentAnswersItemRecord as O } from "./records.js";
4
+ const p = (t, s) => {
5
5
  switch (s.type) {
6
6
  case l:
7
- return new f({
8
- item: new m({
7
+ return new A({
8
+ item: new O({
9
9
  id: s.itemID,
10
10
  version_id: s.fileVersionID && s.fileVersionID.toString()
11
11
  })
12
12
  });
13
13
  case c:
14
- return n.set("isLoading", s.isLoading);
15
- case _:
16
- return n.withMutations((e) => {
14
+ return t.set("isLoading", s.isLoading);
15
+ case w:
16
+ return t.withMutations((e) => {
17
17
  e.set("questions", []), e.set("contextSession", null);
18
18
  });
19
19
  case R: {
20
20
  const {
21
21
  questions: e
22
- } = n, {
23
- newQuestion: t,
22
+ } = t, {
23
+ newQuestion: r,
24
24
  session: i
25
- } = s, o = [...e], u = (e == null ? void 0 : e.findIndex((r) => r.id === t.id)) ?? -1;
26
- u >= 0 ? o[u] = t : o.push(t);
25
+ } = s, o = [...e], u = (e == null ? void 0 : e.findIndex((n) => n.id === r.id)) ?? -1;
26
+ u >= 0 ? o[u] = r : o.push(r);
27
27
  const {
28
- isCompleted: d
28
+ isCompleted: S
29
29
  } = s.newQuestion;
30
- return n.withMutations((r) => {
31
- i && r.merge(i), r.set("hasRequestInProgress", !d), r.set("questions", o);
30
+ return t.withMutations((n) => {
31
+ i && n.merge(i), n.set("hasRequestInProgress", !S), n.set("questions", o);
32
32
  });
33
33
  }
34
+ case g:
35
+ return t.set("error", s.error);
34
36
  case I:
35
- return n.set("error", s.error);
36
- case E:
37
- return n.withMutations((e) => {
38
- e.set("encodedSession", s.encodedSession), e.set("error", s.isLargeFile ? S.LARGE_FILE : null), e.set("isLoading", !1);
37
+ return t.withMutations((e) => {
38
+ e.set("encodedSession", s.encodedSession), e.set("error", s.isLargeFile ? d.LARGE_FILE : null), e.set("isLoading", !1);
39
+ });
40
+ case _:
41
+ return t.withMutations((e) => {
42
+ e.setIn(["suggestedQuestions", "requestState"], s.requestState);
43
+ });
44
+ case T:
45
+ return t.withMutations((e) => {
46
+ e.setIn(["suggestedQuestions", "requestState"], E.SUCCESS), e.setIn(["suggestedQuestions", "suggestions"], s.suggestedQuestions);
39
47
  });
40
48
  default:
41
- return n;
49
+ return t;
42
50
  }
43
51
  };
44
52
  export {
45
- L as default
53
+ p as default
46
54
  };