@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
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
TbFileExport,
|
|
4
|
+
TbFileSpreadsheet,
|
|
5
|
+
TbReportAnalytics,
|
|
6
|
+
} from 'react-icons/tb'
|
|
7
|
+
import Button from '@/components/ui/Button'
|
|
8
|
+
import classNames from '@/components/ui/utils/classNames'
|
|
9
|
+
import type { IconType } from 'react-icons'
|
|
10
|
+
import type { FormatoDoRelatorio } from '../types'
|
|
11
|
+
|
|
12
|
+
type OpcaoDeFormato = {
|
|
13
|
+
formato: FormatoDoRelatorio
|
|
14
|
+
titulo: string
|
|
15
|
+
descricao: string
|
|
16
|
+
Icone: IconType
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const OPCOES: ReadonlyArray<OpcaoDeFormato> = [
|
|
20
|
+
{
|
|
21
|
+
formato: 'html',
|
|
22
|
+
titulo: 'Relatório HTML',
|
|
23
|
+
descricao:
|
|
24
|
+
'Visual, com indicadores e gráficos. Abre aqui e no navegador.',
|
|
25
|
+
Icone: TbReportAnalytics,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
formato: 'xlsx',
|
|
29
|
+
titulo: 'Planilha Excel',
|
|
30
|
+
descricao: 'Os registros em colunas, para filtrar e trabalhar.',
|
|
31
|
+
Icone: TbFileSpreadsheet,
|
|
32
|
+
},
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
type FormatoCardProps = {
|
|
36
|
+
/** `null` = o usuario fechou sem escolher. */
|
|
37
|
+
onChoose: (formato: FormatoDoRelatorio | null) => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A escolha do formato de um relatorio que o usuario pediu sem dizer qual.
|
|
42
|
+
*
|
|
43
|
+
* O agente fica PARADO enquanto este card estiver na tela, como no ApprovalCard
|
|
44
|
+
* e no DataRequestCard - e divide o visual deles, para o usuario reconhecer as
|
|
45
|
+
* tres paradas como a mesma coisa. Depois do clique tudo desabilita: dois
|
|
46
|
+
* cliques mandariam duas retomadas, e a segunda falha.
|
|
47
|
+
*/
|
|
48
|
+
const FormatoCard = ({ onChoose }: FormatoCardProps) => {
|
|
49
|
+
// `undefined` = ainda nao escolheu; `null` = fechou sem escolher.
|
|
50
|
+
const [escolha, setEscolha] = useState<FormatoDoRelatorio | null>()
|
|
51
|
+
const decidido = escolha !== undefined
|
|
52
|
+
|
|
53
|
+
const escolher = (formato: FormatoDoRelatorio | null) => {
|
|
54
|
+
setEscolha(formato)
|
|
55
|
+
onChoose(formato)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<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">
|
|
60
|
+
<div className="flex items-center gap-2 border-b border-gray-200 px-4 py-2.5 dark:border-gray-700">
|
|
61
|
+
<TbFileExport
|
|
62
|
+
size={16}
|
|
63
|
+
className="text-gray-400 dark:text-gray-500"
|
|
64
|
+
/>
|
|
65
|
+
<span className="text-xs font-semibold uppercase tracking-wide text-gray-500 dark:text-gray-400">
|
|
66
|
+
Formato do relatório
|
|
67
|
+
</span>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div className="px-4 py-3.5">
|
|
71
|
+
<div className="mb-3 text-sm text-gray-500 dark:text-gray-400">
|
|
72
|
+
Em qual formato você quer o relatório?
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
<div className="grid gap-2 sm:grid-cols-2">
|
|
76
|
+
{OPCOES.map(({ formato, titulo, descricao, Icone }) => (
|
|
77
|
+
<button
|
|
78
|
+
key={formato}
|
|
79
|
+
type="button"
|
|
80
|
+
disabled={decidido}
|
|
81
|
+
aria-pressed={escolha === formato}
|
|
82
|
+
onClick={() => escolher(formato)}
|
|
83
|
+
className={classNames(
|
|
84
|
+
'flex items-start gap-2.5 rounded-lg border px-3 py-2.5 text-left transition-colors disabled:cursor-not-allowed',
|
|
85
|
+
escolha === formato
|
|
86
|
+
? 'border-primary bg-primary-subtle'
|
|
87
|
+
: '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',
|
|
88
|
+
)}
|
|
89
|
+
>
|
|
90
|
+
<span className="mt-0.5 flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary">
|
|
91
|
+
<Icone size={17} />
|
|
92
|
+
</span>
|
|
93
|
+
<span className="min-w-0">
|
|
94
|
+
<span className="block font-semibold text-gray-900 dark:text-gray-100">
|
|
95
|
+
{titulo}
|
|
96
|
+
</span>
|
|
97
|
+
<span className="block text-xs text-gray-500 dark:text-gray-400">
|
|
98
|
+
{descricao}
|
|
99
|
+
</span>
|
|
100
|
+
</span>
|
|
101
|
+
</button>
|
|
102
|
+
))}
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
<div className="mt-4 flex items-center gap-2">
|
|
106
|
+
<Button
|
|
107
|
+
size="sm"
|
|
108
|
+
loading={escolha === null}
|
|
109
|
+
disabled={decidido}
|
|
110
|
+
onClick={() => escolher(null)}
|
|
111
|
+
>
|
|
112
|
+
Agora não
|
|
113
|
+
</Button>
|
|
114
|
+
<span className="ml-auto text-xs text-gray-400 dark:text-gray-500">
|
|
115
|
+
Os dados saem da consulta, com o seu acesso
|
|
116
|
+
</span>
|
|
117
|
+
</div>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default FormatoCard
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { TbPhotoOff } from 'react-icons/tb'
|
|
2
|
+
import Skeleton from '@/components/ui/Skeleton'
|
|
3
|
+
import useImagemDoStorage from '../hooks/useImagemDoStorage'
|
|
4
|
+
import type { ImagemDaMensagem } from '../types'
|
|
5
|
+
|
|
6
|
+
const MINIATURA = 'h-40 max-w-[240px] rounded-lg object-cover'
|
|
7
|
+
|
|
8
|
+
const Miniatura = ({ imagem }: { imagem: ImagemDaMensagem }) => {
|
|
9
|
+
const { src, carregando, falhou } = useImagemDoStorage(imagem)
|
|
10
|
+
|
|
11
|
+
if (carregando) {
|
|
12
|
+
return <Skeleton width={160} height={160} className="rounded-lg" />
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (falhou || !src) {
|
|
16
|
+
return (
|
|
17
|
+
<div className="flex h-40 w-40 flex-col items-center justify-center gap-1 rounded-lg bg-white/10 text-xs">
|
|
18
|
+
<TbPhotoOff className="text-2xl" />
|
|
19
|
+
Imagem indisponível
|
|
20
|
+
</div>
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return <img className={MINIATURA} src={src} alt="Imagem enviada" />
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type ImagensDaMensagemProps = {
|
|
28
|
+
imagens?: ImagemDaMensagem[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* As imagens que o usuário enviou, em miniatura, acima do texto da mensagem.
|
|
33
|
+
*
|
|
34
|
+
* Serve a mensagem recém-enviada (blob local) e a que veio do histórico
|
|
35
|
+
* (baixada do object storage) - quem resolve de onde vem é o hook.
|
|
36
|
+
*/
|
|
37
|
+
const ImagensDaMensagem = ({ imagens }: ImagensDaMensagemProps) => {
|
|
38
|
+
if (!imagens?.length) {
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div className="flex flex-wrap gap-2">
|
|
44
|
+
{imagens.map((imagem, indice) => (
|
|
45
|
+
<Miniatura
|
|
46
|
+
key={imagem.objectName ?? imagem.url ?? indice}
|
|
47
|
+
imagem={imagem}
|
|
48
|
+
/>
|
|
49
|
+
))}
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default ImagensDaMensagem
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { TbBrain, TbCheck, TbChevronDown, TbSparkles } from 'react-icons/tb'
|
|
2
|
+
import Dropdown from '@/components/ui/Dropdown'
|
|
3
|
+
import useModelos from '../hooks/useModelos'
|
|
4
|
+
import { useEsforcoStore } from '../store/esforcoStore'
|
|
5
|
+
import { useModeloStore } from '../store/modeloStore'
|
|
6
|
+
import type { Esforco } from '../types'
|
|
7
|
+
|
|
8
|
+
type NivelDeEsforco = {
|
|
9
|
+
valor: Esforco
|
|
10
|
+
rotulo: string
|
|
11
|
+
descricao: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Os níveis, do menor para o maior raciocínio. Servem o botão e o menu. */
|
|
15
|
+
const NIVEIS: ReadonlyArray<NivelDeEsforco> = [
|
|
16
|
+
{
|
|
17
|
+
valor: 'minimal',
|
|
18
|
+
rotulo: 'Mínimo',
|
|
19
|
+
descricao: 'Mais rápido, para consultas diretas.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
valor: 'medium',
|
|
23
|
+
rotulo: 'Médio',
|
|
24
|
+
descricao: 'Equilíbrio entre rapidez e cuidado. Recomendado.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
valor: 'high',
|
|
28
|
+
rotulo: 'Alto',
|
|
29
|
+
descricao: 'Pensa mais antes de responder; bom para análises.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
valor: 'max',
|
|
33
|
+
rotulo: 'Máximo',
|
|
34
|
+
descricao: 'Pensa o máximo possível antes de responder.',
|
|
35
|
+
},
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
/** O `eventKey` do Dropdown é `string`; só um dos níveis acima é aceito. */
|
|
39
|
+
const ehEsforco = (valor: string): valor is Esforco =>
|
|
40
|
+
NIVEIS.some((nivel) => nivel.valor === valor)
|
|
41
|
+
|
|
42
|
+
// O MenuItem fixa 42px de altura e `nowrap`, feitos para uma linha; aqui um
|
|
43
|
+
// item pode ter título e descrição.
|
|
44
|
+
const ALTURA_LIVRE = { height: 'auto' }
|
|
45
|
+
const ITEM_EM_DUAS_LINHAS = 'items-start whitespace-normal py-2'
|
|
46
|
+
|
|
47
|
+
type SecaoProps = {
|
|
48
|
+
titulo: string
|
|
49
|
+
descricao: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Cabeçalho de uma seção do menu. */
|
|
53
|
+
const Secao = ({ titulo, descricao }: SecaoProps) => (
|
|
54
|
+
<Dropdown.Item variant="header">
|
|
55
|
+
<div className="px-3 pb-2">
|
|
56
|
+
<div className="heading-text text-sm font-bold">{titulo}</div>
|
|
57
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
58
|
+
{descricao}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</Dropdown.Item>
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
type OpcaoProps = {
|
|
65
|
+
titulo: string
|
|
66
|
+
descricao?: string
|
|
67
|
+
marcada: boolean
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Conteúdo de um item: título, descrição e o check no escolhido. */
|
|
71
|
+
const Opcao = ({ titulo, descricao, marcada }: OpcaoProps) => (
|
|
72
|
+
<>
|
|
73
|
+
<div className="flex-1">
|
|
74
|
+
<div>{titulo}</div>
|
|
75
|
+
{descricao && (
|
|
76
|
+
<div className="text-xs font-normal text-gray-500 dark:text-gray-400">
|
|
77
|
+
{descricao}
|
|
78
|
+
</div>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
{marcada && <TbCheck className="mt-0.5 shrink-0 text-lg" />}
|
|
82
|
+
</>
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
type ModeloERaciocinioProps = {
|
|
86
|
+
/** Classes do menu flutuante; o widget passa um z-index acima do painel. */
|
|
87
|
+
floatingClass?: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* O modelo e o nível de raciocínio, num menu só dentro da caixa de mensagem.
|
|
92
|
+
*
|
|
93
|
+
* Com mais de um modelo para escolher, o botão mostra o modelo e o menu tem as
|
|
94
|
+
* duas seções. Com um só, sem a permissão de escolher (ver `useModelos`) ou sem
|
|
95
|
+
* a lista do backend, fica como era: o botão mostra o nível e o menu só tem o
|
|
96
|
+
* raciocínio. A escolha vale para as próximas mensagens (e para as retomadas de
|
|
97
|
+
* aprovação e de formulário); as respostas já dadas não mudam.
|
|
98
|
+
*/
|
|
99
|
+
const ModeloERaciocinio = ({ floatingClass }: ModeloERaciocinioProps) => {
|
|
100
|
+
const { esforco, setEsforco } = useEsforcoStore()
|
|
101
|
+
const setModelo = useModeloStore((state) => state.setModelo)
|
|
102
|
+
const { modelos, escolhido } = useModelos()
|
|
103
|
+
|
|
104
|
+
const nivelAtual = NIVEIS.find((nivel) => nivel.valor === esforco)
|
|
105
|
+
const modeloAtual = modelos.length > 1 ? escolhido : undefined
|
|
106
|
+
|
|
107
|
+
const handleEsforco = (valor: string) => {
|
|
108
|
+
if (ehEsforco(valor)) {
|
|
109
|
+
setEsforco(valor)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Como no nível: só um id da lista do backend é aceito. */
|
|
114
|
+
const handleModelo = (id: string) => {
|
|
115
|
+
if (modelos.some((modelo) => modelo.id === id)) {
|
|
116
|
+
setModelo(id)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const rotuloDoBotao = modeloAtual
|
|
121
|
+
? `Modelo: ${modeloAtual.nome}. Raciocínio: ${nivelAtual?.rotulo}`
|
|
122
|
+
: `Nível de raciocínio: ${nivelAtual?.rotulo}`
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<Dropdown
|
|
126
|
+
placement="top-end"
|
|
127
|
+
menuClass="w-72 max-h-[60vh] overflow-y-auto"
|
|
128
|
+
// Sem largura mínima: num painel estreito o nome do modelo é
|
|
129
|
+
// cortado antes de o campo de texto sumir.
|
|
130
|
+
toggleClassName="min-w-0"
|
|
131
|
+
floatingClass={floatingClass}
|
|
132
|
+
renderTitle={
|
|
133
|
+
<button
|
|
134
|
+
type="button"
|
|
135
|
+
aria-label={rotuloDoBotao}
|
|
136
|
+
title={rotuloDoBotao}
|
|
137
|
+
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"
|
|
138
|
+
>
|
|
139
|
+
{modeloAtual ? (
|
|
140
|
+
<TbSparkles className="shrink-0 text-base" />
|
|
141
|
+
) : (
|
|
142
|
+
<TbBrain className="shrink-0 text-base" />
|
|
143
|
+
)}
|
|
144
|
+
<span className="min-w-0 max-w-[9rem] truncate">
|
|
145
|
+
{modeloAtual?.nome ?? nivelAtual?.rotulo}
|
|
146
|
+
</span>
|
|
147
|
+
<TbChevronDown className="shrink-0" />
|
|
148
|
+
</button>
|
|
149
|
+
}
|
|
150
|
+
>
|
|
151
|
+
{modeloAtual && (
|
|
152
|
+
<>
|
|
153
|
+
<Secao
|
|
154
|
+
titulo="Modelo"
|
|
155
|
+
descricao="Qual inteligência artificial responde."
|
|
156
|
+
/>
|
|
157
|
+
{modelos.map((modelo) => (
|
|
158
|
+
<Dropdown.Item
|
|
159
|
+
key={modelo.id}
|
|
160
|
+
eventKey={modelo.id}
|
|
161
|
+
onSelect={handleModelo}
|
|
162
|
+
style={ALTURA_LIVRE}
|
|
163
|
+
className={ITEM_EM_DUAS_LINHAS}
|
|
164
|
+
>
|
|
165
|
+
<Opcao
|
|
166
|
+
titulo={modelo.nome}
|
|
167
|
+
descricao={
|
|
168
|
+
modelo.imagens ? undefined : 'Só lê texto.'
|
|
169
|
+
}
|
|
170
|
+
marcada={modelo.id === modeloAtual.id}
|
|
171
|
+
/>
|
|
172
|
+
</Dropdown.Item>
|
|
173
|
+
))}
|
|
174
|
+
<Dropdown.Item variant="divider" />
|
|
175
|
+
</>
|
|
176
|
+
)}
|
|
177
|
+
<Secao
|
|
178
|
+
titulo="Raciocínio"
|
|
179
|
+
descricao="Quanto o assistente pensa antes de responder."
|
|
180
|
+
/>
|
|
181
|
+
{NIVEIS.map((nivel) => (
|
|
182
|
+
<Dropdown.Item
|
|
183
|
+
key={nivel.valor}
|
|
184
|
+
eventKey={nivel.valor}
|
|
185
|
+
onSelect={handleEsforco}
|
|
186
|
+
style={ALTURA_LIVRE}
|
|
187
|
+
className={ITEM_EM_DUAS_LINHAS}
|
|
188
|
+
>
|
|
189
|
+
<Opcao
|
|
190
|
+
titulo={nivel.rotulo}
|
|
191
|
+
descricao={nivel.descricao}
|
|
192
|
+
marcada={nivel.valor === esforco}
|
|
193
|
+
/>
|
|
194
|
+
</Dropdown.Item>
|
|
195
|
+
))}
|
|
196
|
+
</Dropdown>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export default ModeloERaciocinio
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { TbDownload, TbFileSpreadsheet } from 'react-icons/tb'
|
|
2
|
+
import * as XLSX from 'xlsx'
|
|
3
|
+
import Button from '@/components/ui/Button'
|
|
4
|
+
import type { PlanilhaDoChat } from '../types'
|
|
5
|
+
|
|
6
|
+
type PlanilhaNaMensagemProps = {
|
|
7
|
+
planilha: PlanilhaDoChat
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** O Excel limita o nome da aba a 31 caracteres. */
|
|
11
|
+
const MAX_NOME_DA_ABA = 31
|
|
12
|
+
|
|
13
|
+
/** Monta o .xlsx no navegador, uma aba por aba do backend, com o nome que ele deu. */
|
|
14
|
+
const baixarPlanilha = ({ abas, arquivo }: PlanilhaDoChat) => {
|
|
15
|
+
const workbook = XLSX.utils.book_new()
|
|
16
|
+
for (const aba of abas) {
|
|
17
|
+
const folha = XLSX.utils.aoa_to_sheet([aba.colunas, ...aba.linhas])
|
|
18
|
+
XLSX.utils.book_append_sheet(
|
|
19
|
+
workbook,
|
|
20
|
+
folha,
|
|
21
|
+
aba.nome.slice(0, MAX_NOME_DA_ABA),
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
XLSX.writeFile(workbook, arquivo)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Uma planilha gerada pelo agente: o resumo e o download.
|
|
29
|
+
*
|
|
30
|
+
* Os registros chegam do backend como vieram da consulta; o .xlsx so nasce no
|
|
31
|
+
* clique, para a mensagem nao carregar um arquivo que talvez ninguem baixe. A
|
|
32
|
+
* primeira aba e a dos registros, e por ela se conta as linhas.
|
|
33
|
+
*/
|
|
34
|
+
const PlanilhaNaMensagem = ({ planilha }: PlanilhaNaMensagemProps) => {
|
|
35
|
+
const linhas = planilha.abas[0]?.linhas.length ?? 0
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className="not-prose w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
39
|
+
<div className="flex flex-wrap items-center gap-3 px-4 py-3">
|
|
40
|
+
<span className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary">
|
|
41
|
+
<TbFileSpreadsheet size={17} />
|
|
42
|
+
</span>
|
|
43
|
+
<div className="min-w-0 flex-1">
|
|
44
|
+
<div className="truncate font-semibold text-gray-900 dark:text-gray-100">
|
|
45
|
+
{planilha.titulo}
|
|
46
|
+
</div>
|
|
47
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
48
|
+
Planilha Excel · {linhas}{' '}
|
|
49
|
+
{linhas === 1 ? 'linha' : 'linhas'}
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
<Button
|
|
53
|
+
size="sm"
|
|
54
|
+
variant="solid"
|
|
55
|
+
icon={<TbDownload />}
|
|
56
|
+
onClick={() => baixarPlanilha(planilha)}
|
|
57
|
+
>
|
|
58
|
+
Baixar planilha
|
|
59
|
+
</Button>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default PlanilhaNaMensagem
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { TbDownload, TbEye, TbEyeOff, TbReportAnalytics } from 'react-icons/tb'
|
|
3
|
+
import Button from '@/components/ui/Button'
|
|
4
|
+
import type { RelatorioHtml } from '../types'
|
|
5
|
+
|
|
6
|
+
type RelatorioNaMensagemProps = {
|
|
7
|
+
relatorio: RelatorioHtml
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Baixa o MESMO texto que a prévia mostra, com o nome que o backend deu. */
|
|
11
|
+
const baixarHtml = ({ html, arquivo }: RelatorioHtml) => {
|
|
12
|
+
const link = document.createElement('a')
|
|
13
|
+
link.href = URL.createObjectURL(
|
|
14
|
+
new Blob([html], { type: 'text/html;charset=utf-8' }),
|
|
15
|
+
)
|
|
16
|
+
link.download = arquivo
|
|
17
|
+
link.click()
|
|
18
|
+
URL.revokeObjectURL(link.href)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Um relatório gerado pelo agente: a prévia dentro do chat e o download.
|
|
23
|
+
*
|
|
24
|
+
* A prévia é um iframe com `sandbox=""` e `srcDoc`: o HTML roda isolado — sem
|
|
25
|
+
* script, sem formulário, sem acesso a esta página — e não precisa de rota de
|
|
26
|
+
* visualização. O download fica fora do iframe e baixa exatamente o documento
|
|
27
|
+
* da prévia (`relatorio.html`).
|
|
28
|
+
*/
|
|
29
|
+
const RelatorioNaMensagem = ({ relatorio }: RelatorioNaMensagemProps) => {
|
|
30
|
+
const [aberto, setAberto] = useState(false)
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="not-prose w-full overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-gray-700 dark:bg-gray-800">
|
|
34
|
+
<div className="flex flex-wrap items-center gap-3 px-4 py-3">
|
|
35
|
+
<span className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary">
|
|
36
|
+
<TbReportAnalytics size={17} />
|
|
37
|
+
</span>
|
|
38
|
+
<div className="min-w-0 flex-1">
|
|
39
|
+
<div className="truncate font-semibold text-gray-900 dark:text-gray-100">
|
|
40
|
+
{relatorio.titulo}
|
|
41
|
+
</div>
|
|
42
|
+
<div className="text-xs text-gray-500 dark:text-gray-400">
|
|
43
|
+
Relatório em HTML · versão {relatorio.versao}
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<div className="flex flex-wrap gap-2">
|
|
47
|
+
<Button
|
|
48
|
+
size="sm"
|
|
49
|
+
variant="solid"
|
|
50
|
+
icon={aberto ? <TbEyeOff /> : <TbEye />}
|
|
51
|
+
aria-expanded={aberto}
|
|
52
|
+
onClick={() => setAberto((anterior) => !anterior)}
|
|
53
|
+
>
|
|
54
|
+
{aberto ? 'Fechar prévia' : 'Visualizar relatório'}
|
|
55
|
+
</Button>
|
|
56
|
+
<Button
|
|
57
|
+
size="sm"
|
|
58
|
+
icon={<TbDownload />}
|
|
59
|
+
onClick={() => baixarHtml(relatorio)}
|
|
60
|
+
>
|
|
61
|
+
Baixar HTML
|
|
62
|
+
</Button>
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
{aberto && (
|
|
66
|
+
<iframe
|
|
67
|
+
title={`Prévia do relatório: ${relatorio.titulo}`}
|
|
68
|
+
sandbox=""
|
|
69
|
+
srcDoc={relatorio.html}
|
|
70
|
+
className="block h-[70vh] max-h-[760px] min-h-[360px] w-full border-t border-gray-200 bg-white dark:border-gray-700"
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default RelatorioNaMensagem
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
rotularExecucao,
|
|
14
14
|
rotularFerramenta,
|
|
15
15
|
} from './toolPresentation'
|
|
16
|
-
import type { ToolCall } from '../types'
|
|
16
|
+
import type { Espera, ToolCall } from '../types'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Uma consulta ou operacao que o agente executou, no meio da conversa.
|
|
@@ -32,18 +32,24 @@ type Estado = {
|
|
|
32
32
|
/**
|
|
33
33
|
* Se o texto do estado acompanha o icone na pilula.
|
|
34
34
|
*
|
|
35
|
-
* So quando o icone sozinho nao basta: "aguardando confirmacao
|
|
36
|
-
* concluida" pedem uma acao ou explicam uma falha. Em execucao o rotulo ja
|
|
35
|
+
* So quando o icone sozinho nao basta: "aguardando" (a confirmacao ou o
|
|
36
|
+
* formato) e "nao concluida" pedem uma acao ou explicam uma falha. Em execucao o rotulo ja
|
|
37
37
|
* esta no gerundio ("Consultando contratos…") e o ✓ de concluida e obvio —
|
|
38
38
|
* escrever isso de novo so engorda a pilula.
|
|
39
39
|
*/
|
|
40
40
|
mostrarTexto?: boolean
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
/** O texto da pilula enquanto o agente espera o usuario responder a pausa. */
|
|
44
|
+
const ESPERAS: Record<Espera, string> = {
|
|
45
|
+
confirmacao: 'Aguardando confirmação',
|
|
46
|
+
formato: 'Aguardando o formato',
|
|
47
|
+
}
|
|
48
|
+
|
|
43
49
|
const estadoDe = (tool: ToolCall): Estado => {
|
|
44
|
-
if (tool.
|
|
50
|
+
if (tool.aguardando) {
|
|
45
51
|
return {
|
|
46
|
-
texto:
|
|
52
|
+
texto: ESPERAS[tool.aguardando],
|
|
47
53
|
Icone: TbClock,
|
|
48
54
|
classe: 'text-amber-600 dark:text-amber-400',
|
|
49
55
|
mostrarTexto: true,
|
|
@@ -79,11 +85,14 @@ const ToolCallChip = ({ tool }: ToolCallChipProps) => {
|
|
|
79
85
|
const [aberto, setAberto] = useState(false)
|
|
80
86
|
const estado = estadoDe(tool)
|
|
81
87
|
const IconeFerramenta = iconeFerramenta(tool.name)
|
|
82
|
-
const emAndamento = tool.running && !tool.
|
|
88
|
+
const emAndamento = tool.running && !tool.aguardando
|
|
83
89
|
const campos = camposVisiveis(tool.args, tool.name)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
90
|
+
// Em andamento, o progresso que o backend manda vai junto do gerúndio:
|
|
91
|
+
// "Gerando relatório · Lendo 1.200 de 4.800 registros…".
|
|
92
|
+
const execucao = tool.progresso
|
|
93
|
+
? `${rotularExecucao(tool.name)} · ${tool.progresso}`
|
|
94
|
+
: `${rotularExecucao(tool.name)}…`
|
|
95
|
+
const rotulo = emAndamento ? execucao : rotularFerramenta(tool.name)
|
|
87
96
|
|
|
88
97
|
return (
|
|
89
98
|
// not-prose: o balao do agente e `prose`, que aplicaria margens de
|
|
@@ -2,12 +2,15 @@ import { formatQuantity } from '@base/utils/functions/stringUtils'
|
|
|
2
2
|
import {
|
|
3
3
|
TbBriefcase,
|
|
4
4
|
TbBuildingPlus,
|
|
5
|
+
TbCalculator,
|
|
5
6
|
TbCalendarEvent,
|
|
6
7
|
TbFilePlus,
|
|
7
8
|
TbForms,
|
|
8
9
|
TbListSearch,
|
|
9
10
|
TbPackage,
|
|
10
11
|
TbPackages,
|
|
12
|
+
TbPalette,
|
|
13
|
+
TbReportAnalytics,
|
|
11
14
|
TbSearch,
|
|
12
15
|
TbTool,
|
|
13
16
|
TbUserSearch,
|
|
@@ -88,6 +91,23 @@ const FERRAMENTAS: Record<string, Ferramenta> = {
|
|
|
88
91
|
executando: 'Consultando produto',
|
|
89
92
|
icone: TbPackage,
|
|
90
93
|
},
|
|
94
|
+
// Um relatorio em HTML ou uma planilha Excel: o mesmo workflow no backend.
|
|
95
|
+
gerar_relatorio: {
|
|
96
|
+
rotulo: 'Geração de relatório',
|
|
97
|
+
executando: 'Gerando relatório',
|
|
98
|
+
icone: TbReportAnalytics,
|
|
99
|
+
},
|
|
100
|
+
// A estatistica no chat: o mesmo workflow do relatorio, sem arquivo.
|
|
101
|
+
calcular_estatisticas: {
|
|
102
|
+
rotulo: 'Cálculo de estatísticas',
|
|
103
|
+
executando: 'Calculando estatísticas',
|
|
104
|
+
icone: TbCalculator,
|
|
105
|
+
},
|
|
106
|
+
personalizar_relatorio: {
|
|
107
|
+
rotulo: 'Personalização de relatório',
|
|
108
|
+
executando: 'Personalizando relatório',
|
|
109
|
+
icone: TbPalette,
|
|
110
|
+
},
|
|
91
111
|
// Nao executa nada no ERP: e o sinal de que faltam campos. Mas o agente a
|
|
92
112
|
// pede como qualquer outra, entao um chip aparece junto do formulario.
|
|
93
113
|
solicitar_dados: {
|