Refactor error handling and logging in ApplicationBrowserService; clean up unused code in ApplicationService; streamline message handling in AdvancedAIPromptSolver and SourceCodeRagSolver
This commit is contained in:
@@ -51,21 +51,17 @@ public class ApplicationBrowserService {
|
||||
}
|
||||
|
||||
public ResponseEntity<Object> getProgressRev(String processId) {
|
||||
logger.info("getProgressRev function:");
|
||||
|
||||
ResponseEntity<Object> responseEntity = null;
|
||||
ResponseEntity<Object> responseEntity = null;
|
||||
|
||||
try {
|
||||
// Chiama il metodo getProcessStatus e memorizza il risultato
|
||||
responseEntity = javaREModule.getProcessStatus(processId);
|
||||
try {
|
||||
// Chiama il metodo getProcessStatus e memorizza il risultato
|
||||
responseEntity = javaREModule.getProcessStatus(processId);
|
||||
} catch (Exception e) {
|
||||
// In caso di eccezione
|
||||
logger.error("Exception in getProgressRev: {}", e.getMessage());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// In caso di eccezione
|
||||
logger.error("Exception in getProgressRev: {}", e.getMessage());
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
return responseEntity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.olympus.hermione.repository.ApplicationRepository;
|
||||
import com.olympus.hermione.repository.ProjectRepository;
|
||||
import com.olympus.hermione.security.entity.User;
|
||||
import com.olympus.model.Application;
|
||||
import com.olympus.model.Project;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,19 +25,9 @@ public class ApplicationService {
|
||||
List<Application> lstApp = null;
|
||||
User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
|
||||
// lstApp = appRepo.findByProjectId(principal.getSelectedProject());
|
||||
|
||||
//List<ObjectId> objectIds = convertToObjectIdList(principal.getSelected_progect());
|
||||
|
||||
//List<Project> lstProject = projectRepo.findAllById(objectIds);
|
||||
|
||||
logger.info("getListProjectByIds function:");
|
||||
|
||||
/* Application all = new Application();
|
||||
all.setFE_name("ALL");
|
||||
all.setInternal_name("ALL");
|
||||
all.setId(new ObjectId("ALL"));
|
||||
lstApp.add(all);*/
|
||||
|
||||
return lstApp;
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ScenarioExecutionService {
|
||||
scenarioExecution.setScenario(scenario);
|
||||
}
|
||||
|
||||
chatModel = createChatModel(aiModel);
|
||||
ChatModel chatModel = createChatModel(aiModel);
|
||||
|
||||
scenarioExecutionRepository.save(scenarioExecution);
|
||||
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package com.olympus.hermione.stepSolvers;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.azure.openai.metadata.AzureOpenAiUsage;
|
||||
import org.springframework.ai.chat.client.ChatClient.CallResponseSpec;
|
||||
import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.metadata.Usage;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.olympus.hermione.dto.aientity.CiaOutputEntity;
|
||||
import com.olympus.hermione.models.ScenarioExecution;
|
||||
import com.olympus.hermione.utility.AttributeParser;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.chat.client.ChatClient.CallResponseSpec;
|
||||
import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.metadata.Usage;
|
||||
|
||||
public class AdvancedAIPromptSolver extends StepSolver {
|
||||
|
||||
@@ -66,38 +62,18 @@ public class AdvancedAIPromptSolver extends StepSolver {
|
||||
|
||||
String userText = this.qai_user_input;
|
||||
|
||||
logger.info("Using model " + chatModel.getDefaultOptions().getModel());
|
||||
|
||||
CallResponseSpec resp=null;
|
||||
|
||||
|
||||
if( chatModel.getDefaultOptions().getModel().contains("o1-") ){
|
||||
//Non funziona
|
||||
logger.info("Using o1- model => " + chatModel.getDefaultOptions().getModel());
|
||||
|
||||
String completePrompt = this.qai_system_prompt_template + userText;
|
||||
|
||||
resp = chatClient.prompt()
|
||||
.messages(new UserMessage(completePrompt))
|
||||
.advisors(advisor -> advisor
|
||||
.param("chat_memory_conversation_id", this.scenarioExecution.getId()+this.qai_custom_memory_id)
|
||||
.param("chat_memory_response_size", 100))
|
||||
.call();
|
||||
|
||||
}else{
|
||||
logger.info("Using standard model=> " + chatModel.getDefaultOptions().getModel());
|
||||
|
||||
Message userMessage = new UserMessage(userText);
|
||||
Message systemMessage = new SystemMessage(this.qai_system_prompt_template);
|
||||
|
||||
resp = chatClient.prompt()
|
||||
.messages(userMessage,systemMessage)
|
||||
.advisors(advisor -> advisor
|
||||
.param("chat_memory_conversation_id", this.scenarioExecution.getId()+this.qai_custom_memory_id)
|
||||
.param("chat_memory_response_size", 100))
|
||||
.call();
|
||||
}
|
||||
|
||||
Message userMessage = new UserMessage(userText);
|
||||
Message systemMessage = new SystemMessage(this.qai_system_prompt_template);
|
||||
|
||||
CallResponseSpec resp = chatClient.prompt()
|
||||
.messages(userMessage,systemMessage)
|
||||
.advisors(advisor -> advisor
|
||||
.param("chat_memory_conversation_id", this.scenarioExecution.getId()+this.qai_custom_memory_id)
|
||||
.param("chat_memory_response_size", 100))
|
||||
.call();
|
||||
|
||||
|
||||
Usage usage = resp.chatResponse().getMetadata().getUsage();
|
||||
|
||||
|
||||
@@ -2,18 +2,14 @@ package com.olympus.hermione.stepSolvers;
|
||||
|
||||
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import com.olympus.dto.CodeRagResponse;
|
||||
import com.olympus.dto.SimilaritySearchCodeInput;
|
||||
import com.olympus.hermione.models.ScenarioExecution;
|
||||
import com.olympus.hermione.utility.AttributeParser;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectWriter;
|
||||
|
||||
import com.olympus.hermione.models.ScenarioExecution;
|
||||
import com.olympus.hermione.utility.AttributeParser;
|
||||
import com.olympus.dto.CodeRagResponse;
|
||||
import com.olympus.dto.SimilaritySearchCodeInput;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
|
||||
public class SourceCodeRagSolver extends StepSolver {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user