Class MistralStreamParser
java.lang.Object
org.apache.camel.component.aws2.bedrock.runtime.stream.MistralStreamParser
- All Implemented Interfaces:
StreamResponseParser
Parser for Mistral AI model streaming responses
Mistral streaming response format: {"outputs": [{"text": "chunk", "stop_reason": null}]} {"outputs": [{"text": " more text", "stop_reason": null}]} {"outputs": [{"text": "", "stop_reason": "stop"}]}
-
Constructor Summary
Constructors -
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
-
Constructor Details
-
MistralStreamParser
public MistralStreamParser()
-
-
Method Details
-
extractText
Description copied from interface:StreamResponseParserExtract text content from a streaming chunk- Specified by:
extractTextin interfaceStreamResponseParser- 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
public String extractCompletionReason(String chunk) throws com.fasterxml.jackson.core.JsonProcessingException Description copied from interface:StreamResponseParserExtract the completion reason from a streaming chunk (if present)- Specified by:
extractCompletionReasonin interfaceStreamResponseParser- 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
public Integer extractTokenCount(String chunk) throws com.fasterxml.jackson.core.JsonProcessingException Description copied from interface:StreamResponseParserExtract the token count from a streaming chunk (if present)- Specified by:
extractTokenCountin interfaceStreamResponseParser- 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
Description copied from interface:StreamResponseParserCheck if this chunk represents the end of the stream- Specified by:
isFinalChunkin interfaceStreamResponseParser- Parameters:
chunk- the JSON chunk from the stream- Returns:
- true if this is the final chunk
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-