Skip to content
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

[NA] fix gemini streaming #1106

Merged
merged 3 commits into from
Jan 22, 2025
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
@@ -7,6 +7,7 @@
import lombok.RequiredArgsConstructor;

import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

@RequiredArgsConstructor
@@ -27,9 +28,9 @@ public ChatCompletionResponse generate(@NonNull ChatCompletionRequest request, @
public void generateStream(@NonNull ChatCompletionRequest request, @NonNull String workspaceId,
@NonNull Consumer<ChatCompletionResponse> handleMessage, @NonNull Runnable handleClose,
@NonNull Consumer<Throwable> handleError) {
llmProviderClientGenerator.newGeminiStreamingClient(apiKey, request)
CompletableFuture.runAsync(() -> llmProviderClientGenerator.newGeminiStreamingClient(apiKey, request)
.generate(request.messages().stream().map(LlmProviderGeminiMapper.INSTANCE::toChatMessage).toList(),
new ChunkedResponseHandler(handleMessage, handleClose, handleError, request.model()));
new ChunkedResponseHandler(handleMessage, handleClose, handleError, request.model())));
}

@Override
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@
/// relevant test will be skipped for that provider.
/// - **Openai**: runs against a demo server and doesn't require an API key
/// - **Anthropic**: set `ANTHROPIC_API_KEY` to your anthropic api key
/// - **Gemini**: set `GEMINI_API_KEY` to your gemini api key
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
// Disabled because the tests require an API key to run and this seems to be failing in the CI pipeline
class ChatCompletionsResourceTest {
@@ -227,7 +228,7 @@ private static Stream<Arguments> testModelsProvider() {
arguments(AnthropicModelName.CLAUDE_3_5_SONNET_20240620.toString(), LlmProvider.ANTHROPIC,
System.getenv("ANTHROPIC_API_KEY")),
arguments(GeminiModelName.GEMINI_1_0_PRO.toString(), LlmProvider.GEMINI,
System.getenv("GEMINI_AI_KEY")));
System.getenv("GEMINI_API_KEY")));
}

@ParameterizedTest