Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/post-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: Revert pom.xml to ${{env.NEXT_VERSION}}
run: |
./mvnw versions:set -DnewVersion=${{env.NEXT_VERSION}}
./mvnw -f samples/pom.xml versions:use-dep-version -Dincludes=com.ibm.watsonx:watsonx-ai -DdepVersion=${{env.CURRENT_VERSION}} -DforceVersion=true
./mvnw -f samples/pom.xml versions:use-dep-version -Dincludes=com.ibm.watsonx:* -DdepVersion=${{env.CURRENT_VERSION}} -DforceVersion=true

- name: Commit revert
uses: ./.github/actions/commit-push
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
run: |
./mvnw versions:set -DnewVersion=${{env.CURRENT_VERSION}}
./mvnw versions:set -f samples/pom.xml -DnewVersion=${{env.CURRENT_VERSION}}
./mvnw -f samples/pom.xml versions:use-dep-version -Dincludes=com.ibm.watsonx:* -DdepVersion=${{env.CURRENT_VERSION}} -DforceVersion=true

- name: Update SDK version in docusaurus.config.ts
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,44 @@ public CompletableFuture<ChatResponse> chatStreaming(ChatRequest chatRequest, Ch
return client.chatStreaming(transactionId, textChatRequest, context, handler);
}

/**
* Sends a streaming chat request.
*
* @param chatRequest the {@link ChatRequest}
* @param onResponse a consumer that receives partial response tokens
* @return a {@link CompletableFuture} that completes with the final {@link ChatResponse}
*/
public CompletableFuture<ChatResponse> chatStreaming(ChatRequest chatRequest, Consumer<String> onResponse) {
return chatStreaming(chatRequest, new ChatHandler() {
@Override
public void onPartialResponse(String partialResponse, PartialChatResponse partialChatResponse) {
onResponse.accept(partialResponse);
}
});
}

/**
* Sends a streaming chat request, delivering response and reasoning tokens to separate consumers.
*
* @param chatRequest the {@link ChatRequest}
* @param onResponse a consumer that receives partial response tokens
* @param onThinking a consumer that receives partial reasoning tokens
* @return a {@link CompletableFuture} that completes with the final {@link ChatResponse}
*/
public CompletableFuture<ChatResponse> chatStreaming(ChatRequest chatRequest, Consumer<String> onResponse, Consumer<String> onThinking) {
return chatStreaming(chatRequest, new ChatHandler() {
@Override
public void onPartialResponse(String partialResponse, PartialChatResponse partialChatResponse) {
onResponse.accept(partialResponse);
}

@Override
public void onPartialThinking(String partialThinking, PartialChatResponse partialChatResponse) {
onThinking.accept(partialThinking);
}
});
}

/**
* Sends a chat request to the model using the provided message.
*
Expand Down Expand Up @@ -265,7 +303,7 @@ public CompletableFuture<ChatResponse> chatStreaming(String message, ChatHandler
* @param handler a {@link ChatHandler} implementation
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, ChatHandler handler) {
return chatStreaming(messages, ChatParameters.builder().build(), handler);
return chatStreaming(messages, (ChatParameters) null, handler);
}

/**
Expand All @@ -276,7 +314,7 @@ public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages,
* @param handler a {@link ChatHandler} implementation
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, List<Tool> tools, ChatHandler handler) {
return chatStreaming(messages, null, tools, handler);
return chatStreaming(messages, (ChatParameters) null, tools, handler);
}

/**
Expand All @@ -287,27 +325,59 @@ public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages,
* @param handler a {@link ChatHandler} implementation
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, ChatParameters parameters, ChatHandler handler) {
return chatStreaming(messages, parameters, null, handler);
return chatStreaming(messages, parameters, (List<Tool>) null, handler);
}

/**
* Sends a chat request to the model using the provided message.
* Sends a streaming chat request using the provided message.
*
* @param message Message to send.
* @param handler a consumer that receives partial text responses
* @param message the message to send
* @param onResponse a consumer that receives partial response tokens
*/
public CompletableFuture<ChatResponse> chatStreaming(String message, Consumer<String> handler) {
return chatStreaming(List.of(UserMessage.text(message)), handler);
public CompletableFuture<ChatResponse> chatStreaming(String message, Consumer<String> onResponse) {
return chatStreaming(List.of(UserMessage.text(message)), onResponse);
}

/**
* Sends a streaming chat request using the provided messages.
*
* @param messages the list of chat messages forming the prompt history
* @param handler a consumer that receives partial text responses
* @param onResponse a consumer that receives partial response tokens
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, Consumer<String> onResponse) {
return chatStreaming(messages, (ChatParameters) null, onResponse);
}

/**
* Sends a streaming chat request using the provided message, delivering response and reasoning tokens to separate consumers.
*
* @param message the message to send
* @param onResponse a consumer that receives partial response tokens
* @param onThinking a consumer that receives partial reasoning tokens
*/
public CompletableFuture<ChatResponse> chatStreaming(String message, Consumer<String> onResponse, Consumer<String> onThinking) {
return chatStreaming(List.of(UserMessage.text(message)), onResponse, onThinking);
}

/**
* Sends a streaming chat request using the provided messages, delivering response and reasoning tokens to separate consumers.
*
* @param messages the list of chat messages forming the prompt history
* @param onResponse a consumer that receives partial response tokens
* @param onThinking a consumer that receives partial reasoning tokens
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, Consumer<String> handler) {
return chatStreaming(messages, ChatParameters.builder().build(), handler);
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, Consumer<String> onResponse, Consumer<String> onThinking) {
return chatStreaming(messages, (ChatParameters) null, (List<Tool>) null, new ChatHandler() {
@Override
public void onPartialResponse(String partialResponse, PartialChatResponse partialChatResponse) {
onResponse.accept(partialResponse);
}

@Override
public void onPartialThinking(String partialThinking, PartialChatResponse partialChatResponse) {
onThinking.accept(partialThinking);
}
});
}

/**
Expand All @@ -318,7 +388,7 @@ public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages,
* @param handler a consumer that receives partial text responses
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, ChatParameters parameters, Consumer<String> handler) {
return chatStreaming(messages, parameters, null, handler);
return chatStreaming(messages, parameters, (List<Tool>) null, handler);
}

/**
Expand All @@ -329,7 +399,7 @@ public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages,
* @param handler a consumer that receives partial text responses
*/
public CompletableFuture<ChatResponse> chatStreaming(List<ChatMessage> messages, List<Tool> tools, Consumer<String> handler) {
return chatStreaming(messages, null, tools, handler);
return chatStreaming(messages, (ChatParameters) null, tools, handler);
}

/**
Expand Down
Loading
Loading