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