mirror of
https://github.com/fosrl/pangolin.git
synced 2026-08-14 08:19:51 +02:00
set default provider name
This commit is contained in:
@@ -21,7 +21,10 @@ import {
|
|||||||
import HeaderTitle from "@app/components/SettingsSectionTitle";
|
import HeaderTitle from "@app/components/SettingsSectionTitle";
|
||||||
import { AiProviderAuthTypeSelect } from "@app/components/AiProviderAuthTypeSelect";
|
import { AiProviderAuthTypeSelect } from "@app/components/AiProviderAuthTypeSelect";
|
||||||
import { AiProviderCapabilitiesSelect } from "@app/components/AiProviderCapabilitiesSelect";
|
import { AiProviderCapabilitiesSelect } from "@app/components/AiProviderCapabilitiesSelect";
|
||||||
import { AiProviderTypeSelect } from "@app/components/AiProviderTypeSelect";
|
import {
|
||||||
|
AiProviderTypeSelect,
|
||||||
|
aiProviderTypeLabelMap
|
||||||
|
} from "@app/components/AiProviderTypeSelect";
|
||||||
import { HeadersInput } from "@app/components/HeadersInput";
|
import { HeadersInput } from "@app/components/HeadersInput";
|
||||||
import { StrategySelect } from "@app/components/StrategySelect";
|
import { StrategySelect } from "@app/components/StrategySelect";
|
||||||
import { SwitchInput } from "@app/components/SwitchInput";
|
import { SwitchInput } from "@app/components/SwitchInput";
|
||||||
@@ -74,7 +77,7 @@ export default function CreateAiProviderPage() {
|
|||||||
const form = useForm<AiProviderFormValues>({
|
const form = useForm<AiProviderFormValues>({
|
||||||
resolver: zodResolver(formSchema),
|
resolver: zodResolver(formSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
name: "",
|
name: t(aiProviderTypeLabelMap.openai),
|
||||||
type: "openai",
|
type: "openai",
|
||||||
upstreamUrl: emptyUpstreamForType("openai"),
|
upstreamUrl: emptyUpstreamForType("openai"),
|
||||||
apiKey: "",
|
apiKey: "",
|
||||||
@@ -232,27 +235,6 @@ export default function CreateAiProviderPage() {
|
|||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<SettingsSectionForm variant="half">
|
<SettingsSectionForm variant="half">
|
||||||
<SettingsFormGrid>
|
<SettingsFormGrid>
|
||||||
<SettingsFormCell span="half">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="name"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel>
|
|
||||||
{t("name")}
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
autoComplete="off"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</SettingsFormCell>
|
|
||||||
|
|
||||||
<SettingsFormCell span="half">
|
<SettingsFormCell span="half">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
@@ -268,6 +250,8 @@ export default function CreateAiProviderPage() {
|
|||||||
onChange={(
|
onChange={(
|
||||||
value
|
value
|
||||||
) => {
|
) => {
|
||||||
|
const previousType =
|
||||||
|
field.value;
|
||||||
field.onChange(
|
field.onChange(
|
||||||
value
|
value
|
||||||
);
|
);
|
||||||
@@ -293,6 +277,30 @@ export default function CreateAiProviderPage() {
|
|||||||
value !==
|
value !==
|
||||||
"custom"
|
"custom"
|
||||||
) {
|
) {
|
||||||
|
const currentName =
|
||||||
|
form.getValues(
|
||||||
|
"name"
|
||||||
|
);
|
||||||
|
const previousLabel =
|
||||||
|
t(
|
||||||
|
aiProviderTypeLabelMap[
|
||||||
|
previousType
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
!currentName.trim() ||
|
||||||
|
currentName ===
|
||||||
|
previousLabel
|
||||||
|
) {
|
||||||
|
form.setValue(
|
||||||
|
"name",
|
||||||
|
t(
|
||||||
|
aiProviderTypeLabelMap[
|
||||||
|
value
|
||||||
|
]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
form.setValue(
|
form.setValue(
|
||||||
"routingMode",
|
"routingMode",
|
||||||
"url"
|
"url"
|
||||||
@@ -309,6 +317,27 @@ export default function CreateAiProviderPage() {
|
|||||||
/>
|
/>
|
||||||
</SettingsFormCell>
|
</SettingsFormCell>
|
||||||
|
|
||||||
|
<SettingsFormCell span="half">
|
||||||
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="name"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>
|
||||||
|
{t("name")}
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
autoComplete="off"
|
||||||
|
{...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</SettingsFormCell>
|
||||||
|
|
||||||
<SettingsFormCell span="full">
|
<SettingsFormCell span="full">
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import { CheckIcon, ChevronsUpDown } from "lucide-react";
|
|||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
|
|
||||||
const typeLabelMap = {
|
export const aiProviderTypeLabelMap = {
|
||||||
openai: "aiProviderTypeOpenai",
|
openai: "aiProviderTypeOpenai",
|
||||||
anthropic: "aiProviderTypeAnthropic",
|
anthropic: "aiProviderTypeAnthropic",
|
||||||
googleGemini: "aiProviderTypeGoogleGemini",
|
googleGemini: "aiProviderTypeGoogleGemini",
|
||||||
@@ -65,7 +65,7 @@ export function AiProviderTypeSelect({
|
|||||||
() =>
|
() =>
|
||||||
aiProviderTypeValues.map((type) => ({
|
aiProviderTypeValues.map((type) => ({
|
||||||
type,
|
type,
|
||||||
title: t(typeLabelMap[type]),
|
title: t(aiProviderTypeLabelMap[type]),
|
||||||
description: t(typeDescriptionMap[type])
|
description: t(typeDescriptionMap[type])
|
||||||
})),
|
})),
|
||||||
[t]
|
[t]
|
||||||
|
|||||||
Reference in New Issue
Block a user