fix
This commit is contained in:
@@ -26,7 +26,6 @@ public class GeminiVideoGenerationService {
|
|||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(GeminiVideoGenerationService.class);
|
private static final Logger logger = LoggerFactory.getLogger(GeminiVideoGenerationService.class);
|
||||||
|
|
||||||
// ИЗМЕНЕНИЕ 1: Правильный эндпоинт для видео (PredictLongRunning)
|
|
||||||
private static final String VERTEX_API_TEMPLATE = "https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:predictLongRunning";
|
private static final String VERTEX_API_TEMPLATE = "https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/publishers/google/models/%s:predictLongRunning";
|
||||||
private static final String CREDENTIALS_FILE_PATH = "keys/google-key.json";
|
private static final String CREDENTIALS_FILE_PATH = "keys/google-key.json";
|
||||||
|
|
||||||
@@ -88,11 +87,20 @@ public class GeminiVideoGenerationService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String operationName = (String) initResponse.get("name");
|
String rawOperationName = (String) initResponse.get("name");
|
||||||
logger.info("VEO: Задача успешно принята Google. ID операции: {}", operationName);
|
logger.info("VEO: Задача успешно принята Google. Сырой ID: {}", rawOperationName);
|
||||||
|
|
||||||
// ШАГ 2: Цикл опроса (Polling)
|
// =================================================================
|
||||||
String operationUrl = String.format("https://%s-aiplatform.googleapis.com/v1/%s", location, operationName);
|
// ШАГ 2: ФИКС БАГА GOOGLE CLOUD
|
||||||
|
// Вырезаем чистый ID операции и собираем каноничный Vertex URL
|
||||||
|
// =================================================================
|
||||||
|
String operationId = rawOperationName.substring(rawOperationName.lastIndexOf("/") + 1);
|
||||||
|
String cleanOperationPath = String.format("projects/%s/locations/%s/operations/%s", projectId, location, operationId);
|
||||||
|
String operationUrl = String.format("https://%s-aiplatform.googleapis.com/v1/%s", location, cleanOperationPath);
|
||||||
|
|
||||||
|
logger.info("VEO: Сформирован ПРАВИЛЬНЫЙ URL для проверки: {}", operationUrl);
|
||||||
|
|
||||||
|
// ШАГ 3: Цикл опроса (Polling)
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
int maxAttempts = 60; // Максимум 15 минут (60 попыток по 15 сек)
|
int maxAttempts = 60; // Максимум 15 минут (60 попыток по 15 сек)
|
||||||
|
|
||||||
@@ -103,7 +111,7 @@ public class GeminiVideoGenerationService {
|
|||||||
|
|
||||||
Map<String, Object> statusResponse = webClient.get()
|
Map<String, Object> statusResponse = webClient.get()
|
||||||
.uri(URI.create(operationUrl))
|
.uri(URI.create(operationUrl))
|
||||||
.header("Authorization", "Bearer " + getAccessTokenFromResources()) // Обновляем токен
|
.header("Authorization", "Bearer " + getAccessTokenFromResources()) // Обязательно обновляем токен
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {})
|
.bodyToMono(new ParameterizedTypeReference<Map<String, Object>>() {})
|
||||||
.block(Duration.ofSeconds(30));
|
.block(Duration.ofSeconds(30));
|
||||||
@@ -116,7 +124,7 @@ public class GeminiVideoGenerationService {
|
|||||||
|
|
||||||
Boolean isDone = (Boolean) statusResponse.get("done");
|
Boolean isDone = (Boolean) statusResponse.get("done");
|
||||||
if (Boolean.TRUE.equals(isDone)) {
|
if (Boolean.TRUE.equals(isDone)) {
|
||||||
logger.info("VEO: 🔥 Видео готово! Скачиваем результат...");
|
logger.info("VEO: 🔥 ВИДЕО ГОТОВО! Скачиваем результат...");
|
||||||
Map<String, Object> responseObj = (Map<String, Object>) statusResponse.get("response");
|
Map<String, Object> responseObj = (Map<String, Object>) statusResponse.get("response");
|
||||||
return extractVideoFromResponse(responseObj);
|
return extractVideoFromResponse(responseObj);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user