xertica-ui 1.3.1 → 1.3.2
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.
|
@@ -120,7 +120,21 @@ interface AssistenteXerticaProps {
|
|
|
120
120
|
isFullPage?: boolean;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
import type { Message, Conversa, SearchResult, SearchSource, SearchCommand, Sugestao } from '../contexts/AssistenteContext';
|
|
123
|
+
import type { Message, Conversa, SearchResult, SearchSource, SearchCommand, Sugestao, MockResponse } from '../contexts/AssistenteContext';
|
|
124
|
+
|
|
125
|
+
// ... (existing code)
|
|
126
|
+
|
|
127
|
+
interface AssistenteXerticaProps {
|
|
128
|
+
isExpanded: boolean;
|
|
129
|
+
onToggle: () => void;
|
|
130
|
+
onToggleWithTab?: (tab: 'chat' | 'historico' | 'favoritos') => void;
|
|
131
|
+
isFullPage?: boolean;
|
|
132
|
+
demoMode?: boolean;
|
|
133
|
+
customResponses?: MockResponse[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ... (existing code)
|
|
137
|
+
|
|
124
138
|
|
|
125
139
|
const sugestoesPadrao: Sugestao[] = [
|
|
126
140
|
{ id: '1', texto: 'O que posso pedir para você fazer?' },
|
|
@@ -138,13 +152,33 @@ const sugestoesRicas: Sugestao[] = [
|
|
|
138
152
|
];
|
|
139
153
|
|
|
140
154
|
// Respostas simuladas da IA
|
|
141
|
-
const gerarResposta = (mensagemUsuario: string): string => {
|
|
155
|
+
const gerarResposta = (mensagemUsuario: string, customResponses?: MockResponse[]): string | Partial<Message> => {
|
|
142
156
|
const mensagemLower = mensagemUsuario.toLowerCase();
|
|
157
|
+
|
|
158
|
+
// 1. Verificar respostas customizadas primeiro
|
|
159
|
+
if (customResponses && customResponses.length > 0) {
|
|
160
|
+
for (const mock of customResponses) {
|
|
161
|
+
const trigger = mock.trigger;
|
|
162
|
+
let match = false;
|
|
163
|
+
|
|
164
|
+
if (trigger instanceof RegExp) {
|
|
165
|
+
match = trigger.test(mensagemUsuario);
|
|
166
|
+
} else {
|
|
167
|
+
match = mensagemLower.includes(trigger.toLowerCase());
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (match) {
|
|
171
|
+
return mock.response;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
143
176
|
const mensagemOriginal = mensagemUsuario;
|
|
144
177
|
|
|
145
178
|
if (mensagemLower.includes('o que') && (mensagemLower.includes('fazer') || mensagemLower.includes('pedir'))) {
|
|
146
179
|
return 'Posso ajudar você com diversas tarefas! Posso:\n\n• Analisar dados e métricas dos seus projetos\n• Responder perguntas sobre performance e resultados\n• Sugerir otimizações e melhorias\n• Gerar relatórios e documentação\n• Ajudar no planejamento de sprints\n• E muito mais!\n\nQual tarefa você gostaria de realizar primeiro?';
|
|
147
180
|
}
|
|
181
|
+
// ... (rest of the function)
|
|
148
182
|
|
|
149
183
|
if (mensagemLower.includes('o que você faz') || mensagemLower.includes('quem é você')) {
|
|
150
184
|
return 'Olá! Sou o Assistente Xertica, uma IA desenvolvida para ajudar você a gerenciar projetos, analisar dados e otimizar processos. Estou aqui 24/7 para responder suas perguntas e auxiliar nas suas tarefas diárias.\n\nPosso processar documentos, analisar áudios e imagens, além de fornecer insights baseados nos dados da plataforma.';
|
|
@@ -201,7 +235,15 @@ const gerarResposta = (mensagemUsuario: string): string => {
|
|
|
201
235
|
return respostasGenericas[Math.floor(Math.random() * respostasGenericas.length)];
|
|
202
236
|
};
|
|
203
237
|
|
|
204
|
-
|
|
238
|
+
|
|
239
|
+
export function AssistenteXertica({
|
|
240
|
+
isExpanded,
|
|
241
|
+
onToggle,
|
|
242
|
+
onToggleWithTab,
|
|
243
|
+
isFullPage = false,
|
|
244
|
+
demoMode = false,
|
|
245
|
+
customResponses = []
|
|
246
|
+
}: AssistenteXerticaProps) {
|
|
205
247
|
const navigate = useNavigate();
|
|
206
248
|
const { geminiApiKey, isApiKeyValid } = useApiKey();
|
|
207
249
|
const {
|
|
@@ -398,10 +440,10 @@ export function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFul
|
|
|
398
440
|
setIsTyping(true);
|
|
399
441
|
|
|
400
442
|
try {
|
|
401
|
-
let
|
|
443
|
+
let novaMensagemParcial: Partial<Message> = {};
|
|
402
444
|
|
|
403
|
-
// Se a chave da API for válida, usar Gemini
|
|
404
|
-
if (isApiKeyValid && geminiApiKey) {
|
|
445
|
+
// Se a chave da API for válida e não estiver em modo demo, usar Gemini
|
|
446
|
+
if (isApiKeyValid && geminiApiKey && !demoMode) {
|
|
405
447
|
// Construir histórico da conversa para o Gemini
|
|
406
448
|
const conversaAtiva = conversas.find(c => c.id === conversaAtual);
|
|
407
449
|
const historico: GeminiMessage[] = [];
|
|
@@ -444,7 +486,8 @@ export function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFul
|
|
|
444
486
|
}
|
|
445
487
|
|
|
446
488
|
try {
|
|
447
|
-
|
|
489
|
+
const respostaTexto = await callGeminiAPI(geminiApiKey, mensagemUsuario, historico);
|
|
490
|
+
novaMensagemParcial = { content: respostaTexto };
|
|
448
491
|
} catch (error) {
|
|
449
492
|
console.error('Erro ao chamar API Gemini:', error);
|
|
450
493
|
// Usar a mensagem de erro do utilitário se disponível
|
|
@@ -460,27 +503,41 @@ export function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFul
|
|
|
460
503
|
description: 'Sua chave foi reportada como vazada. Gere uma nova em Google AI Studio.',
|
|
461
504
|
duration: 6000,
|
|
462
505
|
});
|
|
463
|
-
|
|
506
|
+
novaMensagemParcial = {
|
|
507
|
+
content: `🔐 **Chave de API Desativada por Segurança**\n\n${errorMessage}\n\n**Como resolver:**\n1. Acesse [Google AI Studio](https://aistudio.google.com/apikey)\n2. Gere uma nova chave de API\n3. Configure a nova chave em **Configurações > API**\n\n⚠️ **Importante:** Não compartilhe sua chave de API publicamente.`
|
|
508
|
+
};
|
|
464
509
|
} else {
|
|
465
510
|
toast.error('Erro ao processar mensagem', {
|
|
466
511
|
description: 'Verifique sua chave de API nas Configurações.',
|
|
467
512
|
duration: 4000,
|
|
468
513
|
});
|
|
469
|
-
|
|
514
|
+
novaMensagemParcial = {
|
|
515
|
+
content: `**Erro ao processar sua mensagem**\n\n${errorMessage}\n\n💡 **Dica:** Verifique se sua chave de API está configurada corretamente em **Configurações > API**.`
|
|
516
|
+
};
|
|
470
517
|
}
|
|
471
518
|
}
|
|
472
519
|
} else {
|
|
473
|
-
// Fallback para respostas simuladas se não houver API key
|
|
520
|
+
// Fallback para respostas simuladas se não houver API key ou em modo demo
|
|
474
521
|
await new Promise(resolve => setTimeout(resolve, 1000 + Math.random() * 1000));
|
|
475
|
-
|
|
522
|
+
|
|
523
|
+
// Passar customResponses para gerarResposta
|
|
524
|
+
const resultadoMock = gerarResposta(mensagemUsuario, customResponses);
|
|
525
|
+
|
|
526
|
+
if (typeof resultadoMock === 'string') {
|
|
527
|
+
novaMensagemParcial = { content: resultadoMock };
|
|
528
|
+
} else {
|
|
529
|
+
// Se for objeto (MockResponse), usar diretamente
|
|
530
|
+
novaMensagemParcial = resultadoMock;
|
|
531
|
+
}
|
|
476
532
|
}
|
|
477
533
|
|
|
478
534
|
const novaMensagem: Message = {
|
|
479
535
|
id: Date.now().toString() + '-ia',
|
|
480
536
|
type: 'assistant',
|
|
481
|
-
content:
|
|
537
|
+
content: '', // Valor padrão se não vier no partial
|
|
482
538
|
timestamp: new Date(),
|
|
483
|
-
isFavorite: false
|
|
539
|
+
isFavorite: false,
|
|
540
|
+
...novaMensagemParcial
|
|
484
541
|
};
|
|
485
542
|
|
|
486
543
|
setConversas(prev => prev.map(conv => {
|
|
@@ -489,7 +546,7 @@ export function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFul
|
|
|
489
546
|
return {
|
|
490
547
|
...conv,
|
|
491
548
|
mensagens: novasMensagens,
|
|
492
|
-
ultimaMensagem:
|
|
549
|
+
ultimaMensagem: (novaMensagem.content || '').substring(0, 50) + '...',
|
|
493
550
|
timestamp: new Date().toLocaleString('pt-BR')
|
|
494
551
|
};
|
|
495
552
|
}
|
|
@@ -33,6 +33,12 @@ export interface Message {
|
|
|
33
33
|
evaluationReason?: string;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
export interface MockResponse {
|
|
37
|
+
trigger: string | RegExp;
|
|
38
|
+
response: string | Partial<Message>;
|
|
39
|
+
delay?: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
36
42
|
export interface Conversa {
|
|
37
43
|
id: string;
|
|
38
44
|
titulo: string;
|
|
@@ -4,5 +4,14 @@ interface AssistenteXerticaProps {
|
|
|
4
4
|
onToggleWithTab?: (tab: 'chat' | 'historico' | 'favoritos') => void;
|
|
5
5
|
isFullPage?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
import type { MockResponse } from '../contexts/AssistenteContext';
|
|
8
|
+
interface AssistenteXerticaProps {
|
|
9
|
+
isExpanded: boolean;
|
|
10
|
+
onToggle: () => void;
|
|
11
|
+
onToggleWithTab?: (tab: 'chat' | 'historico' | 'favoritos') => void;
|
|
12
|
+
isFullPage?: boolean;
|
|
13
|
+
demoMode?: boolean;
|
|
14
|
+
customResponses?: MockResponse[];
|
|
15
|
+
}
|
|
16
|
+
export declare function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFullPage, demoMode, customResponses }: AssistenteXerticaProps): import("react/jsx-runtime").JSX.Element;
|
|
8
17
|
export {};
|
|
@@ -28,6 +28,11 @@ export interface Message {
|
|
|
28
28
|
evaluation?: 'like' | 'dislike';
|
|
29
29
|
evaluationReason?: string;
|
|
30
30
|
}
|
|
31
|
+
export interface MockResponse {
|
|
32
|
+
trigger: string | RegExp;
|
|
33
|
+
response: string | Partial<Message>;
|
|
34
|
+
delay?: number;
|
|
35
|
+
}
|
|
31
36
|
export interface Conversa {
|
|
32
37
|
id: string;
|
|
33
38
|
titulo: string;
|
package/dist/index.es.js
CHANGED
|
@@ -56400,8 +56400,22 @@ const sugestoesRicas = [
|
|
|
56400
56400
|
{ id: "rich-3", texto: "Ver exemplo de Tabela", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Table$1, { className: "w-4 h-4 mr-2" }) },
|
|
56401
56401
|
{ id: "rich-4", texto: "Ver exemplo de Documento", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-4 h-4 mr-2" }) }
|
|
56402
56402
|
];
|
|
56403
|
-
const gerarResposta = (mensagemUsuario) => {
|
|
56403
|
+
const gerarResposta = (mensagemUsuario, customResponses) => {
|
|
56404
56404
|
const mensagemLower = mensagemUsuario.toLowerCase();
|
|
56405
|
+
if (customResponses && customResponses.length > 0) {
|
|
56406
|
+
for (const mock of customResponses) {
|
|
56407
|
+
const trigger = mock.trigger;
|
|
56408
|
+
let match2 = false;
|
|
56409
|
+
if (trigger instanceof RegExp) {
|
|
56410
|
+
match2 = trigger.test(mensagemUsuario);
|
|
56411
|
+
} else {
|
|
56412
|
+
match2 = mensagemLower.includes(trigger.toLowerCase());
|
|
56413
|
+
}
|
|
56414
|
+
if (match2) {
|
|
56415
|
+
return mock.response;
|
|
56416
|
+
}
|
|
56417
|
+
}
|
|
56418
|
+
}
|
|
56405
56419
|
const mensagemOriginal = mensagemUsuario;
|
|
56406
56420
|
if (mensagemLower.includes("o que") && (mensagemLower.includes("fazer") || mensagemLower.includes("pedir"))) {
|
|
56407
56421
|
return "Posso ajudar você com diversas tarefas! Posso:\n\n• Analisar dados e métricas dos seus projetos\n• Responder perguntas sobre performance e resultados\n• Sugerir otimizações e melhorias\n• Gerar relatórios e documentação\n• Ajudar no planejamento de sprints\n• E muito mais!\n\nQual tarefa você gostaria de realizar primeiro?";
|
|
@@ -56447,7 +56461,14 @@ const gerarResposta = (mensagemUsuario) => {
|
|
|
56447
56461
|
];
|
|
56448
56462
|
return respostasGenericas[Math.floor(Math.random() * respostasGenericas.length)];
|
|
56449
56463
|
};
|
|
56450
|
-
function AssistenteXertica({
|
|
56464
|
+
function AssistenteXertica({
|
|
56465
|
+
isExpanded,
|
|
56466
|
+
onToggle,
|
|
56467
|
+
onToggleWithTab,
|
|
56468
|
+
isFullPage = false,
|
|
56469
|
+
demoMode = false,
|
|
56470
|
+
customResponses = []
|
|
56471
|
+
}) {
|
|
56451
56472
|
const navigate = useNavigate();
|
|
56452
56473
|
const { geminiApiKey, isApiKeyValid } = useApiKey();
|
|
56453
56474
|
const {
|
|
@@ -56633,8 +56654,8 @@ function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFullPage =
|
|
|
56633
56654
|
const simularRespostaIA = async (mensagemUsuario) => {
|
|
56634
56655
|
setIsTyping(true);
|
|
56635
56656
|
try {
|
|
56636
|
-
let
|
|
56637
|
-
if (isApiKeyValid && geminiApiKey) {
|
|
56657
|
+
let novaMensagemParcial = {};
|
|
56658
|
+
if (isApiKeyValid && geminiApiKey && !demoMode) {
|
|
56638
56659
|
const conversaAtiva2 = conversas.find((c2) => c2.id === conversaAtual);
|
|
56639
56660
|
const historico = [];
|
|
56640
56661
|
const systemPrompt = buildSystemPrompt();
|
|
@@ -56664,7 +56685,8 @@ function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFullPage =
|
|
|
56664
56685
|
});
|
|
56665
56686
|
}
|
|
56666
56687
|
try {
|
|
56667
|
-
|
|
56688
|
+
const respostaTexto = await callGeminiAPI(geminiApiKey, mensagemUsuario, historico);
|
|
56689
|
+
novaMensagemParcial = { content: respostaTexto };
|
|
56668
56690
|
} catch (error) {
|
|
56669
56691
|
console.error("Erro ao chamar API Gemini:", error);
|
|
56670
56692
|
const errorMessage = error instanceof Error ? error.message : "❌ Erro desconhecido";
|
|
@@ -56674,7 +56696,8 @@ function AssistenteXertica({ isExpanded, onToggle, onToggleWithTab, isFullPage =
|
|
|
56674
56696
|
description: "Sua chave foi reportada como vazada. Gere uma nova em Google AI Studio.",
|
|
56675
56697
|
duration: 6e3
|
|
56676
56698
|
});
|
|
56677
|
-
|
|
56699
|
+
novaMensagemParcial = {
|
|
56700
|
+
content: `🔐 **Chave de API Desativada por Segurança**
|
|
56678
56701
|
|
|
56679
56702
|
${errorMessage}
|
|
56680
56703
|
|
|
@@ -56683,29 +56706,39 @@ ${errorMessage}
|
|
|
56683
56706
|
2. Gere uma nova chave de API
|
|
56684
56707
|
3. Configure a nova chave em **Configurações > API**
|
|
56685
56708
|
|
|
56686
|
-
⚠️ **Importante:** Não compartilhe sua chave de API publicamente
|
|
56709
|
+
⚠️ **Importante:** Não compartilhe sua chave de API publicamente.`
|
|
56710
|
+
};
|
|
56687
56711
|
} else {
|
|
56688
56712
|
ue$1.error("Erro ao processar mensagem", {
|
|
56689
56713
|
description: "Verifique sua chave de API nas Configurações.",
|
|
56690
56714
|
duration: 4e3
|
|
56691
56715
|
});
|
|
56692
|
-
|
|
56716
|
+
novaMensagemParcial = {
|
|
56717
|
+
content: `**Erro ao processar sua mensagem**
|
|
56693
56718
|
|
|
56694
56719
|
${errorMessage}
|
|
56695
56720
|
|
|
56696
|
-
💡 **Dica:** Verifique se sua chave de API está configurada corretamente em **Configurações > API
|
|
56721
|
+
💡 **Dica:** Verifique se sua chave de API está configurada corretamente em **Configurações > API**.`
|
|
56722
|
+
};
|
|
56697
56723
|
}
|
|
56698
56724
|
}
|
|
56699
56725
|
} else {
|
|
56700
56726
|
await new Promise((resolve) => setTimeout(resolve, 1e3 + Math.random() * 1e3));
|
|
56701
|
-
|
|
56727
|
+
const resultadoMock = gerarResposta(mensagemUsuario, customResponses);
|
|
56728
|
+
if (typeof resultadoMock === "string") {
|
|
56729
|
+
novaMensagemParcial = { content: resultadoMock };
|
|
56730
|
+
} else {
|
|
56731
|
+
novaMensagemParcial = resultadoMock;
|
|
56732
|
+
}
|
|
56702
56733
|
}
|
|
56703
56734
|
const novaMensagem = {
|
|
56704
56735
|
id: Date.now().toString() + "-ia",
|
|
56705
56736
|
type: "assistant",
|
|
56706
|
-
content:
|
|
56737
|
+
content: "",
|
|
56738
|
+
// Valor padrão se não vier no partial
|
|
56707
56739
|
timestamp: /* @__PURE__ */ new Date(),
|
|
56708
|
-
isFavorite: false
|
|
56740
|
+
isFavorite: false,
|
|
56741
|
+
...novaMensagemParcial
|
|
56709
56742
|
};
|
|
56710
56743
|
setConversas((prev) => prev.map((conv) => {
|
|
56711
56744
|
if (conv.id === conversaAtual) {
|
|
@@ -56713,7 +56746,7 @@ ${errorMessage}
|
|
|
56713
56746
|
return {
|
|
56714
56747
|
...conv,
|
|
56715
56748
|
mensagens: novasMensagens,
|
|
56716
|
-
ultimaMensagem:
|
|
56749
|
+
ultimaMensagem: (novaMensagem.content || "").substring(0, 50) + "...",
|
|
56717
56750
|
timestamp: (/* @__PURE__ */ new Date()).toLocaleString("pt-BR")
|
|
56718
56751
|
};
|
|
56719
56752
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -56419,8 +56419,22 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
56419
56419
|
{ id: "rich-3", texto: "Ver exemplo de Tabela", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Table$1, { className: "w-4 h-4 mr-2" }) },
|
|
56420
56420
|
{ id: "rich-4", texto: "Ver exemplo de Documento", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(FileText, { className: "w-4 h-4 mr-2" }) }
|
|
56421
56421
|
];
|
|
56422
|
-
const gerarResposta = (mensagemUsuario) => {
|
|
56422
|
+
const gerarResposta = (mensagemUsuario, customResponses) => {
|
|
56423
56423
|
const mensagemLower = mensagemUsuario.toLowerCase();
|
|
56424
|
+
if (customResponses && customResponses.length > 0) {
|
|
56425
|
+
for (const mock of customResponses) {
|
|
56426
|
+
const trigger = mock.trigger;
|
|
56427
|
+
let match2 = false;
|
|
56428
|
+
if (trigger instanceof RegExp) {
|
|
56429
|
+
match2 = trigger.test(mensagemUsuario);
|
|
56430
|
+
} else {
|
|
56431
|
+
match2 = mensagemLower.includes(trigger.toLowerCase());
|
|
56432
|
+
}
|
|
56433
|
+
if (match2) {
|
|
56434
|
+
return mock.response;
|
|
56435
|
+
}
|
|
56436
|
+
}
|
|
56437
|
+
}
|
|
56424
56438
|
const mensagemOriginal = mensagemUsuario;
|
|
56425
56439
|
if (mensagemLower.includes("o que") && (mensagemLower.includes("fazer") || mensagemLower.includes("pedir"))) {
|
|
56426
56440
|
return "Posso ajudar você com diversas tarefas! Posso:\n\n• Analisar dados e métricas dos seus projetos\n• Responder perguntas sobre performance e resultados\n• Sugerir otimizações e melhorias\n• Gerar relatórios e documentação\n• Ajudar no planejamento de sprints\n• E muito mais!\n\nQual tarefa você gostaria de realizar primeiro?";
|
|
@@ -56466,7 +56480,14 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
56466
56480
|
];
|
|
56467
56481
|
return respostasGenericas[Math.floor(Math.random() * respostasGenericas.length)];
|
|
56468
56482
|
};
|
|
56469
|
-
function AssistenteXertica({
|
|
56483
|
+
function AssistenteXertica({
|
|
56484
|
+
isExpanded,
|
|
56485
|
+
onToggle,
|
|
56486
|
+
onToggleWithTab,
|
|
56487
|
+
isFullPage = false,
|
|
56488
|
+
demoMode = false,
|
|
56489
|
+
customResponses = []
|
|
56490
|
+
}) {
|
|
56470
56491
|
const navigate = useNavigate();
|
|
56471
56492
|
const { geminiApiKey, isApiKeyValid } = useApiKey();
|
|
56472
56493
|
const {
|
|
@@ -56652,8 +56673,8 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
56652
56673
|
const simularRespostaIA = async (mensagemUsuario) => {
|
|
56653
56674
|
setIsTyping(true);
|
|
56654
56675
|
try {
|
|
56655
|
-
let
|
|
56656
|
-
if (isApiKeyValid && geminiApiKey) {
|
|
56676
|
+
let novaMensagemParcial = {};
|
|
56677
|
+
if (isApiKeyValid && geminiApiKey && !demoMode) {
|
|
56657
56678
|
const conversaAtiva2 = conversas.find((c2) => c2.id === conversaAtual);
|
|
56658
56679
|
const historico = [];
|
|
56659
56680
|
const systemPrompt = buildSystemPrompt();
|
|
@@ -56683,7 +56704,8 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
56683
56704
|
});
|
|
56684
56705
|
}
|
|
56685
56706
|
try {
|
|
56686
|
-
|
|
56707
|
+
const respostaTexto = await callGeminiAPI(geminiApiKey, mensagemUsuario, historico);
|
|
56708
|
+
novaMensagemParcial = { content: respostaTexto };
|
|
56687
56709
|
} catch (error) {
|
|
56688
56710
|
console.error("Erro ao chamar API Gemini:", error);
|
|
56689
56711
|
const errorMessage = error instanceof Error ? error.message : "❌ Erro desconhecido";
|
|
@@ -56693,7 +56715,8 @@ ${colorConfig.map(([key, itemConfig]) => {
|
|
|
56693
56715
|
description: "Sua chave foi reportada como vazada. Gere uma nova em Google AI Studio.",
|
|
56694
56716
|
duration: 6e3
|
|
56695
56717
|
});
|
|
56696
|
-
|
|
56718
|
+
novaMensagemParcial = {
|
|
56719
|
+
content: `🔐 **Chave de API Desativada por Segurança**
|
|
56697
56720
|
|
|
56698
56721
|
${errorMessage}
|
|
56699
56722
|
|
|
@@ -56702,29 +56725,39 @@ ${errorMessage}
|
|
|
56702
56725
|
2. Gere uma nova chave de API
|
|
56703
56726
|
3. Configure a nova chave em **Configurações > API**
|
|
56704
56727
|
|
|
56705
|
-
⚠️ **Importante:** Não compartilhe sua chave de API publicamente
|
|
56728
|
+
⚠️ **Importante:** Não compartilhe sua chave de API publicamente.`
|
|
56729
|
+
};
|
|
56706
56730
|
} else {
|
|
56707
56731
|
ue$1.error("Erro ao processar mensagem", {
|
|
56708
56732
|
description: "Verifique sua chave de API nas Configurações.",
|
|
56709
56733
|
duration: 4e3
|
|
56710
56734
|
});
|
|
56711
|
-
|
|
56735
|
+
novaMensagemParcial = {
|
|
56736
|
+
content: `**Erro ao processar sua mensagem**
|
|
56712
56737
|
|
|
56713
56738
|
${errorMessage}
|
|
56714
56739
|
|
|
56715
|
-
💡 **Dica:** Verifique se sua chave de API está configurada corretamente em **Configurações > API
|
|
56740
|
+
💡 **Dica:** Verifique se sua chave de API está configurada corretamente em **Configurações > API**.`
|
|
56741
|
+
};
|
|
56716
56742
|
}
|
|
56717
56743
|
}
|
|
56718
56744
|
} else {
|
|
56719
56745
|
await new Promise((resolve) => setTimeout(resolve, 1e3 + Math.random() * 1e3));
|
|
56720
|
-
|
|
56746
|
+
const resultadoMock = gerarResposta(mensagemUsuario, customResponses);
|
|
56747
|
+
if (typeof resultadoMock === "string") {
|
|
56748
|
+
novaMensagemParcial = { content: resultadoMock };
|
|
56749
|
+
} else {
|
|
56750
|
+
novaMensagemParcial = resultadoMock;
|
|
56751
|
+
}
|
|
56721
56752
|
}
|
|
56722
56753
|
const novaMensagem = {
|
|
56723
56754
|
id: Date.now().toString() + "-ia",
|
|
56724
56755
|
type: "assistant",
|
|
56725
|
-
content:
|
|
56756
|
+
content: "",
|
|
56757
|
+
// Valor padrão se não vier no partial
|
|
56726
56758
|
timestamp: /* @__PURE__ */ new Date(),
|
|
56727
|
-
isFavorite: false
|
|
56759
|
+
isFavorite: false,
|
|
56760
|
+
...novaMensagemParcial
|
|
56728
56761
|
};
|
|
56729
56762
|
setConversas((prev) => prev.map((conv) => {
|
|
56730
56763
|
if (conv.id === conversaAtual) {
|
|
@@ -56732,7 +56765,7 @@ ${errorMessage}
|
|
|
56732
56765
|
return {
|
|
56733
56766
|
...conv,
|
|
56734
56767
|
mensagens: novasMensagens,
|
|
56735
|
-
ultimaMensagem:
|
|
56768
|
+
ultimaMensagem: (novaMensagem.content || "").substring(0, 50) + "...",
|
|
56736
56769
|
timestamp: (/* @__PURE__ */ new Date()).toLocaleString("pt-BR")
|
|
56737
56770
|
};
|
|
56738
56771
|
}
|