Class NaruAnthropicResponseParser

java.lang.Object
net.thevpc.naru.ext.models.anthropic.NaruAnthropicResponseParser
All Implemented Interfaces:
net.thevpc.nuts.elem.NElementDeserializer<NaruResponse>

public class NaruAnthropicResponseParser extends Object implements net.thevpc.nuts.elem.NElementDeserializer<NaruResponse>
Parses an Anthropic Messages API response:
 {
   "id": "msg_...",
   "type": "message",
   "role": "assistant",
   "content": [
     {"type": "text", "text": "Hello"},
     {"type": "tool_use", "id": "toolu_1", "name": "web_search", "input": {"q": "..."}}
   ],
   "stop_reason": "end_turn" | "tool_use" | "max_tokens" | "stop_sequence",
   "usage": {"input_tokens": 25, "output_tokens": 30}
 }
 
  • Constructor Details

    • NaruAnthropicResponseParser

      public NaruAnthropicResponseParser()
  • Method Details

    • toObject

      public NaruResponse toObject(net.thevpc.nuts.elem.NElementDeserializerContext context)
      Specified by:
      toObject in interface net.thevpc.nuts.elem.NElementDeserializer<NaruResponse>
    • parseInput

      public static Map<String,Object> parseInput(net.thevpc.nuts.elem.NElement inputEl)