mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-08 18:37:46 +08:00
feat(provider): 模型测试支持自定义请求头,优化对话框布局与并发策略
- 前后端新增 request_headers 字段,测试时可自定义额外请求头 - ModelTestDialog 拆分为请求头/请求体并排双栏布局,增加格式化与重置按钮 - 区分 Pool 托管(并发5)和单 Key Provider(并发1)的测试并发数 - JsonImportInput 新增 multiple prop 支持单文件模式 - KeyFormDialog Service Account 输入改用 JsonImportInput,支持拖拽导入
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
const DEFAULT_MODEL_TEST_MESSAGE = 'Hello! This is a test message.'
|
||||
|
||||
/** Pool-managed provider runs concurrent checks; single-key provider does not. */
|
||||
export const POOL_TEST_CONCURRENCY = 5
|
||||
export const SINGLE_TEST_CONCURRENCY = 1
|
||||
|
||||
export function buildDefaultModelTestRequestBody(modelName: string): string {
|
||||
return JSON.stringify({
|
||||
model: modelName,
|
||||
@@ -15,14 +19,23 @@ export function buildDefaultModelTestRequestBody(modelName: string): string {
|
||||
}, null, 2)
|
||||
}
|
||||
|
||||
export function parseModelTestRequestBodyDraft(
|
||||
export function buildDefaultModelTestRequestHeaders(): string {
|
||||
return JSON.stringify({}, null, 2)
|
||||
}
|
||||
|
||||
function parseModelTestJsonObjectDraft(
|
||||
draft: string,
|
||||
options: {
|
||||
emptyValue: Record<string, unknown> | null
|
||||
emptyError: string | null
|
||||
invalidTypeError: string
|
||||
},
|
||||
): { value: Record<string, unknown> | null; error: string | null } {
|
||||
const normalized = draft.trim()
|
||||
if (!normalized) {
|
||||
return {
|
||||
value: null,
|
||||
error: '测试请求体不能为空',
|
||||
value: options.emptyValue,
|
||||
error: options.emptyError,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +44,7 @@ export function parseModelTestRequestBodyDraft(
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
return {
|
||||
value: null,
|
||||
error: '测试请求体必须是 JSON 对象',
|
||||
error: options.invalidTypeError,
|
||||
}
|
||||
}
|
||||
return {
|
||||
@@ -45,3 +58,23 @@ export function parseModelTestRequestBodyDraft(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function parseModelTestRequestBodyDraft(
|
||||
draft: string,
|
||||
): { value: Record<string, unknown> | null; error: string | null } {
|
||||
return parseModelTestJsonObjectDraft(draft, {
|
||||
emptyValue: null,
|
||||
emptyError: '测试请求体不能为空',
|
||||
invalidTypeError: '测试请求体必须是 JSON 对象',
|
||||
})
|
||||
}
|
||||
|
||||
export function parseModelTestRequestHeadersDraft(
|
||||
draft: string,
|
||||
): { value: Record<string, unknown> | null; error: string | null } {
|
||||
return parseModelTestJsonObjectDraft(draft, {
|
||||
emptyValue: {},
|
||||
emptyError: null,
|
||||
invalidTypeError: '测试请求头必须是 JSON 对象',
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user