Skip to content
Closed
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
@@ -1,5 +1,5 @@
/*
* Copyright 2023-2024 the original author or authors.
* Copyright 2023-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -57,6 +57,7 @@
* @author Alexandros Pappas
* @author Claudio Silva Junior
* @author Soby Chacko
* @author Sun Yuhan
* @since 1.0.0
*/
public class StreamHelper {
Expand All @@ -83,7 +84,9 @@ public boolean isToolUseFinish(StreamEvent event) {
*/
public StreamEvent mergeToolUseEvents(StreamEvent previousEvent, StreamEvent event) {

ToolUseAggregationEvent eventAggregator = (ToolUseAggregationEvent) previousEvent;
if (!(previousEvent instanceof ToolUseAggregationEvent eventAggregator)) {
return event;
}

if (event.type() == EventType.CONTENT_BLOCK_START) {
ContentBlockStartEvent contentBlockStart = (ContentBlockStartEvent) event;
Expand Down Expand Up @@ -161,7 +164,7 @@ else if (event.type().equals(EventType.CONTENT_BLOCK_START)) {
}
else if (contentBlockStartEvent.contentBlock() instanceof ContentBlockThinking thinkingBlock) {
ContentBlock cb = new ContentBlock(Type.THINKING, null, null, contentBlockStartEvent.index(), null,
null, null, null, null, null, thinkingBlock.thinking(), null, null);
null, null, null, null, thinkingBlock.signature(), thinkingBlock.thinking(), null, null);
contentBlockReference.get().withType(event.type().name()).withContent(List.of(cb));
}
else {
Expand Down
Loading