feat: complete docs navigation and media task metadata
This commit is contained in:
1 parent
c445dd035f
commit
9b98de3efa
4 files changed
+46
-10
No files matched your search
+4
-3
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
|
||||
/** Real async adapters for the providers currently represented in the catalog. */
|
||||
@Service
|
||||
public class AsyncProviderClient {
|
||||
private static final Duration UPSTREAM_REQUEST_TIMEOUT = Duration.ofSeconds(60);
|
||||
private final JdbcTemplate jdbc;
|
||||
private final SecretCipher cipher;
|
||||
private final ObjectMapper mapper;
|
||||
@@ -208,7 +209,7 @@ public class AsyncProviderClient {
|
||||
|
||||
private Map<String,Object> requestAudio(String method, String url, String key, Map<String,Object> body, String message) {
|
||||
try {
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(URI.create(url)).timeout(Duration.ofSeconds(30))
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(URI.create(url)).timeout(UPSTREAM_REQUEST_TIMEOUT)
|
||||
.header("Authorization", "Bearer " + key).header("Content-Type", "application/json");
|
||||
HttpResponse<byte[]> response = client.send(builder.POST(HttpRequest.BodyPublishers.ofString(write(body))).build(), HttpResponse.BodyHandlers.ofByteArray());
|
||||
if (response.statusCode() < 200 || response.statusCode() >= 300) {
|
||||
@@ -253,7 +254,7 @@ public class AsyncProviderClient {
|
||||
multipartFile(out, boundary, fileField, file.filename(), file.contentType(), file.bytes());
|
||||
}
|
||||
out.write(("--" + boundary + "--\r\n").getBytes(java.nio.charset.StandardCharsets.UTF_8));
|
||||
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).timeout(Duration.ofSeconds(30))
|
||||
HttpRequest request = HttpRequest.newBuilder().uri(URI.create(url)).timeout(UPSTREAM_REQUEST_TIMEOUT)
|
||||
.header("Authorization", "Bearer " + key)
|
||||
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
|
||||
.POST(HttpRequest.BodyPublishers.ofByteArray(out.toByteArray())).build();
|
||||
@@ -335,7 +336,7 @@ public class AsyncProviderClient {
|
||||
|
||||
private Map<String,Object> request(String method, String url, String key, Map<String,Object> body, String message) {
|
||||
try {
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(URI.create(url)).timeout(Duration.ofSeconds(30))
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder().uri(URI.create(url)).timeout(UPSTREAM_REQUEST_TIMEOUT)
|
||||
.header("Authorization", "Bearer " + key).header("Content-Type", "application/json");
|
||||
if ("POST".equals(method)) builder.POST(HttpRequest.BodyPublishers.ofString(write(body)));
|
||||
else builder.GET();
|
||||
|
||||
@@ -187,12 +187,8 @@ public class AsyncTaskService {
|
||||
String taskId = String.valueOf(task.get("id"));
|
||||
usage.updateTask(taskId, "running", null, null, null);
|
||||
try {
|
||||
Map<String,Object> upstream = providerClient.submit(
|
||||
String.valueOf(task.get("provider_id")),
|
||||
String.valueOf(task.get("upstream_model")),
|
||||
String.valueOf(task.get("task_type")),
|
||||
taskInput(task)
|
||||
);
|
||||
Map<String,Object> input = taskInput(task);
|
||||
Map<String,Object> upstream = submitProviderTask(task, input);
|
||||
// Some OpenAI-compatible image/audio endpoints return the
|
||||
// generated media in the submit response rather than creating
|
||||
// a pollable job. Persist that result and settle the task in
|
||||
@@ -320,6 +316,19 @@ public class AsyncTaskService {
|
||||
return input;
|
||||
}
|
||||
|
||||
private Map<String,Object> submitProviderTask(Map<String,Object> task, Map<String,Object> input) {
|
||||
String providerId = String.valueOf(task.get("provider_id"));
|
||||
String model = String.valueOf(task.get("upstream_model"));
|
||||
String type = String.valueOf(task.get("task_type"));
|
||||
// Keep the legacy overload for rows created before V30. Apart from
|
||||
// compatibility with existing integrations, this makes a queued
|
||||
// prompt-only task indistinguishable from the original submit path.
|
||||
if (input.size() == 1 && input.containsKey("prompt")) {
|
||||
return providerClient.submit(providerId, model, type, String.valueOf(input.get("prompt")));
|
||||
}
|
||||
return providerClient.submit(providerId, model, type, input);
|
||||
}
|
||||
|
||||
private OffsetDateTime now() { return OffsetDateTime.now(ZoneOffset.UTC); }
|
||||
|
||||
private String providerTaskId(Map<String,Object> response) {
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
-- Tripo H-series routes accept either a text prompt or an image URL/file token.
|
||||
-- Keep the catalog metadata aligned with the async adapter so clients can
|
||||
-- expose the image input without guessing from the model type.
|
||||
UPDATE model_definitions
|
||||
SET input_types = '["text", "image"]'::jsonb,
|
||||
updated_at = now()
|
||||
WHERE model_key IN ('tripo-v3', 'tripo-h-v3-0', 'tripo-h-v2-5')
|
||||
AND deleted_at IS NULL;
|
||||
|
||||
UPDATE model_catalog
|
||||
SET input_types = '["text", "image"]'::jsonb,
|
||||
updated_at = now()
|
||||
WHERE provider_id = 'provider-vast'
|
||||
AND upstream_model IN ('v3.1-20260211', 'v3.0-20250812', 'v2.5-20250123')
|
||||
AND deleted_at IS NULL;
|
||||
@@ -130,6 +130,17 @@ const projects = ref<CatalogProject[]>([])
|
||||
const keyScopeType = ref<'personal' | 'project'>('personal')
|
||||
const selectedProjectId = ref('')
|
||||
const selectedApiKeyId = ref('')
|
||||
function scrollDocs(target: string) {
|
||||
const selectors: Record<string, string> = {
|
||||
'docs-overview': '.docs-layout',
|
||||
'docs-auth': '.docs-path-card',
|
||||
'docs-chat': '.docs-detail-grid .docs-detail-card:nth-child(2)',
|
||||
'docs-reference': '.docs-reference-table',
|
||||
'docs-troubleshooting': '.docs-detail-grid .docs-detail-card:last-child',
|
||||
'docs-usage': '.docs-guide-extra',
|
||||
}
|
||||
document.querySelector(selectors[target] || target)?.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||
}
|
||||
const activeDebugKeys = computed(() => keys.value.filter((key) => key.status === '正常'))
|
||||
const selectedDebugKey = computed(() => activeDebugKeys.value.find((key) => String(key.id) === selectedApiKeyId.value))
|
||||
const debugKeyCanInvoke = computed(() => !!selectedDebugKey.value?.modelIds.includes(activeModel.value.id))
|
||||
@@ -771,7 +782,7 @@ async function createProject() {
|
||||
|
||||
<template v-else>
|
||||
<section class="page-heading"><div><span>DEVELOPER DOCS</span><h1>接入文档</h1><p>使用标准接口把模型能力接入你的应用。</p></div><button class="button secondary" @click="copy(platformApiBaseUrl, 'Base URL', 'docs-base-url')"><Check v-if="copySucceeded('docs-base-url')" :size="16" /><Copy v-else :size="16" />{{ copySucceeded('docs-base-url') ? '已复制' : copyStates['docs-base-url'] === 'failed' ? '复制失败' : '复制 Base URL' }}</button></section>
|
||||
<section class="docs-layout"><aside class="docs-menu panel"><span>快速开始</span><button class="active">概览</button><button>认证与 API Key</button><button>标准对话接口</button><button>异步任务</button><button>错误码与重试</button><span>API 参考</span><button>模型列表</button><button>用量查询</button></aside><article class="docs-content panel"><span class="eyebrow">QUICK START</span><h2>三分钟完成第一次调用</h2><p>只需要统一 API 地址、API Key 和模型名称,即可开始使用模亦灵枢。</p><section><b>01</b><div><h3>准备接入信息</h3><p>在用户端创建 API Key,并保存以下环境变量。</p><pre><code>MOYI_BASE_URL={{ platformApiBaseUrl }}
|
||||
<section id="docs-overview" class="docs-layout"><aside class="docs-menu panel"><span>快速开始</span><button class="active" type="button" @click="scrollDocs('docs-overview')">概览</button><button type="button" @click="scrollDocs('docs-auth')">认证与 API Key</button><button type="button" @click="scrollDocs('docs-chat')">标准对话接口</button><button type="button" @click="scrollDocs('docs-reference')">异步任务</button><button type="button" @click="scrollDocs('docs-troubleshooting')">错误码与重试</button><span>API 参考</span><button type="button" @click="scrollDocs('docs-reference')">模型列表</button><button type="button" @click="scrollDocs('docs-usage')">用量查询</button></aside><article class="docs-content panel"><span class="eyebrow">QUICK START</span><h2>三分钟完成第一次调用</h2><p>只需要统一 API 地址、API Key 和模型名称,即可开始使用模亦灵枢。</p><section><b>01</b><div><h3>准备接入信息</h3><p>在用户端创建 API Key,并保存以下环境变量。</p><pre><code>MOYI_BASE_URL={{ platformApiBaseUrl }}
|
||||
MOYI_API_KEY=sk-moyi-your-key
|
||||
MOYI_MODEL=<model-id></code></pre></div></section><section><b>02</b><div><h3>发送标准请求</h3><p>文本模型支持同步和流式响应;3D、图像、视频使用异步任务接口。</p><pre><code>curl {{ platformApiBaseUrl }}/chat/completions \
|
||||
-H "Authorization: Bearer $MOYI_API_KEY" \
|
||||
|
||||
Reference in new issue
Block a user