Class OpenAiStreamFunctionCallingHelper
java.lang.Object
org.springframework.ai.openai.api.OpenAiStreamFunctionCallingHelper
Helper class to support Streaming function calling.
It can merge the streamed ChatCompletionChunk in case of function calling message.
- Since:
- 0.8.1
- Author:
- Christian Tzolov
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConvert the ChatCompletionChunk into a ChatCompletion.boolean
isStreamingToolFunctionCall
(OpenAiApi.ChatCompletionChunk chatCompletion) boolean
isStreamingToolFunctionCallFinish
(OpenAiApi.ChatCompletionChunk chatCompletion) merge
(OpenAiApi.ChatCompletionChunk previous, OpenAiApi.ChatCompletionChunk current) Merge the previous and current ChatCompletionChunk into a single one.
-
Constructor Details
-
OpenAiStreamFunctionCallingHelper
public OpenAiStreamFunctionCallingHelper()
-
-
Method Details
-
merge
public OpenAiApi.ChatCompletionChunk merge(OpenAiApi.ChatCompletionChunk previous, OpenAiApi.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
-