Files
TaxHacker_s23/app/(auth)/self-hosted/page.tsx
Dmitrii Anfimov dee915ffd6 feat: more llm provider options (google, mistral) (#28)
* feat: add google provider

* fix: default for google model

* feat: multiple providers

* fix: defaults from env for login form

* fix: add mistral to env files

* chore: delete unused code

* chore: revert database url to original

* fix: render default value for api key from env on server

* fix: type errors during compilation

---------

Co-authored-by: Vasily Zubarev <me@vas3k.ru>
2025-07-22 21:49:54 +02:00

58 lines
2.4 KiB
TypeScript

import { Card, CardDescription, CardTitle } from "@/components/ui/card"
import { ColoredText } from "@/components/ui/colored-text"
import config from "@/lib/config"
import { getSelfHostedUser } from "@/models/users"
import { ShieldAlert } from "lucide-react"
import Image from "next/image"
import { redirect } from "next/navigation"
import { PROVIDERS } from "@/lib/llm-providers"
import SelfHostedSetupFormClient from "./setup-form-client"
export default async function SelfHostedWelcomePage() {
if (!config.selfHosted.isEnabled) {
return (
<Card className="w-full max-w-xl mx-auto p-8 flex flex-col items-center justify-center gap-6">
<CardTitle className="text-2xl font-bold flex items-center gap-2">
<ShieldAlert className="w-6 h-6" />
<span>Self-Hosted Mode is not enabled</span>
</CardTitle>
<CardDescription className="text-center text-lg flex flex-col gap-2">
<p>
To use TaxHacker in self-hosted mode, please set <code className="font-bold">SELF_HOSTED_MODE=true</code> in
your environment.
</p>
<p>In self-hosted mode you can use your own ChatGPT API key and store your data on your own server.</p>
</CardDescription>
</Card>
)
}
const user = await getSelfHostedUser()
if (user) {
redirect(config.selfHosted.redirectUrl)
}
// Собираем дефолтные ключи для всех провайдеров
const defaultProvider = PROVIDERS[0].key
const defaultApiKeys: Record<string, string> = {
openai: config.ai.openaiApiKey ?? "",
google: config.ai.googleApiKey ?? "",
mistral: config.ai.mistralApiKey ?? "",
}
return (
<Card className="w-full max-w-xl mx-auto p-8 flex flex-col items-center justify-center gap-4">
<Image src="/logo/512.png" alt="Logo" width={144} height={144} className="w-36 h-36" />
<CardTitle className="text-3xl font-bold ">
<ColoredText>TaxHacker: Self-Hosted Edition</ColoredText>
</CardTitle>
<CardDescription className="flex flex-col gap-4 text-center text-lg">
<p>Welcome to your own instance of TaxHacker. Let&apos;s set up a couple of settings to get started.</p>
<SelfHostedSetupFormClient defaultProvider={defaultProvider} defaultApiKeys={defaultApiKeys} />
</CardDescription>
</Card>
)
}
export const dynamic = "force-dynamic"