feat(provider): optimize provider and model configuration management (#377)

* feat(provider): optimize provider and model configuration management

* style(provider): use default tabs variant in provider settings dialog

* style(provider): make tabs list full width

* feat(provider): make model card row clickable and remove pencil edit icon

* feat(settings): persist active settings tab in url hash

* feat(agent): add search box and alphabetical sorting for provider and model selectors

* refactor(providers): remove frontend pagination and display all models in scrollable list

* fix(providers): address code review findings for model editing, i18n, and api protocol propagation
This commit is contained in:
Yiling-J
2026-09-03 15:16:16 +08:00
committed by GitHub
parent e58dfaa71a
commit c3ef769f51
63 changed files with 3249 additions and 513 deletions
@@ -12,6 +12,11 @@ test('owner manages resource quotas in settings and resets usage from the dashbo
// 2. Click the Quotas sidebar tab
await page.getByRole('button', { name: /Quotas|配额/i }).click()
// Verify URL contains #quotas and remains after reload
expect(page.url()).toContain('#quotas')
await page.reload()
expect(page.url()).toContain('#quotas')
// 3. Verify Quotas settings card is displayed with empty state
await expect(page.getByRole('heading', { name: /^(Resource Quotas|资源配额)$/i })).toBeVisible()
await expect(page.getByText(/No resource quotas configured|暂未配置资源配额/i)).toBeVisible()
+28
View File
@@ -1257,3 +1257,31 @@ describe('createAgentSession enabled skill filtering', () => {
}
})
})
describe('getModelFromDb', () => {
it('should prioritize provider active api protocol over model config api', () => {
const providers: DbProviderInfo[] = [
{
name: 'custom-provider',
config: { api: 'anthropic-messages', apiKey: 'KEY' },
models: [
{
modelId: 'my-model',
name: 'My Model',
config: {
api: 'openai-responses', // stale model config
reasoning: false,
input: ['text'],
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
contextWindow: 128000,
maxTokens: 4096,
},
},
],
},
]
const model = getModelFromDb(providers, 'custom-provider', 'my-model')
expect(model.api).toBe('anthropic-messages')
})
})
+1 -1
View File
@@ -70,10 +70,10 @@ export function getModelFromDb(providers: DbProviderInfo[], providerName: string
if (dbProvider.config.baseUrl) {
m.baseUrl = dbProvider.config.baseUrl
}
Object.assign(m, dbModel.config)
if (dbProvider.config.api) {
m.api = dbProvider.config.api
}
Object.assign(m, dbModel.config)
if (dbModel.name) {
m.name = dbModel.name
}
+107 -2
View File
@@ -163,13 +163,13 @@ describe('provider api', () => {
const res = await app.request('/providers/p1', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ config, models }),
body: JSON.stringify({ name: 'new-name', config, models }),
})
expect(res.status).toBe(200)
const data = await res.json()
expect(data.config.baseUrl).toBe('https://new-url.com')
expect(providerService.update).toHaveBeenCalledWith('t1', 'p1', config, models)
expect(providerService.update).toHaveBeenCalledWith('t1', 'p1', config, models, 'new-name')
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: expect.anything(),
permission: Permission.Admin,
@@ -184,6 +184,111 @@ describe('provider api', () => {
})
})
it('POST /providers/:id/models creates a model', async () => {
vi.mocked(providerService.getById).mockResolvedValue({
id: 'p1',
teamId: 't1',
} as unknown as Awaited<ReturnType<typeof providerService.getById>>)
const modelData = {
modelId: 'm1',
name: 'Model 1',
config: {
reasoning: true,
input: ['text' as const],
contextWindow: 128000,
maxTokens: 4096,
cost: { input: 1, output: 2, cacheRead: 0, cacheWrite: 0 },
},
}
vi.mocked(providerService.createModel).mockResolvedValue({
id: 'm-db-1',
providerId: 'p1',
modelId: 'm1',
name: 'Model 1',
config: modelData.config,
createdAt: new Date(),
updatedAt: new Date(),
})
const res = await app.request('/providers/p1/models', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(modelData),
})
expect(res.status).toBe(201)
const data = await res.json()
expect(data.id).toBe('m-db-1')
expect(providerService.createModel).toHaveBeenCalledWith('t1', 'p1', modelData)
expect(authzService.hasPermission).toHaveBeenCalledWith({
user: expect.anything(),
permission: Permission.Admin,
type: ResourceType.Provider,
id: 'p1',
})
expect(auditLogService.logAction).toHaveBeenCalledWith({
action: 'provider_update',
teamId: 't1',
userId: 'user1',
itemId: 'p1',
})
})
it('PUT /providers/:id/models/:modelDbId updates a model', async () => {
vi.mocked(providerService.getById).mockResolvedValue({
id: 'p1',
teamId: 't1',
} as unknown as Awaited<ReturnType<typeof providerService.getById>>)
const updateData = {
name: 'Updated Model',
}
vi.mocked(providerService.updateModel).mockResolvedValue({
id: 'm-db-1',
providerId: 'p1',
modelId: 'm1',
name: 'Updated Model',
config: {
reasoning: false,
input: ['text'],
contextWindow: 128000,
maxTokens: 4096,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
},
createdAt: new Date(),
updatedAt: new Date(),
})
const res = await app.request('/providers/p1/models/m-db-1', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(updateData),
})
expect(res.status).toBe(200)
const data = await res.json()
expect(data.name).toBe('Updated Model')
expect(providerService.updateModel).toHaveBeenCalledWith('t1', 'p1', 'm-db-1', updateData)
})
it('DELETE /providers/:id/models/:modelDbId deletes a model', async () => {
vi.mocked(providerService.getById).mockResolvedValue({
id: 'p1',
teamId: 't1',
} as unknown as Awaited<ReturnType<typeof providerService.getById>>)
vi.mocked(providerService.deleteModel).mockResolvedValue({
id: 'm-db-1',
} as unknown as Awaited<ReturnType<typeof providerService.deleteModel>>)
const res = await app.request('/providers/p1/models/m-db-1', {
method: 'DELETE',
})
expect(res.status).toBe(200)
const data = await res.json()
expect(data.success).toBe(true)
expect(providerService.deleteModel).toHaveBeenCalledWith('t1', 'p1', 'm-db-1')
})
it('DELETE /providers/:id deletes provider', async () => {
vi.mocked(providerService.getById).mockResolvedValue({
id: 'p1',
+89 -3
View File
@@ -2,7 +2,13 @@ import { zValidator } from '@hono/zod-validator'
import { Hono } from 'hono'
import { authzService, Permission, ResourceType } from '@shumai/core/src/authz/authz'
import { providerService } from '@shumai/core/src/provider/provider'
import { createProviderRequestSchema, updateProviderRequestSchema, AuditAction } from '@shumai/dtos'
import {
createModelRequestSchema,
createProviderRequestSchema,
updateModelRequestSchema,
updateProviderRequestSchema,
AuditAction,
} from '@shumai/dtos'
import type { Prisma } from '@shumai/db'
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
@@ -67,7 +73,7 @@ const route = new Hono<{ Variables: { user: User } }>()
.put('/providers/:id', zValidator('json', updateProviderRequestSchema), async (c) => {
const id = c.req.param('id')
const user = c.get('user')
const { config, models } = c.req.valid('json')
const { name, config, models } = c.req.valid('json')
await authzService.hasPermission({
user,
@@ -79,7 +85,7 @@ const route = new Hono<{ Variables: { user: User } }>()
const providerBefore = await providerService.getById(id)
if (!providerBefore) throw new Error('Provider not found')
const provider = await providerService.update(providerBefore.teamId, id, config, models)
const provider = await providerService.update(providerBefore.teamId, id, config, models, name)
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId: providerBefore.teamId,
@@ -89,6 +95,86 @@ const route = new Hono<{ Variables: { user: User } }>()
return c.json(provider)
})
.post('/providers/:id/models', zValidator('json', createModelRequestSchema), async (c) => {
const id = c.req.param('id')
const user = c.get('user')
const data = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Provider,
id,
})
const provider = await providerService.getById(id)
if (!provider) throw new Error('Provider not found')
const model = await providerService.createModel(provider.teamId, id, data)
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId: provider.teamId,
userId: user?.id,
itemId: id,
})
return c.json(model, 201)
})
.put(
'/providers/:id/models/:modelDbId',
zValidator('json', updateModelRequestSchema),
async (c) => {
const id = c.req.param('id')
const modelDbId = c.req.param('modelDbId')
const user = c.get('user')
const data = c.req.valid('json')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Provider,
id,
})
const provider = await providerService.getById(id)
if (!provider) throw new Error('Provider not found')
const model = await providerService.updateModel(provider.teamId, id, modelDbId, data)
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId: provider.teamId,
userId: user?.id,
itemId: id,
})
return c.json(model)
},
)
.delete('/providers/:id/models/:modelDbId', async (c) => {
const id = c.req.param('id')
const modelDbId = c.req.param('modelDbId')
const user = c.get('user')
await authzService.hasPermission({
user,
permission: Permission.Admin,
type: ResourceType.Provider,
id,
})
const providerBefore = await providerService.getById(id)
if (!providerBefore) throw new Error('Provider not found')
await providerService.deleteModel(providerBefore.teamId, id, modelDbId)
await auditLogService.logAction({
action: AuditAction.provider_update,
teamId: providerBefore.teamId,
userId: user?.id,
itemId: id,
})
return c.json({ success: true })
})
.delete('/providers/:id', async (c) => {
const id = c.req.param('id')
const user = c.get('user')
+155
View File
@@ -191,4 +191,159 @@ describe('ProviderService', () => {
const updatedAgent = updatedAgents.find((a) => a.id === agent!.id)
expect(updatedAgent?.modelId).toBe(initialModelId)
})
it('should support granular model CRUD operations and order by id desc', async () => {
const team = await teamService.ensureDefaultTeam()
const provider = await providerService.create(
team.id,
'test-granular-provider',
{ api: 'openai-completions', apiKey: 'key1' },
[],
)
// 1. createModel
const createdModel1 = await providerService.createModel(team.id, provider.id, {
modelId: 'custom-model-1',
name: 'Custom Model 1',
config: {
reasoning: true,
input: ['text', 'image'],
contextWindow: 200000,
maxTokens: 8192,
cost: { input: 1.5, output: 5, cacheRead: 0.1, cacheWrite: 0.5 },
},
})
expect(createdModel1.modelId).toBe('custom-model-1')
expect(createdModel1.name).toBe('Custom Model 1')
expect((createdModel1.config as { reasoning: boolean }).reasoning).toBe(true)
// Check duplicate modelId error
await expect(
providerService.createModel(team.id, provider.id, {
modelId: 'custom-model-1',
name: 'Duplicate',
config: {
reasoning: false,
input: ['text'],
contextWindow: 100000,
maxTokens: 4000,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
},
}),
).rejects.toThrow('already exists')
// 2. createModel 2
const createdModel2 = await providerService.createModel(team.id, provider.id, {
modelId: 'custom-model-2',
name: 'Custom Model 2',
config: {
reasoning: false,
input: ['text'],
contextWindow: 100000,
maxTokens: 4000,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
},
})
// 3. listModelsByProvider should return newest first (id desc)
const models = await providerService.listModelsByProvider(team.id, provider.id)
expect(models).toHaveLength(2)
expect(models[0].id).toBe(createdModel2.id)
expect(models[1].id).toBe(createdModel1.id)
// 4. updateModel
const updatedModel = await providerService.updateModel(team.id, provider.id, createdModel1.id, {
name: 'Updated Model 1',
config: {
reasoning: false,
input: ['text'],
contextWindow: 64000,
maxTokens: 2048,
cost: { input: 2, output: 8, cacheRead: 0.2, cacheWrite: 0.8 },
},
})
expect(updatedModel.name).toBe('Updated Model 1')
expect((updatedModel.config as { reasoning: boolean }).reasoning).toBe(false)
expect((updatedModel.config as { cost: { input: number } }).cost.input).toBe(2)
// 5. update provider config and name without touching models
const updatedProvider = await providerService.update(
team.id,
provider.id,
{ api: 'openai-completions', apiKey: 'new-key' },
undefined,
'renamed-provider',
)
expect(updatedProvider.name).toBe('renamed-provider')
expect(updatedProvider.config.apiKey).toBe('new-key')
const modelsAfterProviderUpdate = await providerService.listModelsByProvider(
team.id,
provider.id,
)
expect(modelsAfterProviderUpdate).toHaveLength(2)
// 6. deleteModel
await providerService.deleteModel(team.id, provider.id, createdModel2.id)
const modelsAfterDelete = await providerService.listModelsByProvider(team.id, provider.id)
expect(modelsAfterDelete).toHaveLength(1)
expect(modelsAfterDelete[0].id).toBe(createdModel1.id)
})
it('should propagate provider API protocol change to existing models', async () => {
const team = await teamService.ensureDefaultTeam()
// 1. Create provider with openai-responses
const provider = await providerService.create(
team.id,
'test-protocol-provider',
{ api: 'openai-responses', apiKey: 'key-1' },
[
{
modelId: 'm1',
name: 'Model 1',
config: {
api: 'openai-responses',
reasoning: false,
input: ['text'],
contextWindow: 128000,
maxTokens: 4096,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
},
},
{
modelId: 'm2',
name: 'Model 2',
config: {
api: 'openai-responses',
reasoning: true,
input: ['text'],
contextWindow: 64000,
maxTokens: 2048,
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
},
},
],
)
const initialModels = await providerService.listModelsByProvider(team.id, provider.id)
expect(initialModels).toHaveLength(2)
expect((initialModels[0].config as { api: string }).api).toBe('openai-responses')
expect((initialModels[1].config as { api: string }).api).toBe('openai-responses')
// 2. Update provider global API protocol to anthropic-messages without passing models
const updatedProvider = await providerService.update(
team.id,
provider.id,
{ api: 'anthropic-messages', apiKey: 'key-2' },
undefined,
'test-protocol-provider',
)
expect(updatedProvider.config.api).toBe('anthropic-messages')
// 3. Verify that all existing models under this provider were updated
const modelsAfterUpdate = await providerService.listModelsByProvider(team.id, provider.id)
expect(modelsAfterUpdate).toHaveLength(2)
expect((modelsAfterUpdate[0].config as { api: string }).api).toBe('anthropic-messages')
expect((modelsAfterUpdate[1].config as { api: string }).api).toBe('anthropic-messages')
})
})
+160 -38
View File
@@ -1,5 +1,10 @@
import { prisma } from '@shumai/db'
import { ProviderConfigSerializable, providerModelSchema } from '@shumai/dtos'
import {
CreateModelRequest,
ProviderConfigSerializable,
providerModelSchema,
UpdateModelRequest,
} from '@shumai/dtos'
import { getBuiltinProvidersMap } from '@shumai/core/src/provider/builtin'
import { z } from 'zod'
@@ -74,7 +79,7 @@ export class ProviderService {
providerId,
provider: { teamId },
},
orderBy: { id: 'asc' },
orderBy: { id: 'desc' },
})
}
@@ -82,7 +87,7 @@ export class ProviderService {
teamId: string,
name: string,
config: ProviderConfigSerializable,
models: ProviderModel[],
models: ProviderModel[] = [],
) {
return this.prismaClient.provider.create({
data: {
@@ -105,60 +110,177 @@ export class ProviderService {
teamId: string,
id: string,
config: ProviderConfigSerializable,
models: ProviderModel[],
models?: ProviderModel[],
name?: string,
) {
return this.prismaClient.$transaction(async (tx) => {
const existingModels = await tx.model.findMany({
where: { providerId: id },
})
const existingByModelId = new Map(existingModels.map((m) => [m.modelId, m]))
const incomingModelIds = new Set(models.map((m) => m.modelId))
// Delete models that are no longer in the incoming list
const modelsToDelete = existingModels.filter((m) => !incomingModelIds.has(m.modelId))
if (modelsToDelete.length > 0) {
await tx.model.deleteMany({
where: {
id: { in: modelsToDelete.map((m) => m.id) },
},
if (models !== undefined) {
const existingModels = await tx.model.findMany({
where: { providerId: id },
})
}
// Update existing models or create new ones
for (const m of models) {
const existing = existingByModelId.get(m.modelId)
if (existing) {
await tx.model.update({
where: { id: existing.id },
data: {
name: m.name,
config: m.config,
},
})
} else {
await tx.model.create({
data: {
providerId: id,
modelId: m.modelId,
name: m.name,
config: m.config,
const existingByModelId = new Map(existingModels.map((m) => [m.modelId, m]))
const incomingModelIds = new Set(models.map((m) => m.modelId))
// Delete models that are no longer in the incoming list
const modelsToDelete = existingModels.filter((m) => !incomingModelIds.has(m.modelId))
if (modelsToDelete.length > 0) {
await tx.model.deleteMany({
where: {
id: { in: modelsToDelete.map((m) => m.id) },
},
})
}
// Update existing models or create new ones
for (const m of models) {
const existing = existingByModelId.get(m.modelId)
const modelConfig = {
...m.config,
api: m.config?.api || config.api,
}
if (existing) {
await tx.model.update({
where: { id: existing.id },
data: {
name: m.name,
config: modelConfig,
},
})
} else {
await tx.model.create({
data: {
providerId: id,
modelId: m.modelId,
name: m.name,
config: modelConfig,
},
})
}
}
} else if (config.api) {
// Propagate provider API protocol change to all existing models
const existingModels = await tx.model.findMany({
where: { providerId: id },
})
for (const m of existingModels) {
const currentConfig = m.config
if (currentConfig.api !== config.api) {
await tx.model.update({
where: { id: m.id },
data: {
config: {
...currentConfig,
api: config.api,
},
},
})
}
}
}
// Update provider config
// Update provider config and optional name
return tx.provider.update({
where: { id, teamId },
data: {
config,
...(name ? { name } : {}),
},
include: { models: true },
})
})
}
async createModel(teamId: string, providerId: string, data: CreateModelRequest) {
const provider = await this.prismaClient.provider.findUnique({
where: { id: providerId, teamId },
})
if (!provider) {
throw new Error('Provider not found')
}
const existing = await this.prismaClient.model.findFirst({
where: {
providerId,
modelId: data.modelId,
},
})
if (existing) {
throw new Error(`Model with id "${data.modelId}" already exists for this provider`)
}
return this.prismaClient.model.create({
data: {
providerId,
modelId: data.modelId,
name: data.name ?? '',
config: data.config,
},
})
}
async updateModel(
teamId: string,
providerId: string,
modelDbId: string,
data: UpdateModelRequest,
) {
const provider = await this.prismaClient.provider.findUnique({
where: { id: providerId, teamId },
})
if (!provider) {
throw new Error('Provider not found')
}
const model = await this.prismaClient.model.findFirst({
where: { id: modelDbId, providerId },
})
if (!model) {
throw new Error('Model not found')
}
if (data.modelId && data.modelId !== model.modelId) {
const existingWithNewId = await this.prismaClient.model.findFirst({
where: {
providerId,
modelId: data.modelId,
},
})
if (existingWithNewId) {
throw new Error(`Model with id "${data.modelId}" already exists for this provider`)
}
}
return this.prismaClient.model.update({
where: { id: modelDbId },
data: {
...(data.modelId ? { modelId: data.modelId } : {}),
...(data.name !== undefined ? { name: data.name } : {}),
...(data.config ? { config: data.config } : {}),
},
})
}
async deleteModel(teamId: string, providerId: string, modelDbId: string) {
const provider = await this.prismaClient.provider.findUnique({
where: { id: providerId, teamId },
})
if (!provider) {
throw new Error('Provider not found')
}
const model = await this.prismaClient.model.findFirst({
where: { id: modelDbId, providerId },
})
if (!model) {
throw new Error('Model not found')
}
return this.prismaClient.model.delete({
where: { id: modelDbId },
})
}
async delete(teamId: string, id: string) {
const provider = await this.prismaClient.provider.findUnique({
where: { id, teamId },
+23 -2
View File
@@ -49,14 +49,35 @@ export type ProviderConfigSerializable = z.infer<typeof providerConfigSchema>
export const createProviderRequestSchema = z.object({
name: z.string().min(1, 'Provider name is required'),
config: providerConfigSchema,
models: z.array(providerModelSchema).min(1, 'At least one model is required'),
models: z.array(providerModelSchema).default([]),
})
export type CreateProviderRequest = z.infer<typeof createProviderRequestSchema>
export const updateProviderRequestSchema = z.object({
name: z.string().min(1, 'Provider name is required').optional(),
config: providerConfigSchema,
models: z.array(providerModelSchema).min(1, 'At least one model is required'),
models: z.array(providerModelSchema).optional(),
})
export type UpdateProviderRequest = z.infer<typeof updateProviderRequestSchema>
export const createModelRequestSchema = z.object({
modelId: z.string().min(1, 'Model ID is required'),
name: z.string().min(0).default(''),
config: providerModelConfigSchema,
})
export type CreateModelRequest = z.infer<typeof createModelRequestSchema>
export const updateModelRequestSchema = z.object({
modelId: z.string().min(1, 'Model ID is required').optional(),
name: z.string().min(0).optional(),
config: providerModelConfigSchema.optional(),
})
export type UpdateModelRequest = z.infer<typeof updateModelRequestSchema>
export const providerResponseSchema = z.object({
id: z.string(),
name: z.string(),
@@ -12,6 +12,7 @@ import {
DialogTitle,
} from '@/ui/components/ui/dialog'
import { Field, FieldLabel, FieldError } from '@/ui/components/ui/field'
import { Popover, PopoverContent, PopoverTrigger } from '@/ui/components/ui/popover'
import {
Select,
SelectContent,
@@ -22,8 +23,8 @@ import {
import { Switch } from '@/ui/components/ui/switch'
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { useForm, useStore } from '@tanstack/react-form'
import { Loader2, Puzzle, Server, Terminal } from 'lucide-react'
import { useEffect, useMemo } from 'react'
import { Check, ChevronDown, Loader2, Puzzle, Search, Server, Terminal, Zap } from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
import { m } from '@/ui/paraglide/messages.js'
import { toast } from 'sonner'
import { AgentInfo, AgentType, ThinkingLevel, thinkingLevelSchema } from '@shumai/dtos'
@@ -218,6 +219,44 @@ export function AgentFormDialog({
enabled: !!selectedProviderId && isOpen,
})
const [providerSearchQuery, setProviderSearchQuery] = useState('')
const [isProviderSelectOpen, setIsProviderSelectOpen] = useState(false)
// Sort providers alphabetically by name
const sortedProviders = useMemo(() => {
if (!providers) return []
return [...providers].sort((a, b) => a.name.toLowerCase().localeCompare(b.name.toLowerCase()))
}, [providers])
// Filter providers based on search query
const filteredProviders = useMemo(() => {
if (!providerSearchQuery.trim()) return sortedProviders
const q = providerSearchQuery.toLowerCase()
return sortedProviders.filter((p) => p.name.toLowerCase().includes(q))
}, [sortedProviders, providerSearchQuery])
const [modelSearchQuery, setModelSearchQuery] = useState('')
const [isModelSelectOpen, setIsModelSelectOpen] = useState(false)
// Sort models alphabetically by display name / modelId
const sortedModels = useMemo(() => {
if (!models) return []
return [...models].sort((a, b) => {
const nameA = (a.name || a.modelId).toLowerCase()
const nameB = (b.name || b.modelId).toLowerCase()
return nameA.localeCompare(nameB)
})
}, [models])
// Filter models based on search query
const filteredModels = useMemo(() => {
if (!modelSearchQuery.trim()) return sortedModels
const q = modelSearchQuery.toLowerCase()
return sortedModels.filter(
(m) => m.modelId.toLowerCase().includes(q) || (m.name && m.name.toLowerCase().includes(q)),
)
}, [sortedModels, modelSearchQuery])
const createMutation = useMutation({
mutationFn: async (values: AgentFormValues) => {
const res = await client.api.teams[':teamId'].agents.$post({
@@ -259,6 +298,10 @@ export function AgentFormDialog({
useEffect(() => {
if (isOpen) {
form.reset()
setProviderSearchQuery('')
setIsProviderSelectOpen(false)
setModelSearchQuery('')
setIsModelSelectOpen(false)
}
}, [isOpen, initialValues, type])
@@ -421,27 +464,109 @@ export function AgentFormDialog({
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
const selectedProvider = providers?.find((p) => p.id === field.state.value)
return (
<Field data-invalid={isInvalid}>
<FieldLabel>{m.provider()}</FieldLabel>
<Select
value={field.state.value}
onValueChange={(val) => {
field.handleChange(val)
form.setFieldValue('modelId', '')
<Popover
open={isProviderSelectOpen}
onOpenChange={(open) => {
setIsProviderSelectOpen(open)
if (!open) setProviderSearchQuery('')
}}
modal={true}
>
<SelectTrigger aria-invalid={isInvalid}>
<SelectValue placeholder={m.select_provider()} />
</SelectTrigger>
<SelectContent>
{providers?.map((p) => (
<SelectItem key={p.id} value={p.id}>
{p.name}
</SelectItem>
))}
</SelectContent>
</Select>
<PopoverTrigger asChild>
<Button
type="button"
variant="outline"
role="combobox"
aria-expanded={isProviderSelectOpen}
aria-invalid={isInvalid}
className={cn(
'w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50',
isInvalid && 'border-destructive ring-destructive',
)}
>
<span className="truncate">
{selectedProvider ? (
<span className="font-medium text-foreground truncate">
{selectedProvider.name}
</span>
) : (
<span className="text-muted-foreground">
{m.select_provider()}
</span>
)}
</span>
<ChevronDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent
className="w-[--radix-popover-trigger-width] min-w-[320px] max-h-[360px] p-0 flex flex-col overflow-hidden"
align="start"
side="bottom"
sideOffset={4}
onWheel={(e) => e.stopPropagation()}
>
<div className="relative p-2 pb-1.5 border-b border-border shrink-0">
<Search className="absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" />
<Input
placeholder={m.search_providers_placeholder()}
value={providerSearchQuery}
onChange={(e) => setProviderSearchQuery(e.target.value)}
className="pl-8 h-8 text-xs bg-muted/40"
autoFocus
/>
</div>
<ScrollArea
className="w-full p-1"
style={{
height:
filteredProviders.length === 0
? '96px'
: `${Math.min(filteredProviders.length * 38 + 8, 256)}px`,
}}
onWheel={(e) => e.stopPropagation()}
>
{filteredProviders.length === 0 ? (
<div className="flex items-center justify-center h-full py-6 text-xs text-muted-foreground">
{m.no_providers_found()}
</div>
) : (
<div className="space-y-0.5 pr-2">
{filteredProviders.map((p) => {
const isSelected = field.state.value === p.id
return (
<div
key={p.id}
onClick={() => {
field.handleChange(p.id)
form.setFieldValue('modelId', '')
setModelSearchQuery('')
setIsProviderSelectOpen(false)
setProviderSearchQuery('')
}}
className={cn(
'flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors',
isSelected
? 'bg-accent text-accent-foreground font-medium'
: 'hover:bg-muted/60 text-foreground',
)}
>
<span className="truncate flex-1 pr-2">{p.name}</span>
{isSelected && (
<Check className="w-4 h-4 text-primary shrink-0" />
)}
</div>
)
})}
</div>
)}
</ScrollArea>
</PopoverContent>
</Popover>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
@@ -455,28 +580,141 @@ export function AgentFormDialog({
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
const selectedModel = models?.find((m) => m.id === field.state.value)
return (
<Field data-invalid={isInvalid}>
<FieldLabel className="flex items-center gap-2">
{m.model()}
{isModelsLoading && <Loader2 className="w-3 h-3 animate-spin" />}
</FieldLabel>
<Select
value={field.state.value}
onValueChange={field.handleChange}
disabled={!selectedProviderId || isModelsLoading}
<Popover
open={isModelSelectOpen}
onOpenChange={(open) => {
setIsModelSelectOpen(open)
if (!open) setModelSearchQuery('')
}}
modal={true}
>
<SelectTrigger aria-invalid={isInvalid}>
<SelectValue placeholder={m.select_model()} />
</SelectTrigger>
<SelectContent>
{models?.map((m) => (
<SelectItem key={m.id} value={m.id}>
{m.name || m.modelId}
</SelectItem>
))}
</SelectContent>
</Select>
<PopoverTrigger asChild>
<Button
type="button"
variant="outline"
role="combobox"
aria-expanded={isModelSelectOpen}
aria-invalid={isInvalid}
disabled={!selectedProviderId || isModelsLoading}
className={cn(
'w-full justify-between font-normal h-10 px-3 bg-background border-border hover:bg-accent/50',
isInvalid && 'border-destructive ring-destructive',
)}
>
<span className="truncate flex items-center gap-2">
{selectedModel ? (
<>
<span className="truncate font-medium text-foreground">
{selectedModel.name || selectedModel.modelId}
</span>
{selectedModel.name &&
selectedModel.name !== selectedModel.modelId && (
<Badge
variant="secondary"
className="font-mono text-[10px] px-1.5 py-0 shrink-0"
>
{selectedModel.modelId}
</Badge>
)}
</>
) : (
<span className="text-muted-foreground">
{m.select_model()}
</span>
)}
</span>
<ChevronDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent
className="w-[--radix-popover-trigger-width] min-w-[320px] max-h-[360px] p-0 flex flex-col overflow-hidden"
align="start"
side="bottom"
sideOffset={4}
onWheel={(e) => e.stopPropagation()}
>
<div className="relative p-2 pb-1.5 border-b border-border shrink-0">
<Search className="absolute left-4.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" />
<Input
placeholder={m.search_models_placeholder()}
value={modelSearchQuery}
onChange={(e) => setModelSearchQuery(e.target.value)}
className="pl-8 h-8 text-xs bg-muted/40"
autoFocus
/>
</div>
<ScrollArea
className="w-full p-1"
style={{
height:
filteredModels.length === 0
? '96px'
: `${Math.min(filteredModels.length * 38 + 8, 256)}px`,
}}
onWheel={(e) => e.stopPropagation()}
>
{filteredModels.length === 0 ? (
<div className="flex items-center justify-center h-full py-6 text-xs text-muted-foreground">
{m.no_models_found()}
</div>
) : (
<div className="space-y-0.5 pr-2">
{filteredModels.map((m) => {
const isSelected = field.state.value === m.id
return (
<div
key={m.id}
onClick={() => {
field.handleChange(m.id)
setIsModelSelectOpen(false)
setModelSearchQuery('')
}}
className={cn(
'flex items-center justify-between px-2.5 py-2 rounded-md text-xs cursor-pointer transition-colors',
isSelected
? 'bg-accent text-accent-foreground font-medium'
: 'hover:bg-muted/60 text-foreground',
)}
>
<div className="min-w-0 flex-1 pr-2">
<div className="flex items-center gap-2">
<span className="truncate">
{m.name || m.modelId}
</span>
{m.name && m.name !== m.modelId && (
<span className="font-mono text-[10px] text-muted-foreground truncate">
({m.modelId})
</span>
)}
{m.config?.reasoning && (
<Badge
variant="outline"
className="text-[9px] px-1 py-0 h-4 gap-0.5 bg-primary/10 text-primary border-primary/20 shrink-0"
>
<Zap className="w-2.5 h-2.5" />
</Badge>
)}
</div>
</div>
{isSelected && (
<Check className="w-4 h-4 text-primary shrink-0" />
)}
</div>
)
})}
</div>
)}
</ScrollArea>
</PopoverContent>
</Popover>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
@@ -0,0 +1,92 @@
// @vitest-environment happy-dom
import { cleanup, render, screen } from '@testing-library/react'
import React from 'react'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { ModelFormDialog } from './ModelFormDialog'
import type { ModelFormValues } from './ModelFormDialog'
describe('ModelFormDialog', () => {
afterEach(() => {
cleanup()
})
const model1: ModelFormValues = {
modelId: 'gpt-4o',
name: 'GPT-4o Production',
config: {
api: 'openai-responses',
reasoning: true,
input: ['text', 'image'],
contextWindow: 128000,
maxTokens: 4096,
cost: { input: 2.5, output: 10, cacheRead: 1.25, cacheWrite: 2.5 },
},
}
const model2: ModelFormValues = {
modelId: 'claude-3-5-sonnet',
name: 'Claude 3.5 Sonnet',
config: {
api: 'anthropic-messages',
reasoning: false,
input: ['text'],
contextWindow: 200000,
maxTokens: 8192,
cost: { input: 3, output: 15, cacheRead: 0.3, cacheWrite: 3.75 },
},
}
it('populates fields with initialValues when opened for editing', () => {
render(
<ModelFormDialog
isOpen={true}
onClose={vi.fn()}
onSubmit={vi.fn()}
title="Edit Model"
initialValues={model1}
defaultApi="openai-responses"
/>,
)
const modelIdInput = screen.getByLabelText(/model id/i) as HTMLInputElement
const nameInput = screen.getByLabelText(/display name/i) as HTMLInputElement
expect(modelIdInput.value).toBe('gpt-4o')
expect(nameInput.value).toBe('GPT-4o Production')
})
it('updates fields when switching between different models', () => {
const { rerender } = render(
<ModelFormDialog
key="model-1"
isOpen={true}
onClose={vi.fn()}
onSubmit={vi.fn()}
title="Edit Model"
initialValues={model1}
defaultApi="openai-responses"
/>,
)
let modelIdInput = screen.getByLabelText(/model id/i) as HTMLInputElement
expect(modelIdInput.value).toBe('gpt-4o')
rerender(
<ModelFormDialog
key="model-2"
isOpen={true}
onClose={vi.fn()}
onSubmit={vi.fn()}
title="Edit Model"
initialValues={model2}
defaultApi="anthropic-messages"
/>,
)
modelIdInput = screen.getByLabelText(/model id/i) as HTMLInputElement
const nameInput = screen.getByLabelText(/display name/i) as HTMLInputElement
expect(modelIdInput.value).toBe('claude-3-5-sonnet')
expect(nameInput.value).toBe('Claude 3.5 Sonnet')
})
})
@@ -0,0 +1,398 @@
import { ScrollArea } from '@/ui/components/ui/scroll-area'
import { Button } from '@/ui/components/ui/button'
import {
Dialog,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/ui/components/ui/dialog'
import { Field, FieldError, FieldLabel } from '@/ui/components/ui/field'
import { Input } from '@/ui/components/ui/input'
import { Switch } from '@/ui/components/ui/switch'
import { createModelRequestSchema } from '@shumai/dtos'
import { useForm } from '@tanstack/react-form'
import { DollarSign, Loader2 } from 'lucide-react'
import { useEffect, useMemo } from 'react'
import { z } from 'zod'
import { m } from '@/ui/paraglide/messages.js'
export type ModelFormValues = z.infer<typeof createModelRequestSchema>
export interface ModelFormDialogProps {
isOpen: boolean
onClose: () => void
onSubmit: (values: ModelFormValues) => void
initialValues?: ModelFormValues | null
title: string
isLoading?: boolean
defaultApi?: string
existingModelIds?: string[]
}
export function ModelFormDialog({
isOpen,
onClose,
onSubmit,
initialValues,
title,
isLoading = false,
defaultApi,
existingModelIds = [],
}: ModelFormDialogProps) {
const schema = useMemo(() => {
return createModelRequestSchema.extend({
modelId: z
.string()
.min(1, m.model_id())
.refine(
(id) => {
if (initialValues?.modelId === id) return true
return !existingModelIds.includes(id)
},
{ message: m.model_id_already_exists() },
),
})
}, [existingModelIds, initialValues])
const getDefaultValues = () =>
(initialValues || {
modelId: '',
name: '',
config: {
api: defaultApi,
reasoning: false,
input: ['text'],
contextWindow: 128000,
maxTokens: 4096,
cost: {
input: 0,
output: 0,
cacheRead: 0,
cacheWrite: 0,
},
},
}) as z.input<typeof schema>
const form = useForm({
defaultValues: getDefaultValues(),
validators: {
onSubmit: schema,
},
onSubmit: async ({ value }) => {
onSubmit(value as ModelFormValues)
},
})
useEffect(() => {
if (isOpen) {
form.reset(getDefaultValues())
}
}, [isOpen, initialValues, defaultApi, form])
const mapErrors = (errors: unknown[]) => {
return errors.map((e) => {
if (typeof e === 'string') return { message: e }
if (e && typeof e === 'object' && 'message' in e) {
return { message: String(e.message) }
}
return { message: String(e || '') }
})
}
return (
<Dialog open={isOpen} onOpenChange={onClose}>
<DialogContent className="sm:max-w-xl h-[85vh] max-h-[700px] flex flex-col p-0 overflow-hidden">
<DialogHeader className="p-6 pb-2 shrink-0">
<DialogTitle className="text-xl">{title}</DialogTitle>
</DialogHeader>
<form
onSubmit={(e) => {
e.preventDefault()
e.stopPropagation()
form.handleSubmit()
}}
className="flex-1 flex flex-col min-h-0 overflow-hidden"
>
<div className="flex-1 min-h-0">
<ScrollArea className="h-full">
<div className="p-6 pt-2 space-y-6 pr-6">
{/* Basic Model Info */}
<div className="space-y-4">
<form.Field
name="modelId"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name}>{m.model_id()}</FieldLabel>
<Input
id={field.name}
name={field.name}
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(e.target.value)}
placeholder={m.model_id_placeholder()}
aria-invalid={isInvalid}
/>
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
</Field>
)
}}
/>
<form.Field
name="name"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name}>{m.display_name_optional()}</FieldLabel>
<Input
id={field.name}
name={field.name}
value={field.state.value || ''}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(e.target.value)}
placeholder={m.model_name_placeholder()}
aria-invalid={isInvalid}
/>
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
</Field>
)
}}
/>
</div>
{/* Parameters & Reasoning */}
<div className="space-y-4 pt-2 border-t border-border">
<h4 className="text-sm font-semibold text-foreground">{m.parameters()}</h4>
<form.Field
name="config.reasoning"
children={(field) => (
<Field
orientation="horizontal"
className="rounded-lg border border-border p-3 shadow-sm bg-muted/40 justify-between flex items-center"
>
<FieldLabel htmlFor={field.name} className="cursor-pointer">
{m.reasoning_support()}
</FieldLabel>
<Switch
id={field.name}
checked={field.state.value}
onCheckedChange={field.handleChange}
/>
</Field>
)}
/>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<form.Field
name="config.contextWindow"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name} className="text-xs">
{m.context_window_tokens()}
</FieldLabel>
<Input
id={field.name}
name={field.name}
type="number"
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(parseInt(e.target.value) || 0)}
aria-invalid={isInvalid}
/>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
</Field>
)
}}
/>
<form.Field
name="config.maxTokens"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name} className="text-xs">
{m.max_output_tokens()}
</FieldLabel>
<Input
id={field.name}
name={field.name}
type="number"
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(parseInt(e.target.value) || 0)}
aria-invalid={isInvalid}
/>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
</Field>
)
}}
/>
</div>
</div>
{/* Pricing Section */}
<div className="space-y-4 pt-2 border-t border-border">
<h4 className="text-sm font-semibold text-foreground flex items-center gap-1.5">
<DollarSign className="w-4 h-4 text-primary" />
{m.pricing()}
</h4>
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
<form.Field
name="config.cost.input"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name} className="text-xs">
{m.input_cost_1m()}
</FieldLabel>
<Input
id={field.name}
name={field.name}
type="number"
step="0.0001"
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(parseFloat(e.target.value) || 0)}
aria-invalid={isInvalid}
/>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
</Field>
)
}}
/>
<form.Field
name="config.cost.output"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name} className="text-xs">
{m.output_cost_1m()}
</FieldLabel>
<Input
id={field.name}
name={field.name}
type="number"
step="0.0001"
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(parseFloat(e.target.value) || 0)}
aria-invalid={isInvalid}
/>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
</Field>
)
}}
/>
<form.Field
name="config.cost.cacheRead"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name} className="text-xs">
{m.cache_read_cost_1m()}
</FieldLabel>
<Input
id={field.name}
name={field.name}
type="number"
step="0.0001"
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(parseFloat(e.target.value) || 0)}
aria-invalid={isInvalid}
/>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
</Field>
)
}}
/>
<form.Field
name="config.cost.cacheWrite"
children={(field) => {
const isInvalid =
!!field.state.meta.errors.length && field.state.meta.isTouched
return (
<Field data-invalid={isInvalid}>
<FieldLabel htmlFor={field.name} className="text-xs">
{m.cache_write_cost_1m()}
</FieldLabel>
<Input
id={field.name}
name={field.name}
type="number"
step="0.0001"
value={field.state.value}
onBlur={field.handleBlur}
onChange={(e) => field.handleChange(parseFloat(e.target.value) || 0)}
aria-invalid={isInvalid}
/>
{isInvalid && (
<FieldError errors={mapErrors(field.state.meta.errors)} />
)}
</Field>
)
}}
/>
</div>
</div>
</div>
</ScrollArea>
</div>
<DialogFooter className="p-6 pt-4 border-t border-border gap-2 shrink-0">
<Button type="button" variant="outline" onClick={onClose} disabled={isLoading}>
{m.cancel()}
</Button>
<form.Subscribe
selector={(state) => [state.canSubmit, state.isSubmitting]}
children={([canSubmit, isSubmitting]) => (
<Button
type="submit"
className="min-w-[100px]"
disabled={!canSubmit || isSubmitting || isLoading}
>
{isSubmitting || isLoading ? (
<Loader2 className="w-4 h-4 animate-spin" />
) : (
m.save_changes()
)}
</Button>
)}
/>
</DialogFooter>
</form>
</DialogContent>
</Dialog>
)
}
File diff suppressed because it is too large Load Diff
+23
View File
@@ -312,6 +312,7 @@
"configured_ai_providers": "Configured AI Providers",
"add_provider": "Add Provider",
"search_providers_placeholder": "Search providers...",
"no_providers_found": "No providers found",
"built_in": "Built-in",
"models_count": "Models",
"n_models_count": "{count} Models",
@@ -340,6 +341,20 @@
"api_key_description": "You can provide a literal value (e.g. sk-...) or an Environment variable name (e.g. MY_API_KEY).",
"models_configuration": "Models Configuration",
"add_model": "Add Model",
"edit_model": "Edit Model",
"delete_model": "Delete Model",
"delete_model_confirmation": "This action cannot be undone. This will permanently delete the model \"{name}\".",
"model_created_successfully": "Model created successfully",
"model_updated_successfully": "Model updated successfully",
"model_deleted_successfully": "Model deleted successfully",
"models": "Models",
"search_models_placeholder": "Search models by ID or name...",
"no_models_found": "No models found",
"page_info": "Page {current} of {total}",
"previous": "Previous",
"next": "Next",
"pricing": "Pricing ($ per 1M tokens)",
"parameters": "Parameters",
"model_id": "Model ID",
"display_name_optional": "Display Name (Optional)",
"reasoning_support": "Reasoning Support",
@@ -347,8 +362,16 @@
"max_output_tokens": "Max Output Tokens",
"input_cost_1m": "Input Cost (1M)",
"output_cost_1m": "Output Cost (1M)",
"tokens": "tokens",
"cache_read_cost_1m": "Cache Read Cost (1M)",
"cache_write_cost_1m": "Cache Write Cost (1M)",
"save_configuration": "Save Configuration",
"at_least_one_model_required": "At least one model is required",
"model_id_already_exists": "Model ID already exists for this provider",
"model_id_placeholder": "e.g., gpt-4o, claude-3-5-sonnet-20241022",
"model_name_placeholder": "e.g., GPT-4o",
"cost_per_million": "${input}/1M in · ${output}/1M out",
"max_tokens_label": "max {count}",
"provider": "Provider",
"model": "Model",
"select_provider": "Select Provider",
+23
View File
@@ -312,6 +312,7 @@
"configured_ai_providers": "已配置的 AI 提供商",
"add_provider": "添加提供商",
"search_providers_placeholder": "搜索提供商...",
"no_providers_found": "未找到提供商",
"built_in": "内置",
"models_count": "模型",
"n_models_count": "{count} 个模型",
@@ -340,6 +341,20 @@
"api_key_description": "您可以提供一个字面值(例如 sk-...)或环境变量名称(例如 MY_API_KEY)。",
"models_configuration": "模型配置",
"add_model": "添加模型",
"edit_model": "编辑模型",
"delete_model": "删除模型",
"delete_model_confirmation": "此操作无法撤销。这将永久删除模型 \"{name}\"。",
"model_created_successfully": "模型创建成功",
"model_updated_successfully": "模型更新成功",
"model_deleted_successfully": "模型删除成功",
"models": "模型列表",
"search_models_placeholder": "按 ID 或名称搜索模型...",
"no_models_found": "未找到模型",
"page_info": "第 {current} 页,共 {total} 页",
"previous": "上一页",
"next": "下一页",
"pricing": "计费(每百万令牌美元)",
"parameters": "参数",
"model_id": "模型 ID",
"display_name_optional": "显示名称(可选)",
"reasoning_support": "推理支持",
@@ -347,8 +362,16 @@
"max_output_tokens": "最大输出令牌数",
"input_cost_1m": "输入成本(每百万)",
"output_cost_1m": "输出成本(每百万)",
"tokens": "令牌",
"cache_read_cost_1m": "缓存读取成本(每百万)",
"cache_write_cost_1m": "缓存写入成本(每百万)",
"save_configuration": "保存配置",
"at_least_one_model_required": "至少需要一个模型",
"model_id_already_exists": "此提供商已存在该模型 ID",
"model_id_placeholder": "例如:gpt-4o, claude-3-5-sonnet-20241022",
"model_name_placeholder": "例如:GPT-4o",
"cost_per_million": "${input}/1M 输入 · ${output}/1M 输出",
"max_tokens_label": "最大 {count}",
"provider": "提供商",
"model": "模型",
"select_provider": "选择提供商",
+23
View File
@@ -296,6 +296,7 @@ export * from "./providers_description.js";
export * from "./configured_ai_providers.js";
export * from "./add_provider.js";
export * from "./search_providers_placeholder.js";
export * from "./no_providers_found.js";
export * from "./built_in.js";
export * from "./models_count.js";
export * from "./n_models_count.js";
@@ -324,6 +325,20 @@ export * from "./api_key_placeholder.js";
export * from "./api_key_description.js";
export * from "./models_configuration.js";
export * from "./add_model.js";
export * from "./edit_model.js";
export * from "./delete_model.js";
export * from "./delete_model_confirmation.js";
export * from "./model_created_successfully.js";
export * from "./model_updated_successfully.js";
export * from "./model_deleted_successfully.js";
export * from "./models.js";
export * from "./search_models_placeholder.js";
export * from "./no_models_found.js";
export * from "./page_info.js";
export * from "./previous.js";
export * from "./next.js";
export * from "./pricing.js";
export * from "./parameters.js";
export * from "./model_id.js";
export * from "./display_name_optional.js";
export * from "./reasoning_support.js";
@@ -331,8 +346,16 @@ export * from "./context_window_tokens.js";
export * from "./max_output_tokens.js";
export * from "./input_cost_1m.js";
export * from "./output_cost_1m.js";
export * from "./tokens.js";
export * from "./cache_read_cost_1m.js";
export * from "./cache_write_cost_1m.js";
export * from "./save_configuration.js";
export * from "./at_least_one_model_required.js";
export * from "./model_id_already_exists.js";
export * from "./model_id_placeholder.js";
export * from "./model_name_placeholder.js";
export * from "./cost_per_million.js";
export * from "./max_tokens_label.js";
export * from "./provider.js";
export * from "./model.js";
export * from "./select_provider.js";
+23
View File
@@ -298,6 +298,7 @@ export * from './providers_description.js'
export * from './configured_ai_providers.js'
export * from './add_provider.js'
export * from './search_providers_placeholder.js'
export * from './no_providers_found.js'
export * from './built_in.js'
export * from './models_count.js'
export * from './n_models_count.js'
@@ -326,6 +327,20 @@ export * from './api_key_placeholder.js'
export * from './api_key_description.js'
export * from './models_configuration.js'
export * from './add_model.js'
export * from './edit_model.js'
export * from './delete_model.js'
export * from './delete_model_confirmation.js'
export * from './model_created_successfully.js'
export * from './model_updated_successfully.js'
export * from './model_deleted_successfully.js'
export * from './models.js'
export * from './search_models_placeholder.js'
export * from './no_models_found.js'
export * from './page_info.js'
export * from './previous.js'
export * from './next.js'
export * from './pricing.js'
export * from './parameters.js'
export * from './model_id.js'
export * from './display_name_optional.js'
export * from './reasoning_support.js'
@@ -333,8 +348,16 @@ export * from './context_window_tokens.js'
export * from './max_output_tokens.js'
export * from './input_cost_1m.js'
export * from './output_cost_1m.js'
export * from './tokens.js'
export * from './cache_read_cost_1m.js'
export * from './cache_write_cost_1m.js'
export * from './save_configuration.js'
export * from './at_least_one_model_required.js'
export * from './model_id_already_exists.js'
export * from './model_id_placeholder.js'
export * from './model_name_placeholder.js'
export * from './cost_per_million.js'
export * from './max_tokens_label.js'
export * from './provider.js'
export * from './model.js'
export * from './select_provider.js'
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Cache Read Cost (1M)" |
*
* @param {Cache_Read_Cost_1mInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const cache_read_cost_1m: ((inputs?: Cache_Read_Cost_1mInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Cache_Read_Cost_1mInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Cache_Read_Cost_1mInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Cache_Read_Cost_1mInputs */
const en_cache_read_cost_1m = /** @type {(inputs: Cache_Read_Cost_1mInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Cache Read Cost (1M)`)
};
const zh_cache_read_cost_1m = /** @type {(inputs: Cache_Read_Cost_1mInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`缓存读取成本(每百万)`)
};
/**
* | output |
* | --- |
* | "Cache Read Cost (1M)" |
*
* @param {Cache_Read_Cost_1mInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const cache_read_cost_1m = /** @type {((inputs?: Cache_Read_Cost_1mInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Cache_Read_Cost_1mInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_cache_read_cost_1m(inputs)
return zh_cache_read_cost_1m(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Cache Write Cost (1M)" |
*
* @param {Cache_Write_Cost_1mInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const cache_write_cost_1m: ((inputs?: Cache_Write_Cost_1mInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Cache_Write_Cost_1mInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Cache_Write_Cost_1mInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Cache_Write_Cost_1mInputs */
const en_cache_write_cost_1m = /** @type {(inputs: Cache_Write_Cost_1mInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Cache Write Cost (1M)`)
};
const zh_cache_write_cost_1m = /** @type {(inputs: Cache_Write_Cost_1mInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`缓存写入成本(每百万)`)
};
/**
* | output |
* | --- |
* | "Cache Write Cost (1M)" |
*
* @param {Cache_Write_Cost_1mInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const cache_write_cost_1m = /** @type {((inputs?: Cache_Write_Cost_1mInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Cache_Write_Cost_1mInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_cache_write_cost_1m(inputs)
return zh_cache_write_cost_1m(inputs)
});
+19
View File
@@ -0,0 +1,19 @@
/**
* | output |
* | --- |
* | "${input}/1M in · ${output}/1M out" |
*
* @param {Cost_Per_MillionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const cost_per_million: ((inputs: Cost_Per_MillionInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Cost_Per_MillionInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Cost_Per_MillionInputs = {
input: NonNullable<unknown>;
output: NonNullable<unknown>;
};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{ input: NonNullable<unknown>, output: NonNullable<unknown> }} Cost_Per_MillionInputs */
const en_cost_per_million = /** @type {(inputs: Cost_Per_MillionInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`$${i?.input}/1M in · $${i?.output}/1M out`)
};
const zh_cost_per_million = /** @type {(inputs: Cost_Per_MillionInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`$${i?.input}/1M 输入 · $${i?.output}/1M 输出`)
};
/**
* | output |
* | --- |
* | "${input}/1M in · ${output}/1M out" |
*
* @param {Cost_Per_MillionInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const cost_per_million = /** @type {((inputs: Cost_Per_MillionInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Cost_Per_MillionInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_cost_per_million(inputs)
return zh_cost_per_million(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Delete Model" |
*
* @param {Delete_ModelInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const delete_model: ((inputs?: Delete_ModelInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Delete_ModelInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Delete_ModelInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Delete_ModelInputs */
const en_delete_model = /** @type {(inputs: Delete_ModelInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Delete Model`)
};
const zh_delete_model = /** @type {(inputs: Delete_ModelInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`删除模型`)
};
/**
* | output |
* | --- |
* | "Delete Model" |
*
* @param {Delete_ModelInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const delete_model = /** @type {((inputs?: Delete_ModelInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Delete_ModelInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_delete_model(inputs)
return zh_delete_model(inputs)
});
+18
View File
@@ -0,0 +1,18 @@
/**
* | output |
* | --- |
* | "This action cannot be undone. This will permanently delete the model \"{name}\"." |
*
* @param {Delete_Model_ConfirmationInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const delete_model_confirmation: ((inputs: Delete_Model_ConfirmationInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Delete_Model_ConfirmationInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Delete_Model_ConfirmationInputs = {
name: NonNullable<unknown>;
};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{ name: NonNullable<unknown> }} Delete_Model_ConfirmationInputs */
const en_delete_model_confirmation = /** @type {(inputs: Delete_Model_ConfirmationInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`This action cannot be undone. This will permanently delete the model "${i?.name}".`)
};
const zh_delete_model_confirmation = /** @type {(inputs: Delete_Model_ConfirmationInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`此操作无法撤销。这将永久删除模型 "${i?.name}"。`)
};
/**
* | output |
* | --- |
* | "This action cannot be undone. This will permanently delete the model \"{name}\"." |
*
* @param {Delete_Model_ConfirmationInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const delete_model_confirmation = /** @type {((inputs: Delete_Model_ConfirmationInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Delete_Model_ConfirmationInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_delete_model_confirmation(inputs)
return zh_delete_model_confirmation(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Edit Model" |
*
* @param {Edit_ModelInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const edit_model: ((inputs?: Edit_ModelInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Edit_ModelInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Edit_ModelInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Edit_ModelInputs */
const en_edit_model = /** @type {(inputs: Edit_ModelInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Edit Model`)
};
const zh_edit_model = /** @type {(inputs: Edit_ModelInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`编辑模型`)
};
/**
* | output |
* | --- |
* | "Edit Model" |
*
* @param {Edit_ModelInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const edit_model = /** @type {((inputs?: Edit_ModelInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Edit_ModelInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_edit_model(inputs)
return zh_edit_model(inputs)
});
+18
View File
@@ -0,0 +1,18 @@
/**
* | output |
* | --- |
* | "max {count}" |
*
* @param {Max_Tokens_LabelInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const max_tokens_label: ((inputs: Max_Tokens_LabelInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Max_Tokens_LabelInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Max_Tokens_LabelInputs = {
count: NonNullable<unknown>;
};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{ count: NonNullable<unknown> }} Max_Tokens_LabelInputs */
const en_max_tokens_label = /** @type {(inputs: Max_Tokens_LabelInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`max ${i?.count}`)
};
const zh_max_tokens_label = /** @type {(inputs: Max_Tokens_LabelInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`最大 ${i?.count}`)
};
/**
* | output |
* | --- |
* | "max {count}" |
*
* @param {Max_Tokens_LabelInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const max_tokens_label = /** @type {((inputs: Max_Tokens_LabelInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Max_Tokens_LabelInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_max_tokens_label(inputs)
return zh_max_tokens_label(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Model created successfully" |
*
* @param {Model_Created_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_created_successfully: ((inputs?: Model_Created_SuccessfullyInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Model_Created_SuccessfullyInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Model_Created_SuccessfullyInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Model_Created_SuccessfullyInputs */
const en_model_created_successfully = /** @type {(inputs: Model_Created_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Model created successfully`)
};
const zh_model_created_successfully = /** @type {(inputs: Model_Created_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`模型创建成功`)
};
/**
* | output |
* | --- |
* | "Model created successfully" |
*
* @param {Model_Created_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_created_successfully = /** @type {((inputs?: Model_Created_SuccessfullyInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Model_Created_SuccessfullyInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_model_created_successfully(inputs)
return zh_model_created_successfully(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Model deleted successfully" |
*
* @param {Model_Deleted_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_deleted_successfully: ((inputs?: Model_Deleted_SuccessfullyInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Model_Deleted_SuccessfullyInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Model_Deleted_SuccessfullyInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Model_Deleted_SuccessfullyInputs */
const en_model_deleted_successfully = /** @type {(inputs: Model_Deleted_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Model deleted successfully`)
};
const zh_model_deleted_successfully = /** @type {(inputs: Model_Deleted_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`模型删除成功`)
};
/**
* | output |
* | --- |
* | "Model deleted successfully" |
*
* @param {Model_Deleted_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_deleted_successfully = /** @type {((inputs?: Model_Deleted_SuccessfullyInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Model_Deleted_SuccessfullyInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_model_deleted_successfully(inputs)
return zh_model_deleted_successfully(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Model ID already exists for this provider" |
*
* @param {Model_Id_Already_ExistsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_id_already_exists: ((inputs?: Model_Id_Already_ExistsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Model_Id_Already_ExistsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Model_Id_Already_ExistsInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Model_Id_Already_ExistsInputs */
const en_model_id_already_exists = /** @type {(inputs: Model_Id_Already_ExistsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Model ID already exists for this provider`)
};
const zh_model_id_already_exists = /** @type {(inputs: Model_Id_Already_ExistsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`此提供商已存在该模型 ID`)
};
/**
* | output |
* | --- |
* | "Model ID already exists for this provider" |
*
* @param {Model_Id_Already_ExistsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_id_already_exists = /** @type {((inputs?: Model_Id_Already_ExistsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Model_Id_Already_ExistsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_model_id_already_exists(inputs)
return zh_model_id_already_exists(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "e.g., gpt-4o, claude-3-5-sonnet-20241022" |
*
* @param {Model_Id_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_id_placeholder: ((inputs?: Model_Id_PlaceholderInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Model_Id_PlaceholderInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Model_Id_PlaceholderInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Model_Id_PlaceholderInputs */
const en_model_id_placeholder = /** @type {(inputs: Model_Id_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`e.g., gpt-4o, claude-3-5-sonnet-20241022`)
};
const zh_model_id_placeholder = /** @type {(inputs: Model_Id_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`例如:gpt-4o, claude-3-5-sonnet-20241022`)
};
/**
* | output |
* | --- |
* | "e.g., gpt-4o, claude-3-5-sonnet-20241022" |
*
* @param {Model_Id_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_id_placeholder = /** @type {((inputs?: Model_Id_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Model_Id_PlaceholderInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_model_id_placeholder(inputs)
return zh_model_id_placeholder(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "e.g., GPT-4o" |
*
* @param {Model_Name_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_name_placeholder: ((inputs?: Model_Name_PlaceholderInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Model_Name_PlaceholderInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Model_Name_PlaceholderInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Model_Name_PlaceholderInputs */
const en_model_name_placeholder = /** @type {(inputs: Model_Name_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`e.g., GPT-4o`)
};
const zh_model_name_placeholder = /** @type {(inputs: Model_Name_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`例如:GPT-4o`)
};
/**
* | output |
* | --- |
* | "e.g., GPT-4o" |
*
* @param {Model_Name_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_name_placeholder = /** @type {((inputs?: Model_Name_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Model_Name_PlaceholderInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_model_name_placeholder(inputs)
return zh_model_name_placeholder(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Model updated successfully" |
*
* @param {Model_Updated_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_updated_successfully: ((inputs?: Model_Updated_SuccessfullyInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Model_Updated_SuccessfullyInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Model_Updated_SuccessfullyInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Model_Updated_SuccessfullyInputs */
const en_model_updated_successfully = /** @type {(inputs: Model_Updated_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Model updated successfully`)
};
const zh_model_updated_successfully = /** @type {(inputs: Model_Updated_SuccessfullyInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`模型更新成功`)
};
/**
* | output |
* | --- |
* | "Model updated successfully" |
*
* @param {Model_Updated_SuccessfullyInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const model_updated_successfully = /** @type {((inputs?: Model_Updated_SuccessfullyInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Model_Updated_SuccessfullyInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_model_updated_successfully(inputs)
return zh_model_updated_successfully(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Models" |
*
* @param {ModelsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const models: ((inputs?: ModelsInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<ModelsInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type ModelsInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} ModelsInputs */
const en_models = /** @type {(inputs: ModelsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Models`)
};
const zh_models = /** @type {(inputs: ModelsInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`模型列表`)
};
/**
* | output |
* | --- |
* | "Models" |
*
* @param {ModelsInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const models = /** @type {((inputs?: ModelsInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<ModelsInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_models(inputs)
return zh_models(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Next" |
*
* @param {NextInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const next: ((inputs?: NextInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<NextInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type NextInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} NextInputs */
const en_next = /** @type {(inputs: NextInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Next`)
};
const zh_next = /** @type {(inputs: NextInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`下一页`)
};
/**
* | output |
* | --- |
* | "Next" |
*
* @param {NextInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const next = /** @type {((inputs?: NextInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<NextInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_next(inputs)
return zh_next(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "No models found" |
*
* @param {No_Models_FoundInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_models_found: ((inputs?: No_Models_FoundInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<No_Models_FoundInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type No_Models_FoundInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} No_Models_FoundInputs */
const en_no_models_found = /** @type {(inputs: No_Models_FoundInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`No models found`)
};
const zh_no_models_found = /** @type {(inputs: No_Models_FoundInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`未找到模型`)
};
/**
* | output |
* | --- |
* | "No models found" |
*
* @param {No_Models_FoundInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_models_found = /** @type {((inputs?: No_Models_FoundInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<No_Models_FoundInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_no_models_found(inputs)
return zh_no_models_found(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "No providers found" |
*
* @param {No_Providers_FoundInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_providers_found: ((inputs?: No_Providers_FoundInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<No_Providers_FoundInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type No_Providers_FoundInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} No_Providers_FoundInputs */
const en_no_providers_found = /** @type {(inputs: No_Providers_FoundInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`No providers found`)
};
const zh_no_providers_found = /** @type {(inputs: No_Providers_FoundInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`未找到提供商`)
};
/**
* | output |
* | --- |
* | "No providers found" |
*
* @param {No_Providers_FoundInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const no_providers_found = /** @type {((inputs?: No_Providers_FoundInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<No_Providers_FoundInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_no_providers_found(inputs)
return zh_no_providers_found(inputs)
});
+19
View File
@@ -0,0 +1,19 @@
/**
* | output |
* | --- |
* | "Page {current} of {total}" |
*
* @param {Page_InfoInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const page_info: ((inputs: Page_InfoInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Page_InfoInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Page_InfoInputs = {
current: NonNullable<unknown>;
total: NonNullable<unknown>;
};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{ current: NonNullable<unknown>, total: NonNullable<unknown> }} Page_InfoInputs */
const en_page_info = /** @type {(inputs: Page_InfoInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`Page ${i?.current} of ${i?.total}`)
};
const zh_page_info = /** @type {(inputs: Page_InfoInputs) => LocalizedString} */ (i) => {
return /** @type {LocalizedString} */ (`第 ${i?.current} 页,共 ${i?.total} 页`)
};
/**
* | output |
* | --- |
* | "Page {current} of {total}" |
*
* @param {Page_InfoInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const page_info = /** @type {((inputs: Page_InfoInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Page_InfoInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_page_info(inputs)
return zh_page_info(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Parameters" |
*
* @param {ParametersInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const parameters: ((inputs?: ParametersInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<ParametersInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type ParametersInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} ParametersInputs */
const en_parameters = /** @type {(inputs: ParametersInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Parameters`)
};
const zh_parameters = /** @type {(inputs: ParametersInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`参数`)
};
/**
* | output |
* | --- |
* | "Parameters" |
*
* @param {ParametersInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const parameters = /** @type {((inputs?: ParametersInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<ParametersInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_parameters(inputs)
return zh_parameters(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Previous" |
*
* @param {PreviousInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const previous: ((inputs?: PreviousInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<PreviousInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type PreviousInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} PreviousInputs */
const en_previous = /** @type {(inputs: PreviousInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Previous`)
};
const zh_previous = /** @type {(inputs: PreviousInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`上一页`)
};
/**
* | output |
* | --- |
* | "Previous" |
*
* @param {PreviousInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const previous = /** @type {((inputs?: PreviousInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<PreviousInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_previous(inputs)
return zh_previous(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Pricing ($ per 1M tokens)" |
*
* @param {PricingInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const pricing: ((inputs?: PricingInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<PricingInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type PricingInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} PricingInputs */
const en_pricing = /** @type {(inputs: PricingInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Pricing ($ per 1M tokens)`)
};
const zh_pricing = /** @type {(inputs: PricingInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`计费(每百万令牌美元)`)
};
/**
* | output |
* | --- |
* | "Pricing ($ per 1M tokens)" |
*
* @param {PricingInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const pricing = /** @type {((inputs?: PricingInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<PricingInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_pricing(inputs)
return zh_pricing(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "Search models by ID or name..." |
*
* @param {Search_Models_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const search_models_placeholder: ((inputs?: Search_Models_PlaceholderInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<Search_Models_PlaceholderInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type Search_Models_PlaceholderInputs = {};
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} Search_Models_PlaceholderInputs */
const en_search_models_placeholder = /** @type {(inputs: Search_Models_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`Search models by ID or name...`)
};
const zh_search_models_placeholder = /** @type {(inputs: Search_Models_PlaceholderInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`按 ID 或名称搜索模型...`)
};
/**
* | output |
* | --- |
* | "Search models by ID or name..." |
*
* @param {Search_Models_PlaceholderInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const search_models_placeholder = /** @type {((inputs?: Search_Models_PlaceholderInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<Search_Models_PlaceholderInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_search_models_placeholder(inputs)
return zh_search_models_placeholder(inputs)
});
+16
View File
@@ -0,0 +1,16 @@
/**
* | output |
* | --- |
* | "tokens" |
*
* @param {TokensInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const tokens: ((inputs?: TokensInputs, options?: {
locale?: "en" | "zh";
}) => LocalizedString) & import("../runtime.js").MessageMetadata<TokensInputs, {
locale?: "en" | "zh";
}, {}>;
export type LocalizedString = import("../runtime.js").LocalizedString;
export type TokensInputs = {};
+29
View File
@@ -0,0 +1,29 @@
/* eslint-disable */
import { getLocale, experimentalStaticLocale } from '../runtime.js';
/** @typedef {import('../runtime.js').LocalizedString} LocalizedString */
/** @typedef {{}} TokensInputs */
const en_tokens = /** @type {(inputs: TokensInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`tokens`)
};
const zh_tokens = /** @type {(inputs: TokensInputs) => LocalizedString} */ () => {
return /** @type {LocalizedString} */ (`令牌`)
};
/**
* | output |
* | --- |
* | "tokens" |
*
* @param {TokensInputs} inputs
* @param {{ locale?: "en" | "zh" }} options
* @returns {LocalizedString}
*/
export const tokens = /** @type {((inputs?: TokensInputs, options?: { locale?: "en" | "zh" }) => LocalizedString) & import('../runtime.js').MessageMetadata<TokensInputs, { locale?: "en" | "zh" }, {}>} */ ((inputs = {}, options = {}) => {
const locale = experimentalStaticLocale ?? options.locale ?? getLocale()
if (locale === "en") return en_tokens(inputs)
return zh_tokens(inputs)
});
@@ -58,10 +58,51 @@ type SettingsTab =
| 'notifications'
| 'developer'
const VALID_SETTINGS_TABS: readonly SettingsTab[] = [
'general',
'transcode',
'quotas',
'skills',
'mcp',
'providers',
'agents',
'sandbox',
'notifications',
'developer',
]
function getTabFromHash(): SettingsTab {
if (typeof window === 'undefined') return 'general'
const hash = window.location.hash.replace(/^#/, '')
return (VALID_SETTINGS_TABS as readonly string[]).includes(hash)
? (hash as SettingsTab)
: 'general'
}
function TeamSettingsPage() {
const { teamId } = Route.useParams()
const queryClient = useQueryClient()
const [activeTab, setActiveTab] = useState<SettingsTab>('general')
const [activeTab, setActiveTabState] = useState<SettingsTab>(getTabFromHash)
const handleTabChange = (tab: SettingsTab) => {
setActiveTabState(tab)
const newHash = tab === 'general' ? '' : `#${tab}`
if (window.location.hash !== newHash) {
window.history.replaceState(
null,
'',
window.location.pathname + window.location.search + newHash,
)
}
}
useEffect(() => {
const onHashChange = () => {
setActiveTabState(getTabFromHash())
}
window.addEventListener('hashchange', onHashChange)
return () => window.removeEventListener('hashchange', onHashChange)
}, [])
const [profileName, setProfileName] = useState('')
const [isCropOpen, setIsCropOpen] = useState(false)
const [cropImageSrc, setCropImageSrc] = useState<string | null>(null)
@@ -128,7 +169,7 @@ function TeamSettingsPage() {
'sandbox',
]
if (me && me.role !== 'owner' && ownerOnlyTabs.includes(activeTab)) {
setActiveTab('general')
handleTabChange('general')
}
}, [me, activeTab])
@@ -295,7 +336,7 @@ function TeamSettingsPage() {
</div>
<button
onClick={() => setActiveTab('general')}
onClick={() => handleTabChange('general')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'general'
@@ -311,7 +352,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('notifications')}
onClick={() => handleTabChange('notifications')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'notifications'
@@ -327,7 +368,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('developer')}
onClick={() => handleTabChange('developer')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'developer'
@@ -350,7 +391,7 @@ function TeamSettingsPage() {
</div>
<button
onClick={() => setActiveTab('transcode')}
onClick={() => handleTabChange('transcode')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'transcode'
@@ -366,7 +407,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('quotas')}
onClick={() => handleTabChange('quotas')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'quotas'
@@ -391,7 +432,7 @@ function TeamSettingsPage() {
</div>
<button
onClick={() => setActiveTab('providers')}
onClick={() => handleTabChange('providers')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'providers'
@@ -407,7 +448,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('skills')}
onClick={() => handleTabChange('skills')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'skills'
@@ -423,7 +464,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('mcp')}
onClick={() => handleTabChange('mcp')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'mcp'
@@ -439,7 +480,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('agents')}
onClick={() => handleTabChange('agents')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'agents'
@@ -455,7 +496,7 @@ function TeamSettingsPage() {
</button>
<button
onClick={() => setActiveTab('sandbox')}
onClick={() => handleTabChange('sandbox')}
className={cn(
'w-full flex items-center gap-3 px-4 py-3 text-sm font-medium rounded-lg transition-all',
activeTab === 'sandbox'