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;
|
||||
Reference in new issue
Block a user