feat(anthropic): Add support for streaming thinking events#2800
Closed
apappascs wants to merge 1 commit intospring-projects:mainfrom
Closed
feat(anthropic): Add support for streaming thinking events#2800apappascs wants to merge 1 commit intospring-projects:mainfrom
apappascs wants to merge 1 commit intospring-projects:mainfrom
Conversation
ccfe43f to
f2fbcdd
Compare
apappascs
commented
Apr 18, 2025
| // @formatter:off | ||
| String response = ChatClient.create(this.chatModel).prompt() | ||
| .user("What's the weather like in San Francisco, Tokyo, and Paris? Use Celsius.") | ||
| .user("What's the weather like in San Francisco (California, USA), Tokyo (Japan), and Paris (France)? Use Celsius.") |
Contributor
Author
There was a problem hiding this comment.
update flaky test:
[ERROR] Failures:
[ERROR] AnthropicChatModelIT.functionCallTest:288
Expecting actual:
"<thinking>
To get the current weather for multiple locations, I would need to call the getCurrentWeather function multiple times, once for each city.
The getCurrentWeather function takes two required parameters:
- location (string): The city and state, e.g. "San Francisco, CA"
- unit (string): The temperature unit, either "C" or "F"
The user has provided 3 city names:
- San Francisco
- Tokyo
- Paris
However, they did not specify the state/country for each city. Since there could be multiple cities with the same name in different states or countries, the state/country is needed to uniquely identify the location.
The user did specify they want the temperature in Celsius, so the unit parameter can be set to "C".
Since the location parameter cannot be fully populated without more information, I will ask the user to clarify the state/country for each city before making the API calls.
</thinking>
To get the current weather for San Francisco, Tokyo and Paris, I'll need a bit more information. Could you please clarify the state or country for each city? For example:
San Francisco, CA, USA
Tokyo, Japan
Paris, France
Once I have the full location details, I'll be happy to look up the current weather in Celsius for each city."
to contain:
["30", "10", "15"]
but could not find:
["30", "10", "15"]
|
@apappascs any hope to get this in? |
Add necessary types and update stream processing to handle Anthropic's 'thinking' content blocks and deltas in streaming responses. This resolves an issue where an IllegalArgumentException was thrown for unhandled thinking event types. format Signed-off-by: Alexandros Pappas <apappascs@gmail.com>
f2fbcdd to
340ed13
Compare
markpollack
reviewed
Jun 11, 2025
| return true; | ||
| // Tool use streaming sequence ends with a CONTENT_BLOCK_STOP event. | ||
| // The logic relies on the state machine (isInsideTool flag) managed in | ||
| // chatCompletionStream to know if this stop event corresponds to a tool use. |
markpollack
reviewed
Jun 11, 2025
|
|
||
| System.out.println(response); | ||
| .chatCompletionEntity(ChatCompletionRequest.builder() | ||
| .model(AnthropicApi.ChatModel.CLAUDE_3_OPUS.getValue()) |
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(anthropic): Add support for streaming thinking events
Add necessary types and update stream processing to handle Anthropic's 'thinking' content blocks and deltas in streaming responses. This resolves an issue where an IllegalArgumentException was thrown for unhandled thinking event types.
example curl request and response:
response
resolves #2793