@menuia/react 1.4.2 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -18
- package/dist/index.mjs +26 -18
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -42,6 +42,8 @@ interface UseMenuIAReturn {
|
|
|
42
42
|
isLoading: boolean;
|
|
43
43
|
isStreaming: boolean;
|
|
44
44
|
streamingText: string;
|
|
45
|
+
/** A IA nao respondeu de proposito (atendente assumiu, modo humano, autoReply off, plano vencido). */
|
|
46
|
+
aiPaused: boolean;
|
|
45
47
|
error: string | null;
|
|
46
48
|
sendMessage: (content: string, attachments?: MessageAttachment[]) => Promise<void>;
|
|
47
49
|
clearChat: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,8 @@ interface UseMenuIAReturn {
|
|
|
42
42
|
isLoading: boolean;
|
|
43
43
|
isStreaming: boolean;
|
|
44
44
|
streamingText: string;
|
|
45
|
+
/** A IA nao respondeu de proposito (atendente assumiu, modo humano, autoReply off, plano vencido). */
|
|
46
|
+
aiPaused: boolean;
|
|
45
47
|
error: string | null;
|
|
46
48
|
sendMessage: (content: string, attachments?: MessageAttachment[]) => Promise<void>;
|
|
47
49
|
clearChat: () => void;
|
package/dist/index.js
CHANGED
|
@@ -51,6 +51,7 @@ function useMenuIA(config) {
|
|
|
51
51
|
const [streamingText, setStreamingText] = (0, import_react.useState)("");
|
|
52
52
|
const [error, setError] = (0, import_react.useState)(null);
|
|
53
53
|
const [ticketId, setTicketId] = (0, import_react.useState)(null);
|
|
54
|
+
const [aiPaused, setAiPaused] = (0, import_react.useState)(false);
|
|
54
55
|
(0, import_react.useEffect)(() => {
|
|
55
56
|
const client = new import_core.MenuIAClient({
|
|
56
57
|
...config,
|
|
@@ -100,17 +101,20 @@ function useMenuIA(config) {
|
|
|
100
101
|
setStreamingText(fullText);
|
|
101
102
|
}
|
|
102
103
|
);
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
104
|
+
setAiPaused(!!response?.data?.aiPaused);
|
|
105
|
+
const finalContent = (response?.data?.message || streamingText || "").trim();
|
|
106
|
+
if (finalContent && !response?.data?.aiPaused) {
|
|
107
|
+
const assistantMsg = {
|
|
108
|
+
id: `assistant_${Date.now()}`,
|
|
109
|
+
role: "assistant",
|
|
110
|
+
content: finalContent,
|
|
111
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
112
|
+
};
|
|
113
|
+
setMessages((prev) => {
|
|
114
|
+
const filtered = prev.filter((m) => m.id !== assistantMsg.id);
|
|
115
|
+
return [...filtered, assistantMsg];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
114
118
|
if (response?.data?.ticketId) {
|
|
115
119
|
setTicketId(response.data.ticketId);
|
|
116
120
|
}
|
|
@@ -119,13 +123,16 @@ function useMenuIA(config) {
|
|
|
119
123
|
setIsStreaming(false);
|
|
120
124
|
setStreamingText("");
|
|
121
125
|
const response = await clientRef.current.sendMessage({ content: text, attachments });
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
setAiPaused(!!response?.data?.aiPaused);
|
|
127
|
+
const conteudoFb = (response?.data?.message || "").trim();
|
|
128
|
+
if (conteudoFb && !response?.data?.aiPaused) {
|
|
129
|
+
setMessages((prev) => [...prev, {
|
|
130
|
+
id: `assistant_${Date.now()}_fb`,
|
|
131
|
+
role: "assistant",
|
|
132
|
+
content: conteudoFb,
|
|
133
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
134
|
+
}]);
|
|
135
|
+
}
|
|
129
136
|
} catch (fallbackErr) {
|
|
130
137
|
const errMsg = fallbackErr instanceof Error ? fallbackErr.message : "Erro ao enviar mensagem";
|
|
131
138
|
setError(errMsg);
|
|
@@ -148,6 +155,7 @@ function useMenuIA(config) {
|
|
|
148
155
|
isLoading,
|
|
149
156
|
isStreaming,
|
|
150
157
|
streamingText,
|
|
158
|
+
aiPaused,
|
|
151
159
|
error,
|
|
152
160
|
sendMessage,
|
|
153
161
|
clearChat,
|
package/dist/index.mjs
CHANGED
|
@@ -13,6 +13,7 @@ function useMenuIA(config) {
|
|
|
13
13
|
const [streamingText, setStreamingText] = useState("");
|
|
14
14
|
const [error, setError] = useState(null);
|
|
15
15
|
const [ticketId, setTicketId] = useState(null);
|
|
16
|
+
const [aiPaused, setAiPaused] = useState(false);
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
const client = new MenuIAClient({
|
|
18
19
|
...config,
|
|
@@ -62,17 +63,20 @@ function useMenuIA(config) {
|
|
|
62
63
|
setStreamingText(fullText);
|
|
63
64
|
}
|
|
64
65
|
);
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
setAiPaused(!!response?.data?.aiPaused);
|
|
67
|
+
const finalContent = (response?.data?.message || streamingText || "").trim();
|
|
68
|
+
if (finalContent && !response?.data?.aiPaused) {
|
|
69
|
+
const assistantMsg = {
|
|
70
|
+
id: `assistant_${Date.now()}`,
|
|
71
|
+
role: "assistant",
|
|
72
|
+
content: finalContent,
|
|
73
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
74
|
+
};
|
|
75
|
+
setMessages((prev) => {
|
|
76
|
+
const filtered = prev.filter((m) => m.id !== assistantMsg.id);
|
|
77
|
+
return [...filtered, assistantMsg];
|
|
78
|
+
});
|
|
79
|
+
}
|
|
76
80
|
if (response?.data?.ticketId) {
|
|
77
81
|
setTicketId(response.data.ticketId);
|
|
78
82
|
}
|
|
@@ -81,13 +85,16 @@ function useMenuIA(config) {
|
|
|
81
85
|
setIsStreaming(false);
|
|
82
86
|
setStreamingText("");
|
|
83
87
|
const response = await clientRef.current.sendMessage({ content: text, attachments });
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
setAiPaused(!!response?.data?.aiPaused);
|
|
89
|
+
const conteudoFb = (response?.data?.message || "").trim();
|
|
90
|
+
if (conteudoFb && !response?.data?.aiPaused) {
|
|
91
|
+
setMessages((prev) => [...prev, {
|
|
92
|
+
id: `assistant_${Date.now()}_fb`,
|
|
93
|
+
role: "assistant",
|
|
94
|
+
content: conteudoFb,
|
|
95
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
96
|
+
}]);
|
|
97
|
+
}
|
|
91
98
|
} catch (fallbackErr) {
|
|
92
99
|
const errMsg = fallbackErr instanceof Error ? fallbackErr.message : "Erro ao enviar mensagem";
|
|
93
100
|
setError(errMsg);
|
|
@@ -110,6 +117,7 @@ function useMenuIA(config) {
|
|
|
110
117
|
isLoading,
|
|
111
118
|
isStreaming,
|
|
112
119
|
streamingText,
|
|
120
|
+
aiPaused,
|
|
113
121
|
error,
|
|
114
122
|
sendMessage,
|
|
115
123
|
clearChat,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@menuia/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "MenuIA Chat SDK - React Component",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"react-dom": ">=17.0.0"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@menuia/core": "^1.5.
|
|
20
|
+
"@menuia/core": "^1.5.2"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/react": "^18.2.0",
|