Class ZhiPuAiStreamFunctionCallingHelper
java.lang.Object
org.springframework.ai.zhipuai.api.ZhiPuAiStreamFunctionCallingHelper
Helper class to support Streaming function calling. It can merge the streamed
ChatCompletionChunk in case of function calling message.
- Since:
- 1.0.0 M1
- Author:
- Geng Rong
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionConvert the ChatCompletionChunk into a ChatCompletion.boolean
isStreamingToolFunctionCall
(ZhiPuAiApi.ChatCompletionChunk chatCompletion) boolean
isStreamingToolFunctionCallFinish
(ZhiPuAiApi.ChatCompletionChunk chatCompletion) merge
(ZhiPuAiApi.ChatCompletionChunk previous, ZhiPuAiApi.ChatCompletionChunk current) Merge the previous and current ChatCompletionChunk into a single one.
-
Constructor Details
-
ZhiPuAiStreamFunctionCallingHelper
public ZhiPuAiStreamFunctionCallingHelper()
-
-
Method Details
-
merge
public ZhiPuAiApi.ChatCompletionChunk merge(ZhiPuAiApi.ChatCompletionChunk previous, ZhiPuAiApi.ChatCompletionChunk current) Merge the previous and current ChatCompletionChunk into a single one.- Parameters:
previous
- the previous ChatCompletionChunkcurrent
- the current ChatCompletionChunk- Returns:
- the merged ChatCompletionChunk
-
isStreamingToolFunctionCall
- Parameters:
chatCompletion
- the ChatCompletionChunk to check- Returns:
- true if the ChatCompletionChunk is a streaming tool function call.
-
isStreamingToolFunctionCallFinish
- Parameters:
chatCompletion
- the ChatCompletionChunk to check- Returns:
- true if the ChatCompletionChunk is a streaming tool function call and it is the last one.
-
chunkToChatCompletion
Convert the ChatCompletionChunk into a ChatCompletion. The Usage is set to null.- Parameters:
chunk
- the ChatCompletionChunk to convert- Returns:
- the ChatCompletion
-