Fix an issue related to the Azure OpenAI streamig response
This issue in the Flux streaming logic was causing chunks to be aggreagated in a single response. Re-enable the AzureOpenAiAutoConfigurationIT
This commit is contained in:
@@ -183,8 +183,8 @@ public class AzureOpenAiChatModel
|
||||
isFunctionCall.set(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, false)
|
||||
return !isFunctionCall.get();
|
||||
})
|
||||
.concatMapIterable(window -> {
|
||||
final var reduce = window.reduce(MergeUtils.emptyChatCompletions(), MergeUtils::mergeChatCompletions);
|
||||
return List.of(reduce);
|
||||
|
||||
@@ -80,6 +80,29 @@ class OpenAiChatModelIT extends AbstractIT {
|
||||
// needs fine tuning... evaluateQuestionAndAnswer(request, response, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void streamRoleTest() {
|
||||
UserMessage userMessage = new UserMessage(
|
||||
"Tell me about 3 famous pirates from the Golden Age of Piracy and what they did.");
|
||||
SystemPromptTemplate systemPromptTemplate = new SystemPromptTemplate(systemResource);
|
||||
Message systemMessage = systemPromptTemplate.createMessage(Map.of("name", "Bob", "voice", "pirate"));
|
||||
Prompt prompt = new Prompt(List.of(userMessage, systemMessage));
|
||||
Flux<ChatResponse> flux = streamingChatModel.stream(prompt);
|
||||
|
||||
List<ChatResponse> responses = flux.collectList().block();
|
||||
assertThat(responses.size()).isGreaterThan(1);
|
||||
|
||||
String stitchedResponseContent = responses.stream()
|
||||
.map(ChatResponse::getResults)
|
||||
.flatMap(List::stream)
|
||||
.map(Generation::getOutput)
|
||||
.map(AssistantMessage::getContent)
|
||||
.collect(Collectors.joining());
|
||||
|
||||
assertThat(stitchedResponseContent).contains("Blackbeard");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void listOutputConverter() {
|
||||
DefaultConversionService conversionService = new DefaultConversionService();
|
||||
|
||||
Reference in New Issue
Block a user