import { useEffect, useRef, useState } from 'react'; import { nativeParameterSettings } from '../shared/contracts/native-parameters.mjs'; export type NativeConnection = { id: string; revision: number; name: string; protocol: string; nativeParameters?: Record; outputTokenField?: string }; export function NativeParameters({ connection, busy, onCancel, onSave }: { connection: NativeConnection; busy: boolean; onCancel: () => void; onSave: (input: { id: string; revision: number; nativeParameters: Record; outputTokenField: string }) => Promise }) { const [text, setText] = useState(JSON.stringify(connection.nativeParameters ?? {}, null, 2)); const [field, setField] = useState(connection.outputTokenField ?? (connection.protocol === 'responses' ? 'max_output_tokens' : 'max_tokens')); const [error, setError] = useState(''); const form = useRef(null); useEffect(() => { form.current?.scrollIntoView({ block: 'nearest' }); }, []); return
{ event.preventDefault(); setError(''); try { const settings = nativeParameterSettings(connection.protocol, JSON.parse(text), field); await onSave({ id: connection.id, revision: connection.revision, ...settings }); } catch (cause) { setError(cause instanceof Error ? cause.message : '参数格式无效。'); } }}>

{connection.name} · 原生请求参数

参数按所选协议原字段发送,并封存在实际请求中。具体模型是否接受这些选项,以服务响应为准;未填写的选项采用上游默认值。

数值沿用当前任务和连接的输出预算,不允许原生参数覆盖预算、消息、工具或接口。