Delete try/catch block in step
This commit is contained in:
@@ -4,9 +4,11 @@ import ch.qos.logback.classic.Logger;
|
||||
import com.olympus.hermione.models.ScenarioExecution;
|
||||
import com.olympus.hermione.utility.AttributeParser;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.tika.Tika;
|
||||
import org.apache.tika.exception.TikaException;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.transformer.splitter.TokenTextSplitter;
|
||||
@@ -20,8 +22,6 @@ public class EmbeddingDocTempSolver extends StepSolver {
|
||||
private int min_chunk_length_to_embed;
|
||||
private int max_num_chunks;
|
||||
|
||||
|
||||
|
||||
Logger logger = (Logger) LoggerFactory.getLogger(EmbeddingDocTempSolver.class);
|
||||
|
||||
private void loadParameters() {
|
||||
@@ -69,7 +69,6 @@ public class EmbeddingDocTempSolver extends StepSolver {
|
||||
@Override
|
||||
public ScenarioExecution solveStep() {
|
||||
|
||||
try{
|
||||
logger.info("Solving step: " + this.step.getName());
|
||||
this.scenarioExecution.setCurrentStepId(this.step.getStepId());
|
||||
logger.info("Loading parameters for step: {}", this.step.getName());
|
||||
@@ -79,13 +78,20 @@ public class EmbeddingDocTempSolver extends StepSolver {
|
||||
logger.info("Reading file from path: {}", this.path_file);
|
||||
Tika tika = new Tika();
|
||||
tika.setMaxStringLength(-1);
|
||||
String text = tika.parseToString(file);
|
||||
String text;
|
||||
try {
|
||||
text = tika.parseToString(file);
|
||||
} catch (IOException | TikaException e) {
|
||||
logger.error("Error parsing file: ", e);
|
||||
throw new RuntimeException("Error parsing file", e);
|
||||
}
|
||||
logger.info("File read successfully. Length: {} characters", text.length());
|
||||
Document myDoc = new Document(text);
|
||||
|
||||
List<Document> docs = Collections.singletonList(myDoc);
|
||||
|
||||
logger.info("Initializing TokenTextSplitter with default_chunk_size={}, min_chunk_size={}, min_chunk_length_to_embed={}, max_num_chunks={}",
|
||||
logger.info(
|
||||
"Initializing TokenTextSplitter with default_chunk_size={}, min_chunk_size={}, min_chunk_length_to_embed={}, max_num_chunks={}",
|
||||
this.default_chunk_size, this.min_chunk_size, this.min_chunk_length_to_embed, this.max_num_chunks);
|
||||
TokenTextSplitter splitter = new TokenTextSplitter(this.default_chunk_size,
|
||||
this.min_chunk_size,
|
||||
@@ -120,11 +126,6 @@ public class EmbeddingDocTempSolver extends StepSolver {
|
||||
});
|
||||
logger.info("All documents embedded and added to vector store successfully");
|
||||
|
||||
}catch (Exception e){
|
||||
logger.error("Error while solvingStep: "+e.getMessage(), e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
logger.info("Setting next step id: {}", this.step.getNextStepId());
|
||||
this.scenarioExecution.setNextStepId(this.step.getNextStepId());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user