diff --git a/client/src/components/MiroFlowControl.tsx b/client/src/components/MiroFlowControl.tsx new file mode 100644 index 0000000..871ef15 --- /dev/null +++ b/client/src/components/MiroFlowControl.tsx @@ -0,0 +1,217 @@ +import { useState } from "react"; +import { useMutation } from "@tanstack/react-query"; +import { apiRequest } from "@/lib/queryClient"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Textarea } from "@/components/ui/textarea"; +import { Badge } from "@/components/ui/badge"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; +import { Brain, Loader2 } from "lucide-react"; + +interface AnalyzeRequest { + agent: "statistician" | "fiscal_auditor" | "researcher"; + task: string; + context?: Record; +} + +interface AnalyzeResponse { + agent: string; + model: string; + result: string; + execution_id: string; + duration_ms: number; +} + +const AGENTS = [ + { + value: "statistician", + label: "Statistician", + model: "deepseek-r1:14b", + placeholder: + "Ex: Analise a distribuição de vendas por região no último trimestre", + }, + { + value: "fiscal_auditor", + label: "Fiscal Auditor", + model: "deepseek-r1:14b", + placeholder: + "Ex: Verifique inconsistências nos registros NFe do CNPJ 12.345.678/0001-90", + }, + { + value: "researcher", + label: "Researcher", + model: "llama3.1:8b", + placeholder: + "Ex: Quais fornecedores têm maior correlação com atrasos de entrega?", + }, +] as const; + +interface MiroFlowControlProps { + currentDashboardData?: Record; +} + +export function MiroFlowControl({ + currentDashboardData, +}: MiroFlowControlProps) { + const [enabled, setEnabled] = useState(false); + const [selectedAgent, setSelectedAgent] = useState< + "statistician" | "fiscal_auditor" | "researcher" + >("statistician"); + const [task, setTask] = useState(""); + + const mutation = useMutation({ + mutationFn: async (request: AnalyzeRequest) => { + const response = await apiRequest("POST", "/api/miroflow/analyze", request); + return response.json() as Promise; + }, + }); + + const handleAnalyze = () => { + if (!task.trim()) { + return; + } + + mutation.mutate({ + agent: selectedAgent, + task, + context: currentDashboardData, + }); + }; + + const currentAgentConfig = AGENTS.find((a) => a.value === selectedAgent); + + return ( +
+ + +
+
+ + Modo Científico +
+ +
+
+ + {enabled && ( + + {/* Agent Selection */} +
+ + +
+ + {/* Task Input */} +
+ +