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