@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.
- package/chunks/types.js +4 -1
- package/esm/index.js +10 -9
- package/esm/lib/components/api-wrapper/actions.js +6 -4
- package/esm/lib/components/api-wrapper/content-answers-component.js +94 -48
- package/esm/lib/components/api-wrapper/hooks/useContentAnswers.js +139 -119
- package/esm/lib/components/api-wrapper/records.js +13 -7
- package/esm/lib/components/api-wrapper/reducer.js +30 -22
- package/esm/lib/components/api-wrapper/utils/format.js +6 -2
- package/esm/lib/components/chat/chat.js +57 -55
- package/esm/lib/components/suggested-questions/messages.js +10 -2
- package/esm/lib/components/suggested-questions/suggested-questions.js +60 -44
- package/esm/lib/components/suggested-questions/suggestions.js +35 -0
- package/i18n/bn-IN.js +2 -0
- package/i18n/da-DK.js +2 -0
- package/i18n/de-DE.js +2 -0
- package/i18n/en-AU.js +2 -0
- package/i18n/en-CA.js +2 -0
- package/i18n/en-GB.js +2 -0
- package/i18n/en-US.js +2 -0
- package/i18n/en-US.properties +4 -0
- package/i18n/en-x-pseudo.js +2 -0
- package/i18n/es-419.js +2 -0
- package/i18n/es-ES.js +2 -0
- package/i18n/fi-FI.js +2 -0
- package/i18n/fr-CA.js +2 -0
- package/i18n/fr-FR.js +2 -0
- package/i18n/hi-IN.js +2 -0
- package/i18n/it-IT.js +2 -0
- package/i18n/ja-JP.js +2 -0
- package/i18n/json/src/lib/components/suggested-questions/messages.json +1 -1
- package/i18n/ko-KR.js +2 -0
- package/i18n/nb-NO.js +2 -0
- package/i18n/nl-NL.js +2 -0
- package/i18n/pl-PL.js +2 -0
- package/i18n/pt-BR.js +2 -0
- package/i18n/ru-RU.js +2 -0
- package/i18n/sv-SE.js +2 -0
- package/i18n/tr-TR.js +2 -0
- package/i18n/zh-CN.js +2 -0
- package/i18n/zh-TW.js +2 -0
- package/package.json +2 -2
- package/styles/suggested-questions.css +1 -1
- package/styles/suggestions.css +1 -0
- package/types/lib/components/api-wrapper/actions.d.ts +2 -0
- package/types/lib/components/api-wrapper/content-answers-component.d.ts +1 -1
- package/types/lib/components/api-wrapper/hooks/useContentAnswers.d.ts +2 -1
- package/types/lib/components/api-wrapper/records.d.ts +8 -1
- package/types/lib/components/api-wrapper/types.d.ts +14 -3
- package/types/lib/components/api-wrapper/utils/format.d.ts +3 -2
- package/types/lib/components/chat/chat.d.ts +1 -1
- package/types/lib/components/suggested-questions/messages.d.ts +10 -0
- package/types/lib/components/suggested-questions/suggested-questions.d.ts +6 -4
- package/types/lib/components/suggested-questions/suggestions.d.ts +13 -0
- 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
|
|
3
|
-
import { withApiWrapper as
|
|
4
|
-
import { IntelligenceModal as
|
|
5
|
-
import { A as
|
|
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
|
-
|
|
8
|
-
|
|
7
|
+
x as ANSWER_ERROR,
|
|
8
|
+
R as AnswerContent,
|
|
9
9
|
e as BoxAiContentAnswers,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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",
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
T as SET_MODAL_ERROR,
|
|
6
|
+
_ as SET_MODAL_SUCCESS,
|
|
7
7
|
O as SET_NEW_ITEM,
|
|
8
|
-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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:
|
|
18
|
-
createSession:
|
|
19
|
-
fetchAgentConfig:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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:
|
|
29
|
-
error:
|
|
30
|
-
isLoading:
|
|
31
|
-
hasRequestInProgress:
|
|
32
|
-
questions:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
55
|
-
|
|
100
|
+
ee as ContentAnswersComponent,
|
|
101
|
+
ee as default
|
|
56
102
|
};
|
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { useAgentsDispatch as
|
|
4
|
-
import { A as
|
|
5
|
-
import { SET_NEW_ITEM as
|
|
6
|
-
import { QuestionRecord as
|
|
7
|
-
import { defaultFormatCitations as
|
|
8
|
-
import { getAnswerRequest as
|
|
9
|
-
import
|
|
10
|
-
const
|
|
11
|
-
function
|
|
12
|
-
contentAnswers:
|
|
13
|
-
createSessionRequest:
|
|
14
|
-
dispatchStateUpdate:
|
|
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:
|
|
18
|
-
getAnswer:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
formatCitations:
|
|
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
|
|
26
|
-
|
|
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
|
-
|
|
29
|
-
type:
|
|
30
|
-
itemID:
|
|
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
|
-
[
|
|
35
|
+
[u]
|
|
36
36
|
);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
type:
|
|
37
|
+
const C = t.useCallback((s, e) => {
|
|
38
|
+
o({
|
|
39
|
+
type: B,
|
|
40
40
|
newQuestion: s,
|
|
41
41
|
session: e
|
|
42
|
-
}),
|
|
43
|
-
}, [
|
|
44
|
-
|
|
45
|
-
type:
|
|
42
|
+
}), P.current = s;
|
|
43
|
+
}, [o]), M = t.useCallback((s) => {
|
|
44
|
+
o({
|
|
45
|
+
type: D,
|
|
46
46
|
error: s
|
|
47
47
|
});
|
|
48
|
-
}, [
|
|
48
|
+
}, [o]), y = t.useCallback((s, e, r) => {
|
|
49
49
|
const {
|
|
50
|
-
answer:
|
|
51
|
-
error:
|
|
52
|
-
citations:
|
|
53
|
-
createdAt:
|
|
50
|
+
answer: E,
|
|
51
|
+
error: i,
|
|
52
|
+
citations: a = [],
|
|
53
|
+
createdAt: f = null,
|
|
54
54
|
encodedSession: l = void 0,
|
|
55
|
-
contextSession:
|
|
56
|
-
} = s,
|
|
57
|
-
answer:
|
|
58
|
-
error:
|
|
59
|
-
created_at:
|
|
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:
|
|
61
|
+
isCompleted: r
|
|
62
62
|
});
|
|
63
|
-
let
|
|
64
|
-
l && (
|
|
63
|
+
let R;
|
|
64
|
+
l && (R = {
|
|
65
65
|
encodedSession: l
|
|
66
|
-
}),
|
|
67
|
-
contextSession:
|
|
68
|
-
}),
|
|
69
|
-
}, [
|
|
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,
|
|
73
|
-
const
|
|
74
|
-
error:
|
|
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
|
-
|
|
78
|
+
C(f, void 0);
|
|
79
79
|
},
|
|
80
|
-
[
|
|
81
|
-
),
|
|
80
|
+
[C]
|
|
81
|
+
), O = t.useCallback(async (s, e) => {
|
|
82
82
|
try {
|
|
83
|
-
const
|
|
83
|
+
const r = {
|
|
84
84
|
prompt: s.prompt,
|
|
85
85
|
aiAgent: e || void 0
|
|
86
|
-
},
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
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:
|
|
94
|
-
citations:
|
|
95
|
-
contextSession:
|
|
96
|
-
isCompleted:
|
|
97
|
-
} =
|
|
98
|
-
|
|
93
|
+
error: c,
|
|
94
|
+
citations: d,
|
|
95
|
+
contextSession: R,
|
|
96
|
+
isCompleted: J
|
|
97
|
+
} = f;
|
|
98
|
+
y({
|
|
99
99
|
...{
|
|
100
100
|
answer: l,
|
|
101
|
-
citations:
|
|
102
|
-
error:
|
|
103
|
-
contextSession:
|
|
101
|
+
citations: d,
|
|
102
|
+
error: c,
|
|
103
|
+
contextSession: R
|
|
104
104
|
}
|
|
105
|
-
}, s,
|
|
106
|
-
}, void 0, k) :
|
|
107
|
-
response:
|
|
108
|
-
}, s) : (Object.entries(
|
|
109
|
-
const
|
|
110
|
-
delete
|
|
111
|
-
}),
|
|
112
|
-
} catch (
|
|
113
|
-
|
|
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
|
-
}, [
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
return
|
|
120
|
-
}, [
|
|
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:
|
|
124
|
+
is_large_file: r
|
|
125
125
|
} = {
|
|
126
126
|
is_large_file: !1
|
|
127
127
|
}
|
|
128
128
|
} = s;
|
|
129
|
-
|
|
130
|
-
type:
|
|
129
|
+
o({
|
|
130
|
+
type: Z,
|
|
131
131
|
encodedSession: e,
|
|
132
|
-
isLargeFile:
|
|
132
|
+
isLargeFile: r
|
|
133
133
|
});
|
|
134
|
-
}, [
|
|
134
|
+
}, [o]), j = t.useCallback(async () => {
|
|
135
135
|
try {
|
|
136
|
-
|
|
137
|
-
type:
|
|
136
|
+
o({
|
|
137
|
+
type: w,
|
|
138
138
|
isLoading: !0
|
|
139
139
|
});
|
|
140
|
-
const s = await
|
|
141
|
-
items: [
|
|
142
|
-
},
|
|
143
|
-
|
|
140
|
+
const s = await Q({
|
|
141
|
+
items: [n.item]
|
|
142
|
+
}, u);
|
|
143
|
+
v(s);
|
|
144
144
|
} catch {
|
|
145
|
-
|
|
145
|
+
M(h.GENERAL);
|
|
146
146
|
}
|
|
147
|
-
}, [
|
|
148
|
-
|
|
149
|
-
type:
|
|
147
|
+
}, [o, Q, n.item, u, v, M]), x = t.useCallback(() => {
|
|
148
|
+
o({
|
|
149
|
+
type: U
|
|
150
150
|
});
|
|
151
|
-
}, [
|
|
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]),
|
|
160
|
-
|
|
161
|
-
}, []),
|
|
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
|
|
165
|
-
|
|
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
|
-
}, [
|
|
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:
|
|
175
|
-
createSession:
|
|
176
|
-
fetchAgentConfig:
|
|
177
|
-
|
|
193
|
+
clearConversation: x,
|
|
194
|
+
createSession: j,
|
|
195
|
+
fetchAgentConfig: W,
|
|
196
|
+
fetchSuggestedQuestions: H,
|
|
197
|
+
retryQuestion: $,
|
|
178
198
|
sendQuestion: N,
|
|
179
|
-
sendQuestionAnswerRequest:
|
|
180
|
-
stopQuestion:
|
|
181
|
-
updateQuestionInState:
|
|
199
|
+
sendQuestionAnswerRequest: O,
|
|
200
|
+
stopQuestion: V,
|
|
201
|
+
updateQuestionInState: C
|
|
182
202
|
};
|
|
183
203
|
}
|
|
184
204
|
export {
|
|
185
|
-
|
|
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
|
-
}),
|
|
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
|
|
17
|
-
questions: []
|
|
18
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
2
|
-
import { SET_MODAL_SUCCESS as
|
|
3
|
-
import { ContentAnswersRecord as
|
|
4
|
-
const
|
|
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
|
|
8
|
-
item: new
|
|
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
|
|
15
|
-
case
|
|
16
|
-
return
|
|
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
|
-
} =
|
|
23
|
-
newQuestion:
|
|
22
|
+
} = t, {
|
|
23
|
+
newQuestion: r,
|
|
24
24
|
session: i
|
|
25
|
-
} = s, o = [...e], u = (e == null ? void 0 : e.findIndex((
|
|
26
|
-
u >= 0 ? o[u] =
|
|
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:
|
|
28
|
+
isCompleted: S
|
|
29
29
|
} = s.newQuestion;
|
|
30
|
-
return
|
|
31
|
-
i &&
|
|
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
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
|
49
|
+
return t;
|
|
42
50
|
}
|
|
43
51
|
};
|
|
44
52
|
export {
|
|
45
|
-
|
|
53
|
+
p as default
|
|
46
54
|
};
|