Interface NaruModelProtocol


public interface NaruModelProtocol
  • Method Details

    • chat

      NaruResponse chat(NaruModelRequest request, NaruTask task)
      Send a chat request with optional tool definitions.
      Returns:
      the model's response
    • getCapabilities

      NaruModelCapabilities getCapabilities()
    • chatStream

      default NaruResponse chatStream(NaruModelRequest request, NaruTask task, NaruStreamHandler handler)
      Send a chat request, delivering output as it is produced.

      The contract is deliberately the same for every protocol: the handler receives NaruStreamChunks and the call still returns one assembled NaruResponse. A protocol with no incremental transport therefore does not need to implement this at all -- the default replays a complete response as a short chunk sequence, so nothing downstream has to know whether the bytes actually arrived progressively.

      That is what lets a renderer, the transcript and the budget meter be written once against the streamed shape and work for a provider that cannot stream. The alternative, a separate code path per capability, is what this avoids.

      Parameters:
      handler - receives chunks as they arrive; may be null to stream purely for the assembled response
      Returns:
      the same response a non-streaming call would have produced
    • providerName

      default String providerName()
      This protocol's provider name, stamped onto chunks for provenance.

      May be null for a protocol that does not know it, in which case its chunks carry no provider rather than a fabricated one.

    • replayAsChunks

      static void replayAsChunks(String provider, NaruResponse response, NaruStreamHandler handler)
      Feeds an already-complete response through the chunk pipeline.

      Deliberately configured with no thinking delimiters: this protocol has already separated reasoning from the answer by whatever means it had, so rescanning the text for tags here could only re-interpret a decision that was already made -- and a model that merely mentions <think> in a legitimate answer would have its answer truncated.