完善文档页文本向量与重排序调用支持

This commit is contained in:
2026-05-31 21:18:41 +08:00
parent 8ee7a7969e
commit 644a6f9d17
24 changed files with 1945 additions and 71 deletions
+19 -5
View File
@@ -540,7 +540,7 @@ export function App() {
try {
const response = await createApiKey(token, {
name: apiKeyForm.name,
scopes: ['chat', 'image', 'video'],
scopes: ['chat', 'embedding', 'rerank', 'image', 'video'],
expiresAt: apiKeyForm.expiresAt ? new Date(apiKeyForm.expiresAt).toISOString() : undefined,
});
setApiKeySecret(response.secret);
@@ -907,11 +907,20 @@ export function App() {
async function submitTask(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
const credential = apiKeySecret || token;
const selectedApiKeySecret = selectedPlaygroundApiKeyId ? apiKeySecretsById[selectedPlaygroundApiKeyId] ?? '' : '';
const fallbackApiKeySecret = apiKeys.find((item) => Boolean(apiKeySecretsById[item.id]))?.id;
const credential = selectedApiKeySecret || (fallbackApiKeySecret ? apiKeySecretsById[fallbackApiKeySecret] : '') || apiKeySecret || token;
const credentialLabel = selectedApiKeySecret || fallbackApiKeySecret || apiKeySecret ? '本地 API Key' : '当前 Access Token';
setCoreState('loading');
setCoreMessage('');
try {
const response = await runTask(credential, taskForm);
if (response.localOnly) {
setTaskResult(response.task);
setCoreState('ready');
setCoreMessage(`${taskForm.kind} 已通过 ${credentialLabel} 完成 simulation。`);
return;
}
const syncTask = (detail: GatewayTask) => {
setTaskResult(detail);
setTasks((current) => [detail, ...current.filter((item) => item.id !== detail.id)]);
@@ -921,7 +930,7 @@ export function App() {
setTasks((current) => [detail, ...current.filter((item) => item.id !== detail.id)]);
invalidateDataKeys('tasks', 'wallet', 'walletTransactions');
setCoreState('ready');
setCoreMessage(`${taskForm.kind} 已通过 ${apiKeySecret ? '本地 API Key' : '当前 Access Token'} 完成 simulation。`);
setCoreMessage(`${taskForm.kind} 已通过 ${credentialLabel} 完成 simulation。`);
} catch (err) {
setCoreState('error');
setCoreMessage(err instanceof Error ? err.message : '测试任务失败');
@@ -1170,12 +1179,16 @@ export function App() {
{activePage === 'docs' && (
<ApiDocsPage
activeDocSection={apiDocSection}
apiKeySecret={apiKeySecret}
apiKeySecretsById={apiKeySecretsById}
apiKeys={apiKeys}
canRun={isAuthenticated}
coreMessage={coreMessage}
coreState={coreState}
selectedApiKeyId={selectedPlaygroundApiKeyId}
taskForm={taskForm}
taskResult={taskResult}
onApiKeyChange={setSelectedPlaygroundApiKeyId}
onCreateApiKey={openApiKeyCreation}
onDocSectionChange={navigateApiDocSection}
onLogin={showLogin}
onSubmitTask={submitTask}
@@ -1318,7 +1331,8 @@ function dataKeysForRoute(
? ['modelCatalog']
: ['publicCatalog'];
}
if (activePage === 'home' || activePage === 'docs') return [];
if (activePage === 'docs') return isAuthenticated ? ['playgroundApiKeys'] : [];
if (activePage === 'home') return [];
if (!isAuthenticated) return [];
if (activePage === 'workspace') {