Class GPULlama3ResponseParser
java.lang.Object
dev.langchain4j.model.gpullama3.GPULlama3ResponseParser
Utility class for parsing GPULlama3 model responses that contain thinking content.
GPULlama3 models can generate responses with embedded thinking content in the format: <think>thinking content...</think>actual response content
This parser separates the thinking content from the actual response content for both complete responses and streaming responses, while preserving the thinking tags.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents the parsed components of a GPULlama3 model response.static class
Parser for handling streaming responses with real-time thinking content separation. -
Method Summary
Modifier and TypeMethodDescriptioncreateStreamingParser
(StreamingChatResponseHandler handler, org.beehive.gpullama3.model.Model model) Creates a new streaming parser for real-time thinking content separation.static String
extractResponse
(String rawResponse) Convenience method to extract only the cleaned response content.static String
extractThinking
(String rawResponse) Convenience method to extract only the thinking content from a response.parseResponse
(String rawResponse) Parses a raw GPULlama3 response to separate thinking content from actual response.
-
Method Details
-
parseResponse
Parses a raw GPULlama3 response to separate thinking content from actual response. Preserves the thinking tags in the thinking content.- Parameters:
rawResponse
- the raw response from the model- Returns:
- ParsedResponse containing separated thinking and response content
- Throws:
IllegalArgumentException
- if rawResponse is null
-
extractThinking
-
extractResponse
-
createStreamingParser
public static GPULlama3ResponseParser.StreamingParser createStreamingParser(StreamingChatResponseHandler handler, org.beehive.gpullama3.model.Model model) Creates a new streaming parser for real-time thinking content separation.- Parameters:
handler
- the streaming response handlermodel
- the GPULlama3 model instance for token decoding- Returns:
- a new StreamingThinkingParser instance
-