Skip to content

fix(streaming): Remove retry wrapper from chat model stream methods #3524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -323,8 +323,7 @@ public Flux<ChatResponse> stream(Prompt prompt) {
return Flux.deferContextual(contextView -> {
ChatCompletionRequest request = createRequest(requestPrompt, true);

Flux<ChatCompletionChunk> completionChunks = this.retryTemplate
.execute(ctx -> this.miniMaxApi.chatCompletionStream(request));
Flux<ChatCompletionChunk> completionChunks = this.miniMaxApi.chatCompletionStream(request);

// For chunked responses, only the first chunk contains the choice role.
// The rest of the chunks with same ID share the same role.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Optional;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand Down Expand Up @@ -115,6 +116,7 @@ public void miniMaxChatNonTransientError() {
}

@Test
@Disabled
public void miniMaxChatStreamTransientError() {

var choice = new ChatCompletionChunk.ChunkChoice(ChatCompletionFinishReason.STOP, 0,
Expand All @@ -136,6 +138,7 @@ public void miniMaxChatStreamTransientError() {
}

@Test
@Disabled
public void miniMaxChatStreamNonTransientError() {
given(this.miniMaxApi.chatCompletionStream(isA(ChatCompletionRequest.class)))
.willThrow(new RuntimeException("Non Transient Error"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ public Flux<ChatResponse> internalStream(Prompt prompt, ChatResponse previousCha

observation.parentObservation(contextView.getOrDefault(ObservationThreadLocalAccessor.KEY, null)).start();

Flux<ChatCompletionChunk> completionChunks = this.retryTemplate
.execute(ctx -> this.mistralAiApi.chatCompletionStream(request));
Flux<ChatCompletionChunk> completionChunks = this.mistralAiApi.chatCompletionStream(request);

// For chunked responses, only the first chunk contains the choice role.
// The rest of the chunks with same ID share the same role.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,7 @@ public Flux<ChatResponse> stream(Prompt prompt) {
Prompt requestPrompt = buildRequestPrompt(prompt);
ChatCompletionRequest request = createRequest(requestPrompt, true);

Flux<ChatCompletionChunk> completionChunks = this.retryTemplate
.execute(ctx -> this.zhiPuAiApi.chatCompletionStream(request));
Flux<ChatCompletionChunk> completionChunks = this.zhiPuAiApi.chatCompletionStream(request);

// For chunked responses, only the first chunk contains the choice role.
// The rest of the chunks with same ID share the same role.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Optional;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
Expand Down Expand Up @@ -128,6 +129,7 @@ public void zhiPuAiChatNonTransientError() {
}

@Test
@Disabled
public void zhiPuAiChatStreamTransientError() {

var choice = new ChatCompletionChunk.ChunkChoice(ChatCompletionFinishReason.STOP, 0,
Expand All @@ -149,6 +151,7 @@ public void zhiPuAiChatStreamTransientError() {
}

@Test
@Disabled
public void zhiPuAiChatStreamNonTransientError() {
given(this.zhiPuAiApi.chatCompletionStream(isA(ChatCompletionRequest.class)))
.willThrow(new RuntimeException("Non Transient Error"));
Expand Down