target fix
This commit is contained in:
@@ -3,7 +3,6 @@ package kz.konturai.parser.service;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import kz.konturai.parser.exception.ClaudeApiException;
|
||||
import kz.konturai.parser.model.CampaignPrediction;
|
||||
import kz.konturai.parser.model.TargetingCampaign;
|
||||
import kz.konturai.parser.repository.CampaignPredictionRepository;
|
||||
@@ -24,7 +23,7 @@ import java.util.Optional;
|
||||
@Slf4j
|
||||
public class CampaignPredictionService {
|
||||
|
||||
private final ClaudeApiService claudeApiService;
|
||||
private final OpenAIAnalyticsService openAiService;
|
||||
private final CampaignPredictionRepository predictionRepository;
|
||||
private final TargetingCampaignRepository campaignRepository;
|
||||
private final ObjectMapper objectMapper;
|
||||
@@ -93,7 +92,15 @@ public class CampaignPredictionService {
|
||||
String userMessage = buildUserMessage(campaign);
|
||||
|
||||
try {
|
||||
String rawJson = claudeApiService.call(SYSTEM_PROMPT, userMessage, 4000);
|
||||
String rawJson = openAiService.generateWithInstructionWithModel(
|
||||
"",
|
||||
userMessage,
|
||||
"ru",
|
||||
"gpt-4o",
|
||||
SYSTEM_PROMPT,
|
||||
4000,
|
||||
120000L
|
||||
);
|
||||
CampaignPrediction prediction = parsePrediction(rawJson, campaign.getId());
|
||||
|
||||
// Снимаем флаг isLatest со старых предсказаний
|
||||
@@ -108,9 +115,9 @@ public class CampaignPredictionService {
|
||||
prediction.getPredictionScore(), prediction.getPredictionLabel());
|
||||
return prediction;
|
||||
|
||||
} catch (ClaudeApiException e) {
|
||||
log.error("[Prediction] Ошибка Claude API: {}", e.getMessage());
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
log.error("[Prediction] Ошибка OpenAI API: {}", e.getMessage());
|
||||
throw new RuntimeException("Ошибка генерации предсказания: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
public class ClaudeApiService {
|
||||
|
||||
private static final String CLAUDE_MODEL = "claude-sonnet-4-20250514";
|
||||
private static final int MAX_RETRIES = 3;
|
||||
private static final Duration TIMEOUT = Duration.ofSeconds(60);
|
||||
private static final String CLAUDE_MODEL = "claude-sonnet-4-5";
|
||||
private static final int MAX_RETRIES = 2;
|
||||
private static final Duration TIMEOUT = Duration.ofSeconds(90);
|
||||
|
||||
private final WebClient webClient;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
Reference in New Issue
Block a user