feat(insights): adiciona suporte ao MiniMax

This commit is contained in:
Felipe Coutinho
2026-05-28 10:58:52 -03:00
parent 37247e319c
commit 5319d8a5a6
5 changed files with 60 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import { google } from "@ai-sdk/google";
import { openai } from "@ai-sdk/openai";
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
import { generateObject } from "ai";
import { minimax } from "vercel-minimax-ai-provider";
import { getUser } from "@/shared/lib/auth/server";
import {
type InsightsResponse,
@@ -65,6 +66,8 @@ export async function generateInsightsAction(
model = anthropic(modelId);
} else if (selectedModel?.provider === "google") {
model = google(modelId);
} else if (selectedModel?.provider === "minimax") {
model = minimax(modelId);
} else {
return {
success: false,

View File

@@ -146,12 +146,12 @@ export function InsightsPage({ period, onAnalyze }: InsightsPageProps) {
return (
<div className="flex flex-col gap-6">
{/* Privacy Warning */}
<Alert className="border-none bg-primary/15">
<Alert className="border-none bg-primary/10">
<RiAlertLine className="size-4" color="red" />
<AlertDescription className="text-sm text-card-foreground">
<strong>Aviso de privacidade:</strong> Ao gerar insights, seus dados
financeiros serão enviados para o provedor de IA selecionado
(Anthropic, OpenAI, Google ou OpenRouter) para processamento.
(Anthropic, OpenAI, Google, MiniMax ou OpenRouter) para processamento.
Certifique-se de que você confia no provedor escolhido antes de
prosseguir.
</AlertDescription>

View File

@@ -41,6 +41,9 @@ const PROVIDER_ICON_PATHS: Record<
google: {
light: "/providers/gemini.svg",
},
minimax: {
light: "/providers/minimax.svg",
},
openrouter: {
light: "/providers/openrouter_light.svg",
dark: "/providers/openrouter_dark.svg",
@@ -61,7 +64,7 @@ export function ModelSelector({
// Sincronizar customModel quando value mudar (importante para pré-carregamento)
useEffect(() => {
// Se o value tem "/" é um modelo OpenRouter customizado
if (value.includes("/")) {
if (value.includes("/") || selectedProvider === "openrouter") {
setCustomModel(value);
setSelectedProvider("openrouter");
} else {
@@ -69,7 +72,7 @@ export function ModelSelector({
// Limpar selectedProvider para deixar o useMemo detectar automaticamente
setSelectedProvider(null);
}
}, [value]);
}, [value, selectedProvider]);
// Determinar provider atual baseado no modelo selecionado ou provider manual
const currentProvider = useMemo(() => {
@@ -97,6 +100,7 @@ export function ModelSelector({
openai: [],
anthropic: [],
google: [],
minimax: [],
openrouter: [],
};

View File

@@ -1,7 +1,12 @@
/**
* Tipos de providers disponíveis
*/
export type AIProvider = "openai" | "anthropic" | "google" | "openrouter";
export type AIProvider =
| "openai"
| "anthropic"
| "google"
| "minimax"
| "openrouter";
/**
* Metadados dos providers
@@ -22,6 +27,11 @@ export const PROVIDERS = {
name: "Gemini",
icon: "RiGoogleLine",
},
minimax: {
id: "minimax" as const,
name: "MiniMax",
icon: "RiRobot2Line",
},
openrouter: {
id: "openrouter" as const,
name: "OpenRouter",
@@ -73,6 +83,43 @@ export const AVAILABLE_MODELS = [
name: "Gemini 3.1 Flash Lite",
provider: "google" as const,
},
// MiniMax
{
id: "MiniMax-M2.7",
name: "MiniMax M2.7",
provider: "minimax" as const,
},
{
id: "MiniMax-M2.7-highspeed",
name: "MiniMax M2.7 Highspeed",
provider: "minimax" as const,
},
{
id: "MiniMax-M2.5",
name: "MiniMax M2.5",
provider: "minimax" as const,
},
{
id: "MiniMax-M2.5-highspeed",
name: "MiniMax M2.5 Highspeed",
provider: "minimax" as const,
},
{
id: "MiniMax-M2.1",
name: "MiniMax M2.1",
provider: "minimax" as const,
},
{
id: "MiniMax-M2.1-highspeed",
name: "MiniMax M2.1 Highspeed",
provider: "minimax" as const,
},
{
id: "MiniMax-M2",
name: "MiniMax M2",
provider: "minimax" as const,
},
] as const;
export const DEFAULT_MODEL = "gpt-5.5";