@orbe-agro/client-core 5.6.343 → 5.6.345
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/@ecme/assets/styles/app.css +52 -26
- package/dist/@ecme/assets/styles/tailwind/index.css +52 -26
- package/dist/@ecme/components/template/Footer.js +1 -1
- package/dist/@ecme/components/view/ChatBox/ChatBox.js +3 -1
- package/dist/@ecme/components/view/ChatBox/ChatBox.js.map +1 -1
- package/dist/@ecme/components/view/ChatBox/components/ChatInput.js +19 -16
- package/dist/@ecme/components/view/ChatBox/components/ChatInput.js.map +1 -1
- package/dist/@ecme/index.js +3 -1
- package/dist/@ecme/services/AiService.js +31 -2
- package/dist/@ecme/services/AiService.js.map +1 -1
- package/dist/@ecme/services/index.js +3 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js +55 -43
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/FormatoCard.js +81 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/FormatoCard.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.js +35 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/ModeloERaciocinio.js +142 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/ModeloERaciocinio.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/PlanilhaNaMensagem.js +47 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/PlanilhaNaMensagem.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/RelatorioNaMensagem.js +64 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/RelatorioNaMensagem.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/ToolCallChip.js +9 -4
- package/dist/@ecme/views/concepts/ai/Chat/components/ToolCallChip.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/toolPresentation.js +18 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/toolPresentation.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js +96 -51
- package/dist/@ecme/views/concepts/ai/Chat/hooks/useChatSend.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.js +31 -0
- package/dist/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/hooks/useModelos.js +31 -0
- package/dist/@ecme/views/concepts/ai/Chat/hooks/useModelos.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/imagens.js +57 -0
- package/dist/@ecme/views/concepts/ai/Chat/imagens.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/store/modeloStore.js +15 -0
- package/dist/@ecme/views/concepts/ai/Chat/store/modeloStore.js.map +1 -0
- package/dist/@types/@ecme/components/view/ChatBox/ChatBox.d.ts.map +1 -1
- package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts +3 -0
- package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts.map +1 -1
- package/dist/@types/@ecme/services/AiService.d.ts +25 -5
- package/dist/@types/@ecme/services/AiService.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ChatView.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/FormatoCard.d.ts +16 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/FormatoCard.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.d.ts +13 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ModeloERaciocinio.d.ts +16 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ModeloERaciocinio.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/PlanilhaNaMensagem.d.ts +14 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/PlanilhaNaMensagem.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/RelatorioNaMensagem.d.ts +15 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/RelatorioNaMensagem.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/ToolCallChip.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/toolPresentation.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts +3 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useChatSend.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.d.ts +16 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useModelos.d.ts +26 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/hooks/useModelos.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/imagens.d.ts +27 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/imagens.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/store/modeloStore.d.ts +27 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/store/modeloStore.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts +148 -24
- package/dist/@types/@ecme/views/concepts/ai/Chat/types.d.ts.map +1 -1
- package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts +8 -0
- package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts.map +1 -1
- package/dist/@types/base/configs/endpoints.config/transportadora/contratoFrete.d.ts +8 -0
- package/dist/@types/base/configs/endpoints.config/transportadora/contratoFrete.d.ts.map +1 -1
- package/dist/@types/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.d.ts +2 -0
- package/dist/@types/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.d.ts.map +1 -1
- package/dist/base/assets/styles/init.css +59 -30
- package/dist/base/configs/endpoints.config/transportadora/contratoFrete.js +3 -1
- package/dist/base/configs/endpoints.config/transportadora/contratoFrete.js.map +1 -1
- package/dist/base/index.js +3 -1
- package/dist/base/services/index.js +3 -1
- package/dist/base/services/modules/index.js +3 -1
- package/dist/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.js +14 -0
- package/dist/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.js.map +1 -1
- package/dist/base/services/modules/transportadora/index.js +3 -1
- package/lib/@ecme/components/view/ChatBox/ChatBox.tsx +2 -0
- package/lib/@ecme/components/view/ChatBox/components/ChatInput.tsx +23 -16
- package/lib/@ecme/services/AiService.ts +57 -5
- package/lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx +59 -40
- package/lib/@ecme/views/concepts/ai/Chat/components/FormatoCard.tsx +123 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.tsx +54 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/ModeloERaciocinio.tsx +200 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/PlanilhaNaMensagem.tsx +65 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/RelatorioNaMensagem.tsx +77 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/ToolCallChip.tsx +18 -9
- package/lib/@ecme/views/concepts/ai/Chat/components/toolPresentation.ts +20 -0
- package/lib/@ecme/views/concepts/ai/Chat/hooks/useChatSend.ts +193 -78
- package/lib/@ecme/views/concepts/ai/Chat/hooks/useImagemDoStorage.ts +53 -0
- package/lib/@ecme/views/concepts/ai/Chat/hooks/useModelos.ts +63 -0
- package/lib/@ecme/views/concepts/ai/Chat/imagens.ts +86 -0
- package/lib/@ecme/views/concepts/ai/Chat/store/modeloStore.ts +25 -0
- package/lib/@ecme/views/concepts/ai/Chat/types.ts +157 -24
- package/lib/base/configs/endpoints.config/transportadora/contratoFrete.ts +2 -0
- package/lib/base/services/modules/transportadora/ContratoFrete/ContratoFreteService.ts +14 -0
- package/package.json +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.js +0 -85
- package/dist/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.js.map +0 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.d.ts +0 -14
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.d.ts.map +0 -1
- package/lib/@ecme/views/concepts/ai/Chat/components/EsforcoRaciocinio.tsx +0 -115
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiService.js","sources":["../../../lib/@ecme/services/AiService.ts"],"sourcesContent":["import { authHeaders } from './aiAuthHeaders'\nimport ApiService from './ApiService'\nimport { readSse } from './sseParser'\nimport type {
|
|
1
|
+
{"version":3,"file":"AiService.js","sources":["../../../lib/@ecme/services/AiService.ts"],"sourcesContent":["import { endpointsConfig } from '@base/configs'\nimport { authHeaders } from './aiAuthHeaders'\nimport ApiService from './ApiService'\nimport { readSse } from './sseParser'\nimport type {\n ArquivoDoStorage,\n ChatEvent,\n Esforco,\n FormatoDoRelatorio,\n ImagemEnviada,\n} from '@/views/concepts/ai/Chat/types'\nimport type { AxiosRequestConfig } from 'axios'\n\nconst AI_DEV_URL = 'http://localhost:8000'\nconst AI_QAS_URL = 'https://orbe-ai.apps.qas.orbeagro.com.br'\nconst AI_PRD_URL = 'https://orbe-ai.apps.prd.orbeagro.com.br'\n\n/**\n * Host da API de IA.\n *\n * O /ai/* nao vive no gateway do resto da aplicacao, entao nao pode usar o\n * baseURL do AxiosBase (API_URL). A resolucao e por origin em runtime, e nao\n * por import.meta.env.MODE, porque o MODE e congelado na build da lib como\n * \"production\" e nao reflete o dev do MFE consumidor.\n */\nfunction getAiApiUrl() {\n const origin = globalThis?.location?.origin ?? ''\n\n if (origin.includes('localhost') || origin.includes('127.0.0.1')) {\n return AI_DEV_URL\n }\n\n if (origin.includes('.prd.')) {\n return AI_PRD_URL\n }\n\n return AI_QAS_URL\n}\n\nexport const AI_API_URL = getAiApiUrl()\n\n/**\n * Toda chamada de IA sai pelo AI_API_URL (o baseURL por requisicao vence o da\n * instancia do AxiosBase) e fica fora do loading global — o chat mostra o\n * proprio balaozinho de \"digitando\".\n */\nconst aiRequest = <T>(config: AxiosRequestConfig) =>\n ApiService.fetchDataWithAxios<T>({\n ...config,\n baseURL: AI_API_URL,\n skipGlobalLoading: true,\n })\n\nexport async function apiGetChatHistory<T>(conversationId?: string) {\n return aiRequest<T>({\n url: '/ai/chat/history',\n method: 'get',\n params: conversationId ? { conversation_id: conversationId } : undefined,\n })\n}\n\n/** Conversas do usuário (só o resumo), a mais recente primeiro. */\nexport async function apiGetConversations<T>() {\n return aiRequest<T>({\n url: '/ai/chat/conversations',\n method: 'get',\n })\n}\n\nexport async function apiRenameConversation(conversationId: string, title: string) {\n return aiRequest<void>({\n url: `/ai/chat/conversations/${encodeURIComponent(conversationId)}`,\n method: 'patch',\n data: { title },\n })\n}\n\n/** Apaga a conversa e toda a memória dela no backend. */\nexport async function apiDeleteConversation(conversationId: string) {\n return aiRequest<void>({\n url: `/ai/chat/conversations/${encodeURIComponent(conversationId)}`,\n method: 'delete',\n })\n}\n\n/** Modelos que o chat oferece e o padrão; a lista vem do .env do backend. */\nexport async function apiGetModelos<T>() {\n return aiRequest<T>({\n url: '/ai/chat/models',\n method: 'get',\n })\n}\n\nexport type StreamChatParams = {\n prompt: string\n /** Identifica a conversa; o backend usa como thread da memoria. */\n conversationId?: string\n /** Nivel de raciocinio desta mensagem; ausente = o padrao do backend. */\n esforco?: Esforco\n /** Modelo desta mensagem, da lista do backend; ausente = o padrao. */\n modelo?: string\n /** Imagens desta mensagem; ausente = so texto. */\n imagens?: ImagemEnviada[]\n signal?: AbortSignal\n onEvent: (evento: ChatEvent) => void\n}\n\n/**\n * Resposta a pausa atual do agente. Ha tres, e um endpoint so:\n * - `approved` responde ao `approval_required` (true aprova, false nega).\n * - `dados` responde ao `input_required`; `null` = o usuario fechou o\n * formulario sem preencher.\n * - `formato` responde ao `format_required`; `null` = o usuario fechou a\n * escolha sem escolher.\n */\nexport type ResumeChatParams = {\n approved?: boolean\n dados?: Record<string, unknown> | null\n formato?: FormatoDoRelatorio | null\n conversationId?: string\n /** A retomada tambem chama o modelo: vale o mesmo nivel do envio. */\n esforco?: Esforco\n /** E o mesmo modelo do envio. */\n modelo?: string\n signal?: AbortSignal\n onEvent: (evento: ChatEvent) => void\n}\n\n/**\n * Envia a mensagem e consome a resposta em streaming (SSE).\n *\n * Usa `fetch`, e nao o Axios, porque o Axios no browser so resolve a Promise\n * com a resposta inteira — nao ha como ler o corpo enquanto ele chega.\n */\nexport async function streamChat({\n prompt,\n conversationId,\n esforco,\n modelo,\n imagens,\n signal,\n onEvent,\n}: StreamChatParams): Promise<void> {\n await postarEConsumir(\n '/ai/chat/stream',\n { prompt, conversation_id: conversationId, esforco, modelo, imagens },\n onEvent,\n signal,\n )\n}\n\n/**\n * Imagem do chat guardada no object storage, pelo `objectName` do historico.\n *\n * Vai pelo gateway, como os outros modulos (e nao pelo AI_API_URL): e o mesmo\n * endpoint do `ObjectStorageService`, mas fora do loading global - a miniatura\n * carrega dentro da mensagem, sem travar a tela.\n */\nexport async function apiGetImagemDoChat(objectName: string) {\n return ApiService.fetchDataWithAxios<ArquivoDoStorage>({\n url: endpointsConfig.objectStorage.minio.download,\n method: 'get',\n params: { fileName: objectName },\n skipGlobalLoading: true,\n })\n}\n\n/**\n * Retoma uma conversa parada numa pausa (aprovacao, coleta de dados ou escolha\n * do formato do relatorio).\n *\n * Devolve o mesmo tipo de stream do `streamChat`, e a resposta continua na\n * MESMA mensagem do chat — o backend so volta do ponto onde parou.\n *\n * O `JSON.stringify` descarta chaves `undefined`, entao o backend recebe apenas\n * o campo da pausa que esta sendo respondida.\n */\nexport async function resumeChat({\n approved,\n dados,\n formato,\n conversationId,\n esforco,\n modelo,\n signal,\n onEvent,\n}: ResumeChatParams): Promise<void> {\n await postarEConsumir(\n '/ai/chat/resume',\n {\n approved,\n dados,\n formato,\n conversation_id: conversationId,\n esforco,\n modelo,\n },\n onEvent,\n signal,\n )\n}\n\n/** POST + leitura do SSE, comum ao envio e a retomada. */\nasync function postarEConsumir(\n caminho: string,\n corpo: Record<string, unknown>,\n onEvent: (evento: ChatEvent) => void,\n signal?: AbortSignal,\n): Promise<void> {\n const resposta = await fetch(`${AI_API_URL}${caminho}`, {\n method: 'POST',\n headers: {\n ...authHeaders(),\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(corpo),\n signal,\n })\n\n if (!resposta.ok || !resposta.body) {\n throw new Error(`Falha ao falar com a IA (HTTP ${resposta.status})`)\n }\n\n await readSse(resposta.body, ({ event, data }) => {\n try {\n onEvent({ type: event, data: JSON.parse(data) } as ChatEvent)\n } catch (error) {\n // Evento malformado nao pode derrubar o stream inteiro.\n console.debug('Evento SSE ignorado:', event, error)\n }\n })\n}\n\nexport async function apiGetImages<T, U extends Record<string, unknown>>(\n params: U,\n) {\n return aiRequest<T>({\n url: '/ai/images',\n method: 'get',\n params,\n })\n}\n\nexport async function apiPostImages<T, U extends Record<string, unknown>>(\n data: U,\n) {\n return aiRequest<T>({\n url: '/ai/images',\n method: 'post',\n data,\n })\n}\n"],"names":["endpointsConfig"],"mappings":";;;;;AAaA,MAAM,aAAa;AACnB,MAAM,aAAa;AACnB,MAAM,aAAa;AAUnB,SAAS,cAAc;AACnB,QAAM,SAAS,YAAY,UAAU,UAAU;AAE/C,MAAI,OAAO,SAAS,WAAW,KAAK,OAAO,SAAS,WAAW,GAAG;AAC9D,WAAO;AAAA,EACX;AAEA,MAAI,OAAO,SAAS,OAAO,GAAG;AAC1B,WAAO;AAAA,EACX;AAEA,SAAO;AACX;AAEO,MAAM,aAAa,YAAA;AAO1B,M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AA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ,GAAoC;AAChC,QAAM;AAAA,IACF;AAAA,IACA;AAAA,MACI;AAAA,MACA;AAAA,MACA;AAAA,MACA,iBAAiB;AAAA,MACjB;AAAA,MACA;AAAA,IAAA;AAAA,IAEJ;AAAA,IACA;AAAA,EAAA;AAER;AAGA,eAAe,gBACX,SACA,OACA,SACA,QACa;AACb,QAAM,WAAW,MAAM,MAAM,GAAG,UAAU,GAAG,OAAO,IAAI;AAAA,IACpD,QAAQ;AAAA,IACR,SAAS;AAAA,MACL,GAAG,YAAA;AAAA,MACH,gBAAgB;AAAA,IAAA;AAAA,IAEpB,MAAM,KAAK,UAAU,KAAK;AAAA,IAC1B;AAAA,EAAA,CACH;AAED,MAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAChC,UAAM,IAAI,MAAM,iCAAiC,SAAS,MAAM,GAAG;AAAA,EACvE;AAEA,QAAM,QAAQ,SAAS,MAAM,CAAC,EAAE,OAAO,WAAW;AAC9C,QAAI;AACA,cAAQ,EAAE,MAAM,OAAO,MAAM,KAAK,MAAM,IAAI,GAAgB;AAAA,IAChE,SAAS,OAAO;AAEZ,cAAQ,MAAM,wBAAwB,OAAO,KAAK;AAAA,IACtD;AAAA,EACJ,CAAC;AACL;AAEA,eAAsB,aAClB,QACF;AACE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,EAAA,CACH;AACL;AAEA,eAAsB,cAClB,MACF;AACE,SAAO,UAAa;AAAA,IAChB,KAAK;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,EAAA,CACH;AACL;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { default as default2 } from "./ApiService.js";
|
|
2
2
|
import { apiGetPricingPlans, apiGetRolesPermissionsRoles, apiGetRolesPermissionsUsers, apiGetSettingsBilling, apiGetSettingsIntergration, apiGetSettingsNotification, apiGetSettingsProfile } from "./AccontsService.js";
|
|
3
|
-
import { AI_API_URL, apiDeleteConversation, apiGetChatHistory, apiGetConversations, apiGetImages, apiPostImages, apiRenameConversation, resumeChat, streamChat } from "./AiService.js";
|
|
3
|
+
import { AI_API_URL, apiDeleteConversation, apiGetChatHistory, apiGetConversations, apiGetImagemDoChat, apiGetImages, apiGetModelos, apiPostImages, apiRenameConversation, resumeChat, streamChat } from "./AiService.js";
|
|
4
4
|
import { apiForgotPassword, apiResetPassword, apiSignIn, apiSignOut, apiSignUp } from "./AuthService.js";
|
|
5
5
|
import { apiGetCalendar } from "./CalendarService.js";
|
|
6
6
|
import { apiGetChats, apiGetContactDetails, apiGetContacts, apiGetConversation } from "./ChatService.js";
|
|
@@ -34,11 +34,13 @@ export {
|
|
|
34
34
|
apiGetCustomersList,
|
|
35
35
|
apiGetEcommerceDashboard,
|
|
36
36
|
apiGetFiles,
|
|
37
|
+
apiGetImagemDoChat,
|
|
37
38
|
apiGetImages,
|
|
38
39
|
apiGetLogs,
|
|
39
40
|
apiGetMail,
|
|
40
41
|
apiGetMails,
|
|
41
42
|
apiGetMarketingDashboard,
|
|
43
|
+
apiGetModelos,
|
|
42
44
|
apiGetNotificationCount,
|
|
43
45
|
apiGetNotificationList,
|
|
44
46
|
apiGetOrder,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useRef, useEffect, useMemo
|
|
3
|
-
import { TbDownload } from "react-icons/tb";
|
|
4
|
-
import * as XLSX from "xlsx";
|
|
2
|
+
import { useRef, useEffect, useMemo } from "react";
|
|
5
3
|
import "../../../../../components/ui/Card/index.js";
|
|
6
4
|
import "../../../../../components/view/ChatBox/index.js";
|
|
7
5
|
import ChatLandingView from "./ChatLandingView.js";
|
|
@@ -13,10 +11,16 @@ import AiErrorMessage from "./AiErrorMessage.js";
|
|
|
13
11
|
import ToolCallChip from "./ToolCallChip.js";
|
|
14
12
|
import ApprovalCard from "./ApprovalCard.js";
|
|
15
13
|
import DataRequestCard from "./DataRequestCard.js";
|
|
16
|
-
import
|
|
14
|
+
import FormatoCard from "./FormatoCard.js";
|
|
15
|
+
import ModeloERaciocinio from "./ModeloERaciocinio.js";
|
|
16
|
+
import ImagensDaMensagem from "./ImagensDaMensagem.js";
|
|
17
|
+
import PlanilhaNaMensagem from "./PlanilhaNaMensagem.js";
|
|
18
|
+
import RelatorioNaMensagem from "./RelatorioNaMensagem.js";
|
|
19
|
+
import { UPLOAD_DE_IMAGENS } from "../imagens.js";
|
|
17
20
|
import { usGenerativeChatStore } from "../store/generativeChatStore.js";
|
|
18
21
|
import useChatSend from "../hooks/useChatSend.js";
|
|
19
22
|
import useConversationMessages from "../hooks/useConversationMessages.js";
|
|
23
|
+
import useModelos from "../hooks/useModelos.js";
|
|
20
24
|
import Card from "../../../../../components/ui/Card/Card.js";
|
|
21
25
|
import ChatBox from "../../../../../components/view/ChatBox/ChatBox.js";
|
|
22
26
|
const BALAO_AGENTE = "prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100";
|
|
@@ -26,8 +30,9 @@ const ChatView = ({
|
|
|
26
30
|
}) => {
|
|
27
31
|
const scrollRef = useRef(null);
|
|
28
32
|
const { selectedConversation, chatHistory, isTyping, disabledChatFresh } = usGenerativeChatStore();
|
|
29
|
-
const { handleSend, handleApproval, handleDataSubmit } = useChatSend();
|
|
33
|
+
const { handleSend, handleApproval, handleDataSubmit, handleFormato } = useChatSend();
|
|
30
34
|
const { carregando } = useConversationMessages();
|
|
35
|
+
const { atual } = useModelos();
|
|
31
36
|
const scrollToBottom = () => {
|
|
32
37
|
if (scrollRef.current?.getScrollElement) {
|
|
33
38
|
const scrollElement = scrollRef.current.getScrollElement();
|
|
@@ -46,30 +51,15 @@ const ChatView = ({
|
|
|
46
51
|
return chat?.conversation || [];
|
|
47
52
|
}, [selectedConversation, chatHistory]);
|
|
48
53
|
const handleInputChange = async ({
|
|
49
|
-
value
|
|
54
|
+
value,
|
|
55
|
+
attachments
|
|
50
56
|
}) => {
|
|
51
|
-
await handleSend(value);
|
|
57
|
+
await handleSend(value, attachments);
|
|
52
58
|
};
|
|
53
59
|
const handleFinish = (id) => {
|
|
54
60
|
disabledChatFresh(id);
|
|
55
61
|
scrollToBottom();
|
|
56
62
|
};
|
|
57
|
-
const handleSpreadsheetDownload = useCallback(
|
|
58
|
-
(titulo, abas) => {
|
|
59
|
-
const workbook = XLSX.utils.book_new();
|
|
60
|
-
for (const aba of abas) {
|
|
61
|
-
const sheet = XLSX.utils.aoa_to_sheet([
|
|
62
|
-
aba.colunas,
|
|
63
|
-
...aba.linhas.map(
|
|
64
|
-
(linha) => aba.colunas.map((col) => linha[col] ?? "")
|
|
65
|
-
)
|
|
66
|
-
]);
|
|
67
|
-
XLSX.utils.book_append_sheet(workbook, sheet, aba.nome.slice(0, 31));
|
|
68
|
-
}
|
|
69
|
-
XLSX.writeFile(workbook, `${titulo}.xlsx`);
|
|
70
|
-
},
|
|
71
|
-
[]
|
|
72
|
-
);
|
|
73
63
|
return /* @__PURE__ */ jsxs(Card, { className: "flex-1 h-full", bodyClass: "h-full", children: [
|
|
74
64
|
showMobileNav && /* @__PURE__ */ jsx(ChatMobileNav, {}),
|
|
75
65
|
/* @__PURE__ */ jsx(
|
|
@@ -97,7 +87,14 @@ const ChatView = ({
|
|
|
97
87
|
return /* @__PURE__ */ jsx(AiErrorMessage, {});
|
|
98
88
|
}
|
|
99
89
|
if (message.sender.id === "ai") {
|
|
100
|
-
const {
|
|
90
|
+
const {
|
|
91
|
+
tools,
|
|
92
|
+
pendingApproval,
|
|
93
|
+
pendingInput,
|
|
94
|
+
pendingFormat,
|
|
95
|
+
relatorios,
|
|
96
|
+
falhou
|
|
97
|
+
} = message;
|
|
101
98
|
const temTexto = Boolean(
|
|
102
99
|
message.content?.trim()
|
|
103
100
|
);
|
|
@@ -111,23 +108,29 @@ const ChatView = ({
|
|
|
111
108
|
onFinish: () => handleFinish(message.id)
|
|
112
109
|
}
|
|
113
110
|
) }),
|
|
114
|
-
|
|
115
|
-
"
|
|
111
|
+
relatorios?.map(
|
|
112
|
+
(relatorio) => relatorio.formato === "xlsx" ? /* @__PURE__ */ jsx(
|
|
113
|
+
PlanilhaNaMensagem,
|
|
114
|
+
{
|
|
115
|
+
planilha: relatorio
|
|
116
|
+
},
|
|
117
|
+
relatorio.id
|
|
118
|
+
) : /* @__PURE__ */ jsx(
|
|
119
|
+
RelatorioNaMensagem,
|
|
120
|
+
{
|
|
121
|
+
relatorio
|
|
122
|
+
},
|
|
123
|
+
relatorio.id
|
|
124
|
+
)
|
|
125
|
+
),
|
|
126
|
+
pendingFormat && /* @__PURE__ */ jsx(
|
|
127
|
+
FormatoCard,
|
|
116
128
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
)
|
|
122
|
-
className: "inline-flex items-center gap-2 rounded-lg border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-700 transition-colors hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400 dark:hover:bg-emerald-900/50",
|
|
123
|
-
children: [
|
|
124
|
-
/* @__PURE__ */ jsx(TbDownload, { size: 18 }),
|
|
125
|
-
/* @__PURE__ */ jsxs("span", { children: [
|
|
126
|
-
"Baixar ",
|
|
127
|
-
spreadsheet.titulo,
|
|
128
|
-
".xlsx"
|
|
129
|
-
] })
|
|
130
|
-
]
|
|
129
|
+
onChoose: (formato) => handleFormato(
|
|
130
|
+
selectedConversation,
|
|
131
|
+
message.id,
|
|
132
|
+
formato
|
|
133
|
+
)
|
|
131
134
|
}
|
|
132
135
|
),
|
|
133
136
|
pendingInput && /* @__PURE__ */ jsx(
|
|
@@ -151,10 +154,15 @@ const ChatView = ({
|
|
|
151
154
|
aprovado
|
|
152
155
|
)
|
|
153
156
|
}
|
|
154
|
-
)
|
|
157
|
+
),
|
|
158
|
+
falhou && /* @__PURE__ */ jsx(AiErrorMessage, {})
|
|
155
159
|
] });
|
|
156
160
|
}
|
|
157
|
-
|
|
161
|
+
const { imagens } = message;
|
|
162
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
163
|
+
/* @__PURE__ */ jsx(ImagensDaMensagem, { imagens }),
|
|
164
|
+
message.content
|
|
165
|
+
] });
|
|
158
166
|
},
|
|
159
167
|
customAction: (message) => {
|
|
160
168
|
if (message.sender.id === "ai" && !message.isError) {
|
|
@@ -168,7 +176,11 @@ const ChatView = ({
|
|
|
168
176
|
return null;
|
|
169
177
|
},
|
|
170
178
|
onInputChange: handleInputChange,
|
|
171
|
-
|
|
179
|
+
uploadProps: {
|
|
180
|
+
...UPLOAD_DE_IMAGENS,
|
|
181
|
+
disabled: atual?.imagens === false
|
|
182
|
+
},
|
|
183
|
+
inputActions: /* @__PURE__ */ jsx(ModeloERaciocinio, { floatingClass: dropdownFloatingClass }),
|
|
172
184
|
children: selectedConversation ? /* @__PURE__ */ jsx("p", { className: "py-1 text-center text-xs text-gray-500 dark:text-gray-400", children: "Orbe-AI é uma inteligência artificial e pode cometer erros." }) : /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 overflow-y-auto", children: /* @__PURE__ */ jsx(ChatLandingView, {}) })
|
|
173
185
|
}
|
|
174
186
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx"],"sourcesContent":["import { useRef, useEffect, useMemo, useCallback } from 'react'\nimport { TbDownload } from 'react-icons/tb'\nimport * as XLSX from 'xlsx'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatLandingView from './ChatLandingView'\nimport ChatMobileNav from './ChatMobileNav'\nimport ChatCustomContent from './ChatCustomContent'\nimport ChatCustomAction from './ChatCustomAction'\nimport AiThinkingIndicator from './AiThinkingIndicator'\nimport AiErrorMessage from './AiErrorMessage'\nimport ToolCallChip from './ToolCallChip'\nimport ApprovalCard from './ApprovalCard'\nimport DataRequestCard from './DataRequestCard'\nimport EsforcoRaciocinio from './EsforcoRaciocinio'\nimport { usGenerativeChatStore } from '../store/generativeChatStore'\nimport useChatSend from '../hooks/useChatSend'\nimport useConversationMessages from '../hooks/useConversationMessages'\nimport type { Conversation } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\n/**\n * O balao de fala do agente, desenhado aqui em vez de vir do ChatBox.\n *\n * O `botBubbleClass` abaixo zera o balao que o Message desenharia, para os chips\n * de ferramenta e o card de aprovacao ficarem FORA dele — antes tudo dividia a\n * mesma caixa cinza e as ferramentas eram lidas como uma segunda mensagem.\n * Usado tambem pelo indicador de \"pensando\", que passa pelo mesmo balao zerado.\n *\n * Repete `prose text-sm` do balao original de proposito: o reset de margem do\n * @tailwindcss/typography e `.prose > :first-child`, filho DIRETO. Sem o `prose`\n * aqui, o markdown ficaria um nivel abaixo do container e o primeiro paragrafo\n * voltaria a ter margem, inflando todos os baloes.\n */\nconst BALAO_AGENTE =\n 'prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100'\n\ntype ChatViewProps = {\n /**\n * Mostra o drawer de histórico do ChatMobileNav abaixo de xl. O widget\n * flutuante desliga, porque tem o próprio drawer dentro do painel.\n */\n showMobileNav?: boolean\n /**\n * Classes dos menus flutuantes do chat. O widget passa um z-index acima do\n * próprio painel; sem isso o menu abriria atrás dele.\n */\n dropdownFloatingClass?: string\n}\n\nconst ChatView = ({\n showMobileNav = true,\n dropdownFloatingClass,\n}: ChatViewProps) => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const { selectedConversation, chatHistory, isTyping, disabledChatFresh } =\n usGenerativeChatStore()\n const { handleSend, handleApproval, handleDataSubmit } = useChatSend()\n // Conversa aberta da lista: as mensagens vêm do backend na primeira vez.\n const { carregando } = useConversationMessages()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [selectedConversation, chatHistory])\n\n const messageList = useMemo(() => {\n const chat = chatHistory.find(\n (chat) => chat.id === selectedConversation,\n )\n return chat?.conversation || []\n }, [selectedConversation, chatHistory])\n\n const handleInputChange = async ({\n value,\n }: {\n value: string\n attachments?: File[]\n }) => {\n await handleSend(value)\n }\n\n const handleFinish = (id: string) => {\n disabledChatFresh(id)\n scrollToBottom()\n }\n\n const handleSpreadsheetDownload = useCallback(\n (titulo: string, abas: Array<{ nome: string; colunas: string[]; linhas: Record<string, unknown>[] }>) => {\n const workbook = XLSX.utils.book_new()\n for (const aba of abas) {\n const sheet = XLSX.utils.aoa_to_sheet([\n aba.colunas,\n ...aba.linhas.map((linha) =>\n aba.colunas.map((col) => linha[col] ?? ''),\n ),\n ])\n XLSX.utils.book_append_sheet(workbook, sheet, aba.nome.slice(0, 31))\n }\n XLSX.writeFile(workbook, `${titulo}.xlsx`)\n },\n [],\n )\n\n return (\n <Card className=\"flex-1 h-full\" bodyClass=\"h-full\">\n {showMobileNav && <ChatMobileNav />}\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Pergunte algo sobre o Orbe Agro…\"\n showMessageList={Boolean(selectedConversation)}\n showAvatar={false}\n avatarGap={false}\n myBubbleClass=\"bg-primary text-white\"\n botBubbleClass=\"bg-transparent dark:bg-transparent p-0 rounded-none\"\n errorBubbleClass=\"bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20\"\n renderTyping={() => (\n <div className={BALAO_AGENTE}>\n <AiThinkingIndicator />\n </div>\n )}\n containerClass={\n showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'\n }\n // +24px sobre a altura do input: espaco da linha de aviso.\n messageListClass=\"h-[calc(100%-124px)] xl:h-[calc(100%-94px)]\"\n typing={\n isTyping || carregando\n ? {\n id: 'ai',\n name: 'Chat AI',\n avatarImageUrl: '/img/thumbs/ai.jpg',\n }\n : false\n }\n customRenderer={(message) => {\n if (message.isError) {\n return <AiErrorMessage />\n }\n\n if (message.sender.id === 'ai') {\n // As ferramentas e as pausas chegam pelo streaming e\n // vivem no Conversation; o tipo do ChatBox nao os conhece.\n const { tools, pendingApproval, pendingInput, spreadsheet } =\n message as Conversation\n // Enquanto as ferramentas rodam o conteudo ainda e '':\n // sem esta guarda sobraria um balao cinza vazio.\n const temTexto = Boolean(\n (message.content as string)?.trim(),\n )\n\n return (\n <div className=\"flex flex-col items-start gap-1.5\">\n {tools?.map((tool) => (\n <ToolCallChip key={tool.id} tool={tool} />\n ))}\n {temTexto && (\n <div className={BALAO_AGENTE}>\n <ChatCustomContent\n content={message.content as string}\n triggerTyping={\n message.fresh\n ? message.fresh\n : false\n }\n onFinish={() =>\n handleFinish(message.id)\n }\n />\n </div>\n )}\n {spreadsheet && (\n <button\n type=\"button\"\n onClick={() =>\n handleSpreadsheetDownload(\n spreadsheet.titulo,\n spreadsheet.abas,\n )\n }\n className=\"inline-flex items-center gap-2 rounded-lg border border-emerald-300 bg-emerald-50 px-3 py-2 text-sm font-medium text-emerald-700 transition-colors hover:bg-emerald-100 dark:border-emerald-700 dark:bg-emerald-900/30 dark:text-emerald-400 dark:hover:bg-emerald-900/50\"\n >\n <TbDownload size={18} />\n <span>Baixar {spreadsheet.titulo}.xlsx</span>\n </button>\n )}\n {pendingInput && (\n <DataRequestCard\n input={pendingInput}\n onSubmit={(dados) =>\n handleDataSubmit(\n selectedConversation,\n message.id,\n dados,\n )\n }\n />\n )}\n {pendingApproval && (\n <ApprovalCard\n approval={pendingApproval}\n onDecide={(aprovado) =>\n handleApproval(\n selectedConversation,\n message.id,\n aprovado,\n )\n }\n />\n )}\n </div>\n )\n }\n\n return message.content\n }}\n customAction={(message) => {\n if (message.sender.id === 'ai' && !message.isError) {\n return (\n <ChatCustomAction\n content={message.content as string}\n />\n )\n }\n\n return null\n }}\n onInputChange={handleInputChange}\n inputActions={\n <EsforcoRaciocinio floatingClass={dropdownFloatingClass} />\n }\n >\n {/* Os children ficam entre a lista e o input: sem conversa e a\n landing com os cards; com conversa, o aviso sobre a IA. */}\n {selectedConversation ? (\n <p className=\"py-1 text-center text-xs text-gray-500 dark:text-gray-400\">\n Orbe-AI é uma inteligência artificial e pode cometer\n erros.\n </p>\n ) : (\n <div className=\"flex-1 min-h-0 overflow-y-auto\">\n <ChatLandingView />\n </div>\n )}\n </ChatBox>\n </Card>\n )\n}\n\nexport default ChatView\n"],"names":["chat"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,eACF;AAeJ,MAAM,WAAW,CAAC;AAAA,EACd,gBAAgB;AAAA,EAChB;AACJ,MAAqB;AACjB,QAAM,YAAY,OAAqB,IAAI;AAC3C,QAAM,EAAE,sBAAsB,aAAa,UAAU,kBAAA,IACjD,sBAAA;AACJ,QAAM,EAAE,YAAY,gBAAgB,iBAAA,IAAqB,YAAA;AAEzD,QAAM,EAAE,WAAA,IAAe,wBAAA;AAEvB,QAAM,iBAAiB,MAAM;AACzB,QAAI,UAAU,SAAS,kBAAkB;AACrC,YAAM,gBAAgB,UAAU,QAAQ,iBAAA;AACxC,UAAI,eAAe;AACf,sBAAc,YAAY,cAAc;AAAA,MAC5C;AAAA,IACJ;AAAA,EACJ;AAEA,YAAU,MAAM;AACZ,mBAAA;AAAA,EACJ,GAAG,CAAC,sBAAsB,WAAW,CAAC;AAEtC,QAAM,cAAc,QAAQ,MAAM;AAC9B,UAAM,OAAO,YAAY;AAAA,MACrB,CAACA,UAASA,MAAK,OAAO;AAAA,IAAA;AAE1B,WAAO,MAAM,gBAAgB,CAAA;AAAA,EACjC,GAAG,CAAC,sBAAsB,WAAW,CAAC;AAEtC,QAAM,oBAAoB,OAAO;AAAA,IAC7B;AAAA,EAAA,MAIE;AACF,UAAM,WAAW,KAAK;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ER;AAEA,iBAAO,QAAQ;AAAA,QACnB;AAAA,QACA,cAAc,CAAC,YAAY;AACvB,cAAI,QAAQ,OAAO,OAAO,QAAQ,CAAC,QAAQ,SAAS;AAChD,mBACI;AAAA,cAAC;AAAA,cAAA;AAAA,gBACG,SAAS,QAAQ;AAAA,cAAA;AAAA,YAAA;AAAA,UAG7B;AAEA,iBAAO;AAAA,QACX;AAAA,QACA,eAAe;AAAA,QACf,cACI,oBAAC,mBAAA,EAAkB,eAAe,sBAAA,CAAuB;AAAA,QAK5D,UAAA,uBACG,oBAAC,KAAA,EAAE,WAAU,6DAA4D,UAAA,8DAAA,CAGzE,IAEA,oBAAC,OAAA,EAAI,WAAU,kCACX,UAAA,oBAAC,mBAAgB,EAAA,CACrB;AAAA,MAAA;AAAA,IAAA;AAAA,EAER,GACJ;AAER;"}
|
|
1
|
+
{"version":3,"file":"ChatView.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx"],"sourcesContent":["import { useRef, useEffect, useMemo } from 'react'\nimport Card from '@/components/ui/Card'\nimport ChatBox from '@/components/view/ChatBox'\nimport ChatLandingView from './ChatLandingView'\nimport ChatMobileNav from './ChatMobileNav'\nimport ChatCustomContent from './ChatCustomContent'\nimport ChatCustomAction from './ChatCustomAction'\nimport AiThinkingIndicator from './AiThinkingIndicator'\nimport AiErrorMessage from './AiErrorMessage'\nimport ToolCallChip from './ToolCallChip'\nimport ApprovalCard from './ApprovalCard'\nimport DataRequestCard from './DataRequestCard'\nimport FormatoCard from './FormatoCard'\nimport ModeloERaciocinio from './ModeloERaciocinio'\nimport ImagensDaMensagem from './ImagensDaMensagem'\nimport PlanilhaNaMensagem from './PlanilhaNaMensagem'\nimport RelatorioNaMensagem from './RelatorioNaMensagem'\nimport { UPLOAD_DE_IMAGENS } from '../imagens'\nimport { usGenerativeChatStore } from '../store/generativeChatStore'\nimport useChatSend from '../hooks/useChatSend'\nimport useConversationMessages from '../hooks/useConversationMessages'\nimport useModelos from '../hooks/useModelos'\nimport type { Conversation } from '../types'\nimport type { ScrollBarRef } from '@/components/ui/ScrollBar'\n\n/**\n * O balao de fala do agente, desenhado aqui em vez de vir do ChatBox.\n *\n * O `botBubbleClass` abaixo zera o balao que o Message desenharia, para os chips\n * de ferramenta e o card de aprovacao ficarem FORA dele — antes tudo dividia a\n * mesma caixa cinza e as ferramentas eram lidas como uma segunda mensagem.\n * Usado tambem pelo indicador de \"pensando\", que passa pelo mesmo balao zerado.\n *\n * Repete `prose text-sm` do balao original de proposito: o reset de margem do\n * @tailwindcss/typography e `.prose > :first-child`, filho DIRETO. Sem o `prose`\n * aqui, o markdown ficaria um nivel abaixo do container e o primeiro paragrafo\n * voltaria a ter margem, inflando todos os baloes.\n */\nconst BALAO_AGENTE =\n 'prose rounded-xl bg-gray-100 px-5 py-2.5 text-sm text-gray-900 dark:bg-gray-700 dark:text-gray-100'\n\ntype ChatViewProps = {\n /**\n * Mostra o drawer de histórico do ChatMobileNav abaixo de xl. O widget\n * flutuante desliga, porque tem o próprio drawer dentro do painel.\n */\n showMobileNav?: boolean\n /**\n * Classes dos menus flutuantes do chat. O widget passa um z-index acima do\n * próprio painel; sem isso o menu abriria atrás dele.\n */\n dropdownFloatingClass?: string\n}\n\nconst ChatView = ({\n showMobileNav = true,\n dropdownFloatingClass,\n}: ChatViewProps) => {\n const scrollRef = useRef<ScrollBarRef>(null)\n const { selectedConversation, chatHistory, isTyping, disabledChatFresh } =\n usGenerativeChatStore()\n const { handleSend, handleApproval, handleDataSubmit, handleFormato } =\n useChatSend()\n // Conversa aberta da lista: as mensagens vêm do backend na primeira vez.\n const { carregando } = useConversationMessages()\n // Modelo que só lê texto: o botão de imagem fica desligado.\n const { atual } = useModelos()\n\n const scrollToBottom = () => {\n if (scrollRef.current?.getScrollElement) {\n const scrollElement = scrollRef.current.getScrollElement()\n if (scrollElement) {\n scrollElement.scrollTop = scrollElement.scrollHeight\n }\n }\n }\n\n useEffect(() => {\n scrollToBottom()\n }, [selectedConversation, chatHistory])\n\n const messageList = useMemo(() => {\n const chat = chatHistory.find(\n (chat) => chat.id === selectedConversation,\n )\n return chat?.conversation || []\n }, [selectedConversation, chatHistory])\n\n const handleInputChange = async ({\n value,\n attachments,\n }: {\n value: string\n attachments: File[]\n }) => {\n await handleSend(value, attachments)\n }\n\n const handleFinish = (id: string) => {\n disabledChatFresh(id)\n scrollToBottom()\n }\n\n return (\n <Card className=\"flex-1 h-full\" bodyClass=\"h-full\">\n {showMobileNav && <ChatMobileNav />}\n <ChatBox\n ref={scrollRef}\n messageList={messageList}\n placeholder=\"Pergunte algo sobre o Orbe Agro…\"\n showMessageList={Boolean(selectedConversation)}\n showAvatar={false}\n avatarGap={false}\n myBubbleClass=\"bg-primary text-white\"\n botBubbleClass=\"bg-transparent dark:bg-transparent p-0 rounded-none\"\n errorBubbleClass=\"bg-red-50 dark:bg-red-500/10 border border-red-200 dark:border-red-500/20\"\n renderTyping={() => (\n <div className={BALAO_AGENTE}>\n <AiThinkingIndicator />\n </div>\n )}\n containerClass={\n showMobileNav ? 'h-[calc(100%-30px)] xl:h-full' : 'h-full'\n }\n // +24px sobre a altura do input: espaco da linha de aviso.\n messageListClass=\"h-[calc(100%-124px)] xl:h-[calc(100%-94px)]\"\n typing={\n isTyping || carregando\n ? {\n id: 'ai',\n name: 'Chat AI',\n avatarImageUrl: '/img/thumbs/ai.jpg',\n }\n : false\n }\n customRenderer={(message) => {\n if (message.isError) {\n return <AiErrorMessage />\n }\n\n if (message.sender.id === 'ai') {\n // As ferramentas e as pausas chegam pelo streaming e\n // vivem no Conversation; o tipo do ChatBox nao os conhece.\n const {\n tools,\n pendingApproval,\n pendingInput,\n pendingFormat,\n relatorios,\n falhou,\n } = message as Conversation\n // Enquanto as ferramentas rodam o conteudo ainda e '':\n // sem esta guarda sobraria um balao cinza vazio.\n const temTexto = Boolean(\n (message.content as string)?.trim(),\n )\n\n return (\n <div className=\"flex flex-col items-start gap-1.5\">\n {tools?.map((tool) => (\n <ToolCallChip key={tool.id} tool={tool} />\n ))}\n {temTexto && (\n <div className={BALAO_AGENTE}>\n <ChatCustomContent\n content={message.content as string}\n triggerTyping={\n message.fresh\n ? message.fresh\n : false\n }\n onFinish={() =>\n handleFinish(message.id)\n }\n />\n </div>\n )}\n {relatorios?.map((relatorio) =>\n relatorio.formato === 'xlsx' ? (\n <PlanilhaNaMensagem\n key={relatorio.id}\n planilha={relatorio}\n />\n ) : (\n <RelatorioNaMensagem\n key={relatorio.id}\n relatorio={relatorio}\n />\n ),\n )}\n {pendingFormat && (\n <FormatoCard\n onChoose={(formato) =>\n handleFormato(\n selectedConversation,\n message.id,\n formato,\n )\n }\n />\n )}\n {pendingInput && (\n <DataRequestCard\n input={pendingInput}\n onSubmit={(dados) =>\n handleDataSubmit(\n selectedConversation,\n message.id,\n dados,\n )\n }\n />\n )}\n {pendingApproval && (\n <ApprovalCard\n approval={pendingApproval}\n onDecide={(aprovado) =>\n handleApproval(\n selectedConversation,\n message.id,\n aprovado,\n )\n }\n />\n )}\n {/* Falhou no meio: o que ja chegou fica, e o\n aviso vem depois, em vez de apagar tudo. */}\n {falhou && <AiErrorMessage />}\n </div>\n )\n }\n\n const { imagens } = message as Conversation\n return (\n <div className=\"flex flex-col gap-2\">\n <ImagensDaMensagem imagens={imagens} />\n {message.content}\n </div>\n )\n }}\n customAction={(message) => {\n if (message.sender.id === 'ai' && !message.isError) {\n return (\n <ChatCustomAction\n content={message.content as string}\n />\n )\n }\n\n return null\n }}\n onInputChange={handleInputChange}\n uploadProps={{\n ...UPLOAD_DE_IMAGENS,\n disabled: atual?.imagens === false,\n }}\n inputActions={\n <ModeloERaciocinio floatingClass={dropdownFloatingClass} />\n }\n >\n {/* Os children ficam entre a lista e o input: sem conversa e a\n landing com os cards; com conversa, o aviso sobre a IA. */}\n {selectedConversation ? (\n <p className=\"py-1 text-center text-xs text-gray-500 dark:text-gray-400\">\n Orbe-AI é uma inteligência artificial e pode cometer\n erros.\n </p>\n ) : (\n <div className=\"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AGzE,IAEA,oBAAC,OAAA,EAAI,WAAU,kCACX,UAAA,oBAAC,mBAAgB,EAAA,CACrB;AAAA,MAAA;AAAA,IAAA;AAAA,EAER,GACJ;AAER;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { TbReportAnalytics, TbFileSpreadsheet, TbFileExport } from "react-icons/tb";
|
|
4
|
+
import "../../../../../components/ui/Button/index.js";
|
|
5
|
+
import classNames from "../../../../../components/ui/utils/classNames.js";
|
|
6
|
+
import Button from "../../../../../components/ui/Button/Button.js";
|
|
7
|
+
const OPCOES = [
|
|
8
|
+
{
|
|
9
|
+
formato: "html",
|
|
10
|
+
titulo: "Relatório HTML",
|
|
11
|
+
descricao: "Visual, com indicadores e gráficos. Abre aqui e no navegador.",
|
|
12
|
+
Icone: TbReportAnalytics
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
formato: "xlsx",
|
|
16
|
+
titulo: "Planilha Excel",
|
|
17
|
+
descricao: "Os registros em colunas, para filtrar e trabalhar.",
|
|
18
|
+
Icone: TbFileSpreadsheet
|
|
19
|
+
}
|
|
20
|
+
];
|
|
21
|
+
const FormatoCard = ({ onChoose }) => {
|
|
22
|
+
const [escolha, setEscolha] = useState();
|
|
23
|
+
const decidido = escolha !== void 0;
|
|
24
|
+
const escolher = (formato) => {
|
|
25
|
+
setEscolha(formato);
|
|
26
|
+
onChoose(formato);
|
|
27
|
+
};
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", { className: "not-prose mt-1 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800", children: [
|
|
29
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 border-b border-gray-200 px-4 py-2.5 dark:border-gray-700", children: [
|
|
30
|
+
/* @__PURE__ */ jsx(
|
|
31
|
+
TbFileExport,
|
|
32
|
+
{
|
|
33
|
+
size: 16,
|
|
34
|
+
className: "text-gray-400 dark:text-gray-500"
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400", children: "Formato do relatório" })
|
|
38
|
+
] }),
|
|
39
|
+
/* @__PURE__ */ jsxs("div", { className: "px-4 py-3.5", children: [
|
|
40
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 text-sm text-gray-500 dark:text-gray-400", children: "Em qual formato você quer o relatório?" }),
|
|
41
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-2 sm:grid-cols-2", children: OPCOES.map(({ formato, titulo, descricao, Icone }) => /* @__PURE__ */ jsxs(
|
|
42
|
+
"button",
|
|
43
|
+
{
|
|
44
|
+
type: "button",
|
|
45
|
+
disabled: decidido,
|
|
46
|
+
"aria-pressed": escolha === formato,
|
|
47
|
+
onClick: () => escolher(formato),
|
|
48
|
+
className: classNames(
|
|
49
|
+
"flex items-start gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors disabled:cursor-not-allowed",
|
|
50
|
+
escolha === formato ? "border-primary bg-primary-subtle" : "border-gray-200 enabled:hover:border-primary enabled:hover:bg-gray-50 disabled:opacity-60 dark:border-gray-700 dark:enabled:hover:bg-gray-700"
|
|
51
|
+
),
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ jsx("span", { className: "mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary", children: /* @__PURE__ */ jsx(Icone, { size: 17 }) }),
|
|
54
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
|
|
55
|
+
/* @__PURE__ */ jsx("span", { className: "block font-semibold text-gray-900 dark:text-gray-100", children: titulo }),
|
|
56
|
+
/* @__PURE__ */ jsx("span", { className: "block text-xs text-gray-500 dark:text-gray-400", children: descricao })
|
|
57
|
+
] })
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
formato
|
|
61
|
+
)) }),
|
|
62
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-4 flex items-center gap-2", children: [
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
Button,
|
|
65
|
+
{
|
|
66
|
+
size: "sm",
|
|
67
|
+
loading: escolha === null,
|
|
68
|
+
disabled: decidido,
|
|
69
|
+
onClick: () => escolher(null),
|
|
70
|
+
children: "Agora não"
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-gray-400 dark:text-gray-500", children: "Os dados saem da consulta, com o seu acesso" })
|
|
74
|
+
] })
|
|
75
|
+
] })
|
|
76
|
+
] });
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
FormatoCard as default
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=FormatoCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormatoCard.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/FormatoCard.tsx"],"sourcesContent":["import { useState } from 'react'\nimport {\n TbFileExport,\n TbFileSpreadsheet,\n TbReportAnalytics,\n} from 'react-icons/tb'\nimport Button from '@/components/ui/Button'\nimport classNames from '@/components/ui/utils/classNames'\nimport type { IconType } from 'react-icons'\nimport type { FormatoDoRelatorio } from '../types'\n\ntype OpcaoDeFormato = {\n formato: FormatoDoRelatorio\n titulo: string\n descricao: string\n Icone: IconType\n}\n\nconst OPCOES: ReadonlyArray<OpcaoDeFormato> = [\n {\n formato: 'html',\n titulo: 'Relatório HTML',\n descricao:\n 'Visual, com indicadores e gráficos. Abre aqui e no navegador.',\n Icone: TbReportAnalytics,\n },\n {\n formato: 'xlsx',\n titulo: 'Planilha Excel',\n descricao: 'Os registros em colunas, para filtrar e trabalhar.',\n Icone: TbFileSpreadsheet,\n },\n]\n\ntype FormatoCardProps = {\n /** `null` = o usuario fechou sem escolher. */\n onChoose: (formato: FormatoDoRelatorio | null) => void\n}\n\n/**\n * A escolha do formato de um relatorio que o usuario pediu sem dizer qual.\n *\n * O agente fica PARADO enquanto este card estiver na tela, como no ApprovalCard\n * e no DataRequestCard - e divide o visual deles, para o usuario reconhecer as\n * tres paradas como a mesma coisa. Depois do clique tudo desabilita: dois\n * cliques mandariam duas retomadas, e a segunda falha.\n */\nconst FormatoCard = ({ onChoose }: FormatoCardProps) => {\n // `undefined` = ainda nao escolheu; `null` = fechou sem escolher.\n const [escolha, setEscolha] = useState<FormatoDoRelatorio | null>()\n const decidido = escolha !== undefined\n\n const escolher = (formato: FormatoDoRelatorio | null) => {\n setEscolha(formato)\n onChoose(formato)\n }\n\n return (\n <div className=\"not-prose mt-1 overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800\">\n <div className=\"flex items-center gap-2 border-b border-gray-200 px-4 py-2.5 dark:border-gray-700\">\n <TbFileExport\n size={16}\n className=\"text-gray-400 dark:text-gray-500\"\n />\n <span className=\"text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400\">\n Formato do relatório\n </span>\n </div>\n\n <div className=\"px-4 py-3.5\">\n <div className=\"mb-3 text-sm text-gray-500 dark:text-gray-400\">\n Em qual formato você quer o relatório?\n </div>\n\n <div className=\"grid gap-2 sm:grid-cols-2\">\n {OPCOES.map(({ formato, titulo, descricao, Icone }) => (\n <button\n key={formato}\n type=\"button\"\n disabled={decidido}\n aria-pressed={escolha === formato}\n onClick={() => escolher(formato)}\n className={classNames(\n 'flex items-start gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors disabled:cursor-not-allowed',\n escolha === formato\n ? 'border-primary bg-primary-subtle'\n : 'border-gray-200 enabled:hover:border-primary enabled:hover:bg-gray-50 disabled:opacity-60 dark:border-gray-700 dark:enabled:hover:bg-gray-700',\n )}\n >\n <span className=\"mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary\">\n <Icone size={17} />\n </span>\n <span className=\"min-w-0\">\n <span className=\"block font-semibold text-gray-900 dark:text-gray-100\">\n {titulo}\n </span>\n <span className=\"block text-xs text-gray-500 dark:text-gray-400\">\n {descricao}\n </span>\n </span>\n </button>\n ))}\n </div>\n\n <div className=\"mt-4 flex items-center gap-2\">\n <Button\n size=\"sm\"\n loading={escolha === null}\n disabled={decidido}\n onClick={() => escolher(null)}\n >\n Agora não\n </Button>\n <span className=\"ml-auto text-xs text-gray-400 dark:text-gray-500\">\n Os dados saem da consulta, com o seu acesso\n </span>\n </div>\n </div>\n </div>\n )\n}\n\nexport default FormatoCard\n"],"names":[],"mappings":";;;;;;AAkBA,MAAM,SAAwC;AAAA,EAC1C;AAAA,IACI,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WACI;AAAA,IACJ,OAAO;AAAA,EAAA;AAAA,EAEX;AAAA,IACI,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,OAAO;AAAA,EAAA;AAEf;AAeA,MAAM,cAAc,CAAC,EAAE,eAAiC;AAEpD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAA;AAC9B,QAAM,WAAW,YAAY;AAE7B,QAAM,WAAW,CAAC,YAAuC;AACrD,eAAW,OAAO;AAClB,aAAS,OAAO;AAAA,EACpB;AAEA,SACI,qBAAC,OAAA,EAAI,WAAU,6HACX,UAAA;AAAA,IAAA,qBAAC,OAAA,EAAI,WAAU,qFACX,UAAA;AAAA,MAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACG,MAAM;AAAA,UACN,WAAU;AAAA,QAAA;AAAA,MAAA;AAAA,MAEd,oBAAC,QAAA,EAAK,WAAU,kFAAiF,UAAA,uBAAA,CAEjG;AAAA,IAAA,GACJ;AAAA,IAEA,qBAAC,OAAA,EAAI,WAAU,eACX,UAAA;AAAA,MAAA,oBAAC,OAAA,EAAI,WAAU,iDAAgD,UAAA,0CAE/D;AAAA,MAEA,oBAAC,OAAA,EAAI,WAAU,6BACV,UAAA,OAAO,IAAI,CAAC,EAAE,SAAS,QAAQ,WAAW,MAAA,MACvC;AAAA,QAAC;AAAA,QAAA;AAAA,UAEG,MAAK;AAAA,UACL,UAAU;AAAA,UACV,gBAAc,YAAY;AAAA,UAC1B,SAAS,MAAM,SAAS,OAAO;AAAA,UAC/B,WAAW;AAAA,YACP;AAAA,YACA,YAAY,UACN,qCACA;AAAA,UAAA;AAAA,UAGV,UAAA;AAAA,YAAA,oBAAC,UAAK,WAAU,qGACZ,8BAAC,OAAA,EAAM,MAAM,IAAI,EAAA,CACrB;AAAA,YACA,qBAAC,QAAA,EAAK,WAAU,WACZ,UAAA;AAAA,cAAA,oBAAC,QAAA,EAAK,WAAU,wDACX,UAAA,QACL;AAAA,cACA,oBAAC,QAAA,EAAK,WAAU,kDACX,UAAA,UAAA,CACL;AAAA,YAAA,EAAA,CACJ;AAAA,UAAA;AAAA,QAAA;AAAA,QAtBK;AAAA,MAAA,CAwBZ,GACL;AAAA,MAEA,qBAAC,OAAA,EAAI,WAAU,gCACX,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,MAAK;AAAA,YACL,SAAS,YAAY;AAAA,YACrB,UAAU;AAAA,YACV,SAAS,MAAM,SAAS,IAAI;AAAA,YAC/B,UAAA;AAAA,UAAA;AAAA,QAAA;AAAA,QAGD,oBAAC,QAAA,EAAK,WAAU,oDAAmD,UAAA,8CAAA,CAEnE;AAAA,MAAA,EAAA,CACJ;AAAA,IAAA,EAAA,CACJ;AAAA,EAAA,GACJ;AAER;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { TbPhotoOff } from "react-icons/tb";
|
|
3
|
+
import "../../../../../components/ui/Skeleton/index.js";
|
|
4
|
+
import useImagemDoStorage from "../hooks/useImagemDoStorage.js";
|
|
5
|
+
import Skeleton from "../../../../../components/ui/Skeleton/Skeleton.js";
|
|
6
|
+
const MINIATURA = "h-40 max-w-[240px] rounded-lg object-cover";
|
|
7
|
+
const Miniatura = ({ imagem }) => {
|
|
8
|
+
const { src, carregando, falhou } = useImagemDoStorage(imagem);
|
|
9
|
+
if (carregando) {
|
|
10
|
+
return /* @__PURE__ */ jsx(Skeleton, { width: 160, height: 160, className: "rounded-lg" });
|
|
11
|
+
}
|
|
12
|
+
if (falhou || !src) {
|
|
13
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-40 w-40 flex-col items-center justify-center gap-1 rounded-lg bg-white/10 text-xs", children: [
|
|
14
|
+
/* @__PURE__ */ jsx(TbPhotoOff, { className: "text-2xl" }),
|
|
15
|
+
"Imagem indisponível"
|
|
16
|
+
] });
|
|
17
|
+
}
|
|
18
|
+
return /* @__PURE__ */ jsx("img", { className: MINIATURA, src, alt: "Imagem enviada" });
|
|
19
|
+
};
|
|
20
|
+
const ImagensDaMensagem = ({ imagens }) => {
|
|
21
|
+
if (!imagens?.length) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: imagens.map((imagem, indice) => /* @__PURE__ */ jsx(
|
|
25
|
+
Miniatura,
|
|
26
|
+
{
|
|
27
|
+
imagem
|
|
28
|
+
},
|
|
29
|
+
imagem.objectName ?? imagem.url ?? indice
|
|
30
|
+
)) });
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
ImagensDaMensagem as default
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=ImagensDaMensagem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImagensDaMensagem.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ImagensDaMensagem.tsx"],"sourcesContent":["import { TbPhotoOff } from 'react-icons/tb'\nimport Skeleton from '@/components/ui/Skeleton'\nimport useImagemDoStorage from '../hooks/useImagemDoStorage'\nimport type { ImagemDaMensagem } from '../types'\n\nconst MINIATURA = 'h-40 max-w-[240px] rounded-lg object-cover'\n\nconst Miniatura = ({ imagem }: { imagem: ImagemDaMensagem }) => {\n const { src, carregando, falhou } = useImagemDoStorage(imagem)\n\n if (carregando) {\n return <Skeleton width={160} height={160} className=\"rounded-lg\" />\n }\n\n if (falhou || !src) {\n return (\n <div className=\"flex h-40 w-40 flex-col items-center justify-center gap-1 rounded-lg bg-white/10 text-xs\">\n <TbPhotoOff className=\"text-2xl\" />\n Imagem indisponível\n </div>\n )\n }\n\n return <img className={MINIATURA} src={src} alt=\"Imagem enviada\" />\n}\n\ntype ImagensDaMensagemProps = {\n imagens?: ImagemDaMensagem[]\n}\n\n/**\n * As imagens que o usuário enviou, em miniatura, acima do texto da mensagem.\n *\n * Serve a mensagem recém-enviada (blob local) e a que veio do histórico\n * (baixada do object storage) - quem resolve de onde vem é o hook.\n */\nconst ImagensDaMensagem = ({ imagens }: ImagensDaMensagemProps) => {\n if (!imagens?.length) {\n return null\n }\n\n return (\n <div className=\"flex flex-wrap gap-2\">\n {imagens.map((imagem, indice) => (\n <Miniatura\n key={imagem.objectName ?? imagem.url ?? indice}\n imagem={imagem}\n />\n ))}\n </div>\n )\n}\n\nexport default ImagensDaMensagem\n"],"names":[],"mappings":";;;;;AAKA,MAAM,YAAY;AAElB,MAAM,YAAY,CAAC,EAAE,aAA2C;AAC5D,QAAM,EAAE,KAAK,YAAY,OAAA,IAAW,mBAAmB,MAAM;AAE7D,MAAI,YAAY;AACZ,+BAAQ,UAAA,EAAS,OAAO,KAAK,QAAQ,KAAK,WAAU,cAAa;AAAA,EACrE;AAEA,MAAI,UAAU,CAAC,KAAK;AAChB,WACI,qBAAC,OAAA,EAAI,WAAU,4FACX,UAAA;AAAA,MAAA,oBAAC,YAAA,EAAW,WAAU,WAAA,CAAW;AAAA,MAAE;AAAA,IAAA,GAEvC;AAAA,EAER;AAEA,6BAAQ,OAAA,EAAI,WAAW,WAAW,KAAU,KAAI,kBAAiB;AACrE;AAYA,MAAM,oBAAoB,CAAC,EAAE,cAAsC;AAC/D,MAAI,CAAC,SAAS,QAAQ;AAClB,WAAO;AAAA,EACX;AAEA,SACI,oBAAC,SAAI,WAAU,wBACV,kBAAQ,IAAI,CAAC,QAAQ,WAClB;AAAA,IAAC;AAAA,IAAA;AAAA,MAEG;AAAA,IAAA;AAAA,IADK,OAAO,cAAc,OAAO,OAAO;AAAA,EAAA,CAG/C,GACL;AAER;"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { TbCheck, TbSparkles, TbBrain, TbChevronDown } from "react-icons/tb";
|
|
3
|
+
import { Dropdown } from "../../../../../components/ui/Dropdown/index.js";
|
|
4
|
+
import useModelos from "../hooks/useModelos.js";
|
|
5
|
+
import { useEsforcoStore } from "../store/esforcoStore.js";
|
|
6
|
+
import { useModeloStore } from "../store/modeloStore.js";
|
|
7
|
+
const NIVEIS = [
|
|
8
|
+
{
|
|
9
|
+
valor: "minimal",
|
|
10
|
+
rotulo: "Mínimo",
|
|
11
|
+
descricao: "Mais rápido, para consultas diretas."
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
valor: "medium",
|
|
15
|
+
rotulo: "Médio",
|
|
16
|
+
descricao: "Equilíbrio entre rapidez e cuidado. Recomendado."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
valor: "high",
|
|
20
|
+
rotulo: "Alto",
|
|
21
|
+
descricao: "Pensa mais antes de responder; bom para análises."
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
valor: "max",
|
|
25
|
+
rotulo: "Máximo",
|
|
26
|
+
descricao: "Pensa o máximo possível antes de responder."
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
const ehEsforco = (valor) => NIVEIS.some((nivel) => nivel.valor === valor);
|
|
30
|
+
const ALTURA_LIVRE = { height: "auto" };
|
|
31
|
+
const ITEM_EM_DUAS_LINHAS = "items-start whitespace-normal py-2";
|
|
32
|
+
const Secao = ({ titulo, descricao }) => /* @__PURE__ */ jsx(Dropdown.Item, { variant: "header", children: /* @__PURE__ */ jsxs("div", { className: "px-3 pb-2", children: [
|
|
33
|
+
/* @__PURE__ */ jsx("div", { className: "heading-text text-sm font-bold", children: titulo }),
|
|
34
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500 dark:text-gray-400", children: descricao })
|
|
35
|
+
] }) });
|
|
36
|
+
const Opcao = ({ titulo, descricao, marcada }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
37
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
38
|
+
/* @__PURE__ */ jsx("div", { children: titulo }),
|
|
39
|
+
descricao && /* @__PURE__ */ jsx("div", { className: "text-xs font-normal text-gray-500 dark:text-gray-400", children: descricao })
|
|
40
|
+
] }),
|
|
41
|
+
marcada && /* @__PURE__ */ jsx(TbCheck, { className: "mt-0.5 shrink-0 text-lg" })
|
|
42
|
+
] });
|
|
43
|
+
const ModeloERaciocinio = ({ floatingClass }) => {
|
|
44
|
+
const { esforco, setEsforco } = useEsforcoStore();
|
|
45
|
+
const setModelo = useModeloStore((state) => state.setModelo);
|
|
46
|
+
const { modelos, escolhido } = useModelos();
|
|
47
|
+
const nivelAtual = NIVEIS.find((nivel) => nivel.valor === esforco);
|
|
48
|
+
const modeloAtual = modelos.length > 1 ? escolhido : void 0;
|
|
49
|
+
const handleEsforco = (valor) => {
|
|
50
|
+
if (ehEsforco(valor)) {
|
|
51
|
+
setEsforco(valor);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const handleModelo = (id) => {
|
|
55
|
+
if (modelos.some((modelo) => modelo.id === id)) {
|
|
56
|
+
setModelo(id);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const rotuloDoBotao = modeloAtual ? `Modelo: ${modeloAtual.nome}. Raciocínio: ${nivelAtual?.rotulo}` : `Nível de raciocínio: ${nivelAtual?.rotulo}`;
|
|
60
|
+
return /* @__PURE__ */ jsxs(
|
|
61
|
+
Dropdown,
|
|
62
|
+
{
|
|
63
|
+
placement: "top-end",
|
|
64
|
+
menuClass: "w-72 max-h-[60vh] overflow-y-auto",
|
|
65
|
+
toggleClassName: "min-w-0",
|
|
66
|
+
floatingClass,
|
|
67
|
+
renderTitle: /* @__PURE__ */ jsxs(
|
|
68
|
+
"button",
|
|
69
|
+
{
|
|
70
|
+
type: "button",
|
|
71
|
+
"aria-label": rotuloDoBotao,
|
|
72
|
+
title: rotuloDoBotao,
|
|
73
|
+
className: "flex min-w-0 items-center gap-1 rounded-lg px-2 py-1 text-xs font-semibold text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100",
|
|
74
|
+
children: [
|
|
75
|
+
modeloAtual ? /* @__PURE__ */ jsx(TbSparkles, { className: "shrink-0 text-base" }) : /* @__PURE__ */ jsx(TbBrain, { className: "shrink-0 text-base" }),
|
|
76
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 max-w-[9rem] truncate", children: modeloAtual?.nome ?? nivelAtual?.rotulo }),
|
|
77
|
+
/* @__PURE__ */ jsx(TbChevronDown, { className: "shrink-0" })
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
children: [
|
|
82
|
+
modeloAtual && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
Secao,
|
|
85
|
+
{
|
|
86
|
+
titulo: "Modelo",
|
|
87
|
+
descricao: "Qual inteligência artificial responde."
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
modelos.map((modelo) => /* @__PURE__ */ jsx(
|
|
91
|
+
Dropdown.Item,
|
|
92
|
+
{
|
|
93
|
+
eventKey: modelo.id,
|
|
94
|
+
onSelect: handleModelo,
|
|
95
|
+
style: ALTURA_LIVRE,
|
|
96
|
+
className: ITEM_EM_DUAS_LINHAS,
|
|
97
|
+
children: /* @__PURE__ */ jsx(
|
|
98
|
+
Opcao,
|
|
99
|
+
{
|
|
100
|
+
titulo: modelo.nome,
|
|
101
|
+
descricao: modelo.imagens ? void 0 : "Só lê texto.",
|
|
102
|
+
marcada: modelo.id === modeloAtual.id
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
},
|
|
106
|
+
modelo.id
|
|
107
|
+
)),
|
|
108
|
+
/* @__PURE__ */ jsx(Dropdown.Item, { variant: "divider" })
|
|
109
|
+
] }),
|
|
110
|
+
/* @__PURE__ */ jsx(
|
|
111
|
+
Secao,
|
|
112
|
+
{
|
|
113
|
+
titulo: "Raciocínio",
|
|
114
|
+
descricao: "Quanto o assistente pensa antes de responder."
|
|
115
|
+
}
|
|
116
|
+
),
|
|
117
|
+
NIVEIS.map((nivel) => /* @__PURE__ */ jsx(
|
|
118
|
+
Dropdown.Item,
|
|
119
|
+
{
|
|
120
|
+
eventKey: nivel.valor,
|
|
121
|
+
onSelect: handleEsforco,
|
|
122
|
+
style: ALTURA_LIVRE,
|
|
123
|
+
className: ITEM_EM_DUAS_LINHAS,
|
|
124
|
+
children: /* @__PURE__ */ jsx(
|
|
125
|
+
Opcao,
|
|
126
|
+
{
|
|
127
|
+
titulo: nivel.rotulo,
|
|
128
|
+
descricao: nivel.descricao,
|
|
129
|
+
marcada: nivel.valor === esforco
|
|
130
|
+
}
|
|
131
|
+
)
|
|
132
|
+
},
|
|
133
|
+
nivel.valor
|
|
134
|
+
))
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
export {
|
|
140
|
+
ModeloERaciocinio as default
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=ModeloERaciocinio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModeloERaciocinio.js","sources":["../../../../../../../lib/@ecme/views/concepts/ai/Chat/components/ModeloERaciocinio.tsx"],"sourcesContent":["import { TbBrain, TbCheck, TbChevronDown, TbSparkles } from 'react-icons/tb'\nimport Dropdown from '@/components/ui/Dropdown'\nimport useModelos from '../hooks/useModelos'\nimport { useEsforcoStore } from '../store/esforcoStore'\nimport { useModeloStore } from '../store/modeloStore'\nimport type { Esforco } from '../types'\n\ntype NivelDeEsforco = {\n valor: Esforco\n rotulo: string\n descricao: string\n}\n\n/** Os níveis, do menor para o maior raciocínio. Servem o botão e o menu. */\nconst NIVEIS: ReadonlyArray<NivelDeEsforco> = [\n {\n valor: 'minimal',\n rotulo: 'Mínimo',\n descricao: 'Mais rápido, para consultas diretas.',\n },\n {\n valor: 'medium',\n rotulo: 'Médio',\n descricao: 'Equilíbrio entre rapidez e cuidado. Recomendado.',\n },\n {\n valor: 'high',\n rotulo: 'Alto',\n descricao: 'Pensa mais antes de responder; bom para análises.',\n },\n {\n valor: 'max',\n rotulo: 'Máximo',\n descricao: 'Pensa o máximo possível antes de responder.',\n },\n]\n\n/** O `eventKey` do Dropdown é `string`; só um dos níveis acima é aceito. */\nconst ehEsforco = (valor: string): valor is Esforco =>\n NIVEIS.some((nivel) => nivel.valor === valor)\n\n// O MenuItem fixa 42px de altura e `nowrap`, feitos para uma linha; aqui um\n// item pode ter título e descrição.\nconst ALTURA_LIVRE = { height: 'auto' }\nconst ITEM_EM_DUAS_LINHAS = 'items-start whitespace-normal py-2'\n\ntype SecaoProps = {\n titulo: string\n descricao: string\n}\n\n/** Cabeçalho de uma seção do menu. */\nconst Secao = ({ titulo, descricao }: SecaoProps) => (\n <Dropdown.Item variant=\"header\">\n <div className=\"px-3 pb-2\">\n <div className=\"heading-text text-sm font-bold\">{titulo}</div>\n <div className=\"text-xs text-gray-500 dark:text-gray-400\">\n {descricao}\n </div>\n </div>\n </Dropdown.Item>\n)\n\ntype OpcaoProps = {\n titulo: string\n descricao?: string\n marcada: boolean\n}\n\n/** Conteúdo de um item: título, descrição e o check no escolhido. */\nconst Opcao = ({ titulo, descricao, marcada }: OpcaoProps) => (\n <>\n <div className=\"flex-1\">\n <div>{titulo}</div>\n {descricao && (\n <div className=\"text-xs font-normal text-gray-500 dark:text-gray-400\">\n {descricao}\n </div>\n )}\n </div>\n {marcada && <TbCheck className=\"mt-0.5 shrink-0 text-lg\" />}\n </>\n)\n\ntype ModeloERaciocinioProps = {\n /** Classes do menu flutuante; o widget passa um z-index acima do painel. */\n floatingClass?: string\n}\n\n/**\n * O modelo e o nível de raciocínio, num menu só dentro da caixa de mensagem.\n *\n * Com mais de um modelo para escolher, o botão mostra o modelo e o menu tem as\n * duas seções. Com um só, sem a permissão de escolher (ver `useModelos`) ou sem\n * a lista do backend, fica como era: o botão mostra o nível e o menu só tem o\n * raciocínio. A escolha vale para as próximas mensagens (e para as retomadas de\n * aprovação e de formulário); as respostas já dadas não mudam.\n */\nconst ModeloERaciocinio = ({ floatingClass }: ModeloERaciocinioProps) => {\n const { esforco, setEsforco } = useEsforcoStore()\n const setModelo = useModeloStore((state) => state.setModelo)\n const { modelos, escolhido } = useModelos()\n\n const nivelAtual = NIVEIS.find((nivel) => nivel.valor === esforco)\n const modeloAtual = modelos.length > 1 ? escolhido : undefined\n\n const handleEsforco = (valor: string) => {\n if (ehEsforco(valor)) {\n setEsforco(valor)\n }\n }\n\n /** Como no nível: só um id da lista do backend é aceito. */\n const handleModelo = (id: string) => {\n if (modelos.some((modelo) => modelo.id === id)) {\n setModelo(id)\n }\n }\n\n const rotuloDoBotao = modeloAtual\n ? `Modelo: ${modeloAtual.nome}. Raciocínio: ${nivelAtual?.rotulo}`\n : `Nível de raciocínio: ${nivelAtual?.rotulo}`\n\n return (\n <Dropdown\n placement=\"top-end\"\n menuClass=\"w-72 max-h-[60vh] overflow-y-auto\"\n // Sem largura mínima: num painel estreito o nome do modelo é\n // cortado antes de o campo de texto sumir.\n toggleClassName=\"min-w-0\"\n floatingClass={floatingClass}\n renderTitle={\n <button\n type=\"button\"\n aria-label={rotuloDoBotao}\n title={rotuloDoBotao}\n className=\"flex min-w-0 items-center gap-1 rounded-lg px-2 py-1 text-xs font-semibold text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-900 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-gray-100\"\n >\n {modeloAtual ? (\n <TbSparkles className=\"shrink-0 text-base\" />\n ) : (\n <TbBrain className=\"shrink-0 text-base\" />\n )}\n <span className=\"min-w-0 max-w-[9rem] truncate\">\n {modeloAtual?.nome ?? nivelAtual?.rotulo}\n </span>\n <TbChevronDown className=\"shrink-0\" />\n </button>\n }\n >\n {modeloAtual && (\n <>\n <Secao\n titulo=\"Modelo\"\n descricao=\"Qual inteligência artificial responde.\"\n />\n {modelos.map((modelo) => (\n <Dropdown.Item\n key={modelo.id}\n eventKey={modelo.id}\n onSelect={handleModelo}\n style={ALTURA_LIVRE}\n className={ITEM_EM_DUAS_LINHAS}\n >\n <Opcao\n titulo={modelo.nome}\n descricao={\n modelo.imagens ? undefined : 'Só lê texto.'\n }\n marcada={modelo.id === modeloAtual.id}\n />\n </Dropdown.Item>\n ))}\n <Dropdown.Item variant=\"divider\" />\n </>\n )}\n <Secao\n titulo=\"Raciocínio\"\n descricao=\"Quanto o assistente pensa antes de responder.\"\n />\n {NIVEIS.map((nivel) => (\n <Dropdown.Item\n key={nivel.valor}\n eventKey={nivel.valor}\n onSelect={handleEsforco}\n style={ALTURA_LIVRE}\n className={ITEM_EM_DUAS_LINHAS}\n >\n <Opcao\n titulo={nivel.rotulo}\n descricao={nivel.descricao}\n marcada={nivel.valor === esforco}\n />\n </Dropdown.Item>\n ))}\n </Dropdown>\n )\n}\n\nexport default ModeloERaciocinio\n"],"names":[],"mappings":";;;;;;AAcA,MAAM,SAAwC;AAAA,EAC1C;AAAA,IACI,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW;AAAA,EAAA;AAAA,EAEf;AAAA,IACI,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW;AAAA,EAAA;AAAA,EAEf;AAAA,IACI,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,WAAW;AAAA,EAAA;AAAA,EAEf;AAAA,IACI,OAAO;AAAA,IAC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