Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.springframework.util.MimeTypeUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;

@SpringBootTest(classes = OpenAiTestConfiguration.class)
@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+")
Expand Down Expand Up @@ -235,9 +236,18 @@ void beanStreamOutputConverterRecords() {
.stream()
.filter(cr -> cr.getResult() != null)
.map(cr -> cr.getResult().getOutput().getText())
.filter(text -> text != null && !text.trim().isEmpty()) // Filter out empty/null text
.collect(Collectors.joining());
// @formatter:on

// Add debugging to understand what text we're trying to parse
logger.debug("Aggregated streaming text: {}", generationTextFromStream);

// Ensure we have valid JSON before attempting conversion
if (generationTextFromStream.trim().isEmpty()) {
fail("Empty aggregated text from streaming response - this indicates a problem with streaming aggregation");
}

ActorsFilms actorsFilms = outputConverter.convert(generationTextFromStream);

logger.info("" + actorsFilms);
Expand Down