Interface StreamResponseParser
- All Known Implementing Classes:
ClaudeStreamParser,CohereStreamParser,LlamaStreamParser,MistralStreamParser,TitanStreamParser
public interface StreamResponseParser
Parser interface for extracting text and metadata from streaming responses of different Bedrock models
-
Method Summary
Modifier and TypeMethodDescriptionextractCompletionReason(String chunk) Extract the completion reason from a streaming chunk (if present)extractText(String chunk) Extract text content from a streaming chunkextractTokenCount(String chunk) Extract the token count from a streaming chunk (if present)booleanisFinalChunk(String chunk) Check if this chunk represents the end of the stream
-
Method Details
-
extractText
Extract text content from a streaming chunk- Parameters:
chunk- the JSON chunk from the stream- Returns:
- the extracted text content, or empty string if no text in this chunk
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
extractCompletionReason
String extractCompletionReason(String chunk) throws com.fasterxml.jackson.core.JsonProcessingException Extract the completion reason from a streaming chunk (if present)- Parameters:
chunk- the JSON chunk from the stream- Returns:
- the completion reason, or null if not present in this chunk
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
extractTokenCount
Extract the token count from a streaming chunk (if present)- Parameters:
chunk- the JSON chunk from the stream- Returns:
- the token count, or null if not present in this chunk
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
isFinalChunk
Check if this chunk represents the end of the stream- Parameters:
chunk- the JSON chunk from the stream- Returns:
- true if this is the final chunk
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-