import type { FormEvent } from 'react'; import type { GatewayApiKey, GatewayTask } from '@easyai-ai-gateway/contracts'; import type { LoadState, TaskForm } from '../types'; const taskKindOptions = [ ['chat.completions', 'Chat'], ['images.generations', '生图'], ['images.edits', '图像编辑'], ] as const; export function CoreFlowPanel(props: { apiKeyForm: { name: string }; apiKeys: GatewayApiKey[]; apiKeySecret: string; coreMessage: string; coreState: LoadState; platformForm: { provider: string; platformKey: string; name: string; baseUrl: string }; taskForm: TaskForm; taskResult: GatewayTask | null; onAPIKeyFormChange: (value: { name: string }) => void; onPlatformFormChange: (value: { provider: string; platformKey: string; name: string; baseUrl: string }) => void; onSubmitAPIKey: (event: FormEvent) => void; onSubmitPlatform: (event: FormEvent) => void; onSubmitTask: (event: FormEvent) => void; onTaskFormChange: (value: TaskForm) => void; }) { return (

Smoke Flow

核心链路验证

{props.coreState === 'loading' ? '运行中' : '本地闭环'}
{props.coreMessage && (

{props.coreMessage}

)}
); } function ApiKeyForm(props: { apiKeyForm: { name: string }; apiKeys: GatewayApiKey[]; apiKeySecret: string; coreState: LoadState; onAPIKeyFormChange: (value: { name: string }) => void; onSubmitAPIKey: (event: FormEvent) => void; }) { return (

1. API Key

已创建 {props.apiKeys.length} 个 Key

{props.apiKeySecret && {props.apiKeySecret}}
); } function PlatformForm(props: { coreState: LoadState; platformForm: { provider: string; platformKey: string; name: string; baseUrl: string }; onPlatformFormChange: (value: { provider: string; platformKey: string; name: string; baseUrl: string }) => void; onSubmitPlatform: (event: FormEvent) => void; }) { return (

2. 平台

); } function TaskSmokeForm(props: { coreState: LoadState; taskForm: TaskForm; taskResult: GatewayTask | null; onSubmitTask: (event: FormEvent) => void; onTaskFormChange: (value: TaskForm) => void; }) { return (

3. Phase 1 测试

{props.taskForm.kind === 'images.edits' && ( <> )} {props.taskResult && (
{props.taskResult.status} {props.taskResult.model}
{JSON.stringify(props.taskResult.result ?? {}, null, 2)}
)}
); } function defaultTaskForKind(kind: TaskForm['kind'], current: TaskForm): TaskForm { if (kind === 'chat.completions') { return { ...current, kind, model: 'gpt-4o-mini' }; } if (kind === 'images.edits') { return { ...current, kind, model: 'gpt-image-1', image: current.image ?? 'https://example.com/source.png', mask: current.mask ?? 'https://example.com/mask.png' }; } return { ...current, kind, model: 'gpt-image-1' }; }