Merge branch 'master' of https://gitlab.gcp.windtre.it/olympus_ai/hermione
This commit is contained in:
@@ -24,7 +24,6 @@ public class Scenario {
|
||||
private String startWithStepId;
|
||||
private List<ScenarioStep> steps;
|
||||
private List<ScenarioInputs> inputs;
|
||||
private String modelId;
|
||||
private String visible;
|
||||
|
||||
|
||||
@@ -32,7 +31,11 @@ public class Scenario {
|
||||
private List<Project> availableForProjects;
|
||||
@DocumentReference
|
||||
private List<Project> availableForApplications;
|
||||
@DocumentReference
|
||||
private AiModel aiModel;
|
||||
|
||||
private boolean useChatMemory=false;
|
||||
private String outputType;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.olympus.hermione.models;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
@@ -33,4 +34,7 @@ public class ScenarioExecution {
|
||||
private String latestStepOutput;
|
||||
|
||||
private ScenarioExecutionInput scenarioExecutionInput;
|
||||
|
||||
private Date startDate;
|
||||
private Date endDate;
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ import org.springframework.data.mongodb.repository.MongoRepository;
|
||||
|
||||
@Repository
|
||||
public interface AiModelRepository extends MongoRepository<AiModel, String>{
|
||||
Optional <AiModel> findByIsDefault(Boolean isDefault);
|
||||
AiModel findByIsDefault(Boolean isDefault);
|
||||
}
|
||||
|
||||
@@ -127,19 +127,22 @@ public class ScenarioExecutionService {
|
||||
Scenario scenario = o_scenario.get();
|
||||
|
||||
logger.info("Start execution of scenario: " + scenario.getName());
|
||||
scenarioExecution.setStartDate(new java.util.Date());
|
||||
|
||||
HashMap<String, Object> execSharedMap = new HashMap<String, Object>();
|
||||
execSharedMap.put("user_input", inputs);
|
||||
scenarioExecution.setExecSharedMap(execSharedMap);
|
||||
scenarioExecutionRepository.save(scenarioExecution);
|
||||
|
||||
Optional<AiModel> o_aiModel;
|
||||
if(scenario.getModelId() != null){
|
||||
o_aiModel = aiModelRepository.findById(scenario.getModelId());
|
||||
AiModel aiModel;
|
||||
if(scenario.getAiModel() != null){
|
||||
aiModel = scenario.getAiModel();
|
||||
}else {
|
||||
o_aiModel = aiModelRepository.findByIsDefault(true);
|
||||
}
|
||||
AiModel aiModel = o_aiModel.get();
|
||||
aiModel = aiModelRepository.findByIsDefault(true);
|
||||
//scenario.setAiModel(aiModel);
|
||||
//scenarioRepository.save(scenario);
|
||||
}
|
||||
|
||||
ChatModel chatModel = createChatModel(aiModel);
|
||||
|
||||
if(scenario.isUseChatMemory()){
|
||||
@@ -180,6 +183,9 @@ public class ScenarioExecutionService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
scenarioExecution.setEndDate(new java.util.Date());
|
||||
scenarioExecutionRepository.save(scenarioExecution);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,12 +240,10 @@ public class ScenarioExecutionService {
|
||||
scenarioExecutionNew.setNextStepId(null);
|
||||
scenarioExecutionNew.setLatestStepStatus("ERROR");
|
||||
scenarioExecutionNew.setLatestStepOutput(e.getMessage());
|
||||
|
||||
}
|
||||
|
||||
|
||||
scenarioExecutionRepository.save(scenarioExecutionNew);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user