Bug description
When calling DeepSeek using the stream approach and tools are invoked, the org.springframework.ai.deepseek.api.DeepSeekStreamFunctionCallingHelper#merge
method returns a NoSuchElementException: null exception.
Analysis
An exception was thrown on line 98. The previous stream returned a tool call. The current stream returns an array of tool calls, which is an empty array rather than null. So the current.toolCalls().iterator().next()
will throw an NoSuchElementException.
I think the judgement on line 94 should be current.toolCalls() != null && !current.toolCalls().isEmpty()
Environment
Spring AI version: 1.0.3
Java Version: 21
DeepSeek v3.1
Expected behavior
Return tools successfully. Don't throw exception.