How can I get the thinking content using a thinking model?
When I use AzureOpenAI or OpenAI, how do I get the thinking content using a thinking model?
There is no relevant description in the springAI documentation。but when i use deepseek,i can get it:
List<Message> messages = new ArrayList<>();
messages.add(new UserMessage("9.11 and 9.8, which is greater?"));
DeepSeekChatOptions promptOptions = DeepSeekChatOptions.builder()
.model(DeepSeekApi.ChatModel.DEEPSEEK_REASONER.getValue())
.build();
Prompt prompt = new Prompt(messages, promptOptions);
ChatResponse response = chatModel.call(prompt);
DeepSeekAssistantMessage deepSeekAssistantMessage = (DeepSeekAssistantMessage) response.getResult().getOutput();
String reasoningContent = deepSeekAssistantMessage.getReasoningContent();
String text = deepSeekAssistantMessage.getText();
At present, there seems to be no way but to add fields to receive responses.
As far as I know, support for "thinking" is already in progress, and consideration is being given to how to support "thinking" in the model as a whole.
My suggestion is to introduce a new field in AssistantMessage and handle it the same as the toolCalls Property: not required, but possible to set by models that respond thinking tokens.
At the Moment the only class that extends this class is DeepSeekAssistantMessage
I'd be more than happy to suggest the changes in a pull request.
My suggestion is to introduce a new field in AssistantMessage and handle it the same as the toolCalls Property: not required, but possible to set by models that respond thinking tokens.
At the Moment the only class that extends this class is DeepSeekAssistantMessage
I'd be more than happy to suggest the changes in a pull request.
Since @markpollack mentioned that he's already exploring ways to support thinking as a whole(https://github.com/spring-projects/spring-ai/pull/3386#issuecomment-3130804866), I'd prefer to wait for his adjustments. Of course, you're always welcome to submit a PR!
Hi, was this feature already implemented or are still workarounds being used?