feat: display latency when testing model connection (#6258)
Co-authored-by: RhoninSeiei <RhoninSeiei@users.noreply.github.com>
This commit is contained in:
@@ -590,9 +590,11 @@ export function useProviderSources(options: UseProviderSourcesOptions) {
|
||||
async function testProvider(provider: any) {
|
||||
testingProviders.value.push(provider.id)
|
||||
try {
|
||||
const startTime = performance.now()
|
||||
const response = await axios.get('/api/config/provider/check_one', { params: { id: provider.id } })
|
||||
if (response.data.status === 'ok' && response.data.data.error === null) {
|
||||
showMessage(tm('models.testSuccess', { id: provider.id }))
|
||||
const latency = Math.max(0, Math.round(performance.now() - startTime))
|
||||
showMessage(tm('models.testSuccessWithLatency', { id: provider.id, latency }))
|
||||
} else {
|
||||
throw new Error(response.data.data.error || tm('models.testError'))
|
||||
}
|
||||
|
||||
@@ -132,6 +132,7 @@
|
||||
"deleteSuccess": "Model deleted successfully",
|
||||
"deleteError": "Failed to delete model",
|
||||
"testSuccess": "Model {id} test passed",
|
||||
"testSuccessWithLatency": "Model {id} test passed, latency {latency} ms",
|
||||
"testError": "Model test failed",
|
||||
"searchPlaceholder": "Search models or ID",
|
||||
"manualAddButton": "Custom Model",
|
||||
|
||||
@@ -133,6 +133,7 @@
|
||||
"deleteSuccess": "模型删除成功",
|
||||
"deleteError": "模型删除失败",
|
||||
"testSuccess": "模型 {id} 测试通过",
|
||||
"testSuccessWithLatency": "模型 {id} 测试通过,延迟 {latency} ms",
|
||||
"testError": "模型测试失败",
|
||||
"searchPlaceholder": "搜索模型或 ID",
|
||||
"manualAddButton": "自定义模型",
|
||||
|
||||
@@ -602,12 +602,15 @@ async function testSingleProvider(provider) {
|
||||
return
|
||||
}
|
||||
|
||||
const startTime = performance.now()
|
||||
const res = await axios.get(`/api/config/provider/check_one?id=${provider.id}`)
|
||||
if (res.data && res.data.status === 'ok') {
|
||||
const index = providerStatuses.value.findIndex(s => s.id === provider.id)
|
||||
if (index !== -1) {
|
||||
providerStatuses.value.splice(index, 1, res.data.data)
|
||||
}
|
||||
const latency = Math.max(0, Math.round(performance.now() - startTime))
|
||||
showMessage(tm('models.testSuccessWithLatency', { id: provider.id, latency }))
|
||||
} else {
|
||||
throw new Error(res.data?.message || `Failed to check status for ${provider.id}`)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user