Source code for nlp_shap.protocols.backend
"""Generative backend protocol."""
from typing import Protocol
from ..domain.conversation import ConversationSnapshot
[docs]
class GenerationResult(Protocol):
"""Minimal generation output consumed by value functions."""
@property
def text(self) -> str:
"""Return the generated text payload."""
[docs]
class GenerativeBackend(Protocol):
"""Execute model generation for a masked conversation snapshot."""
@property
def model_id(self) -> str:
"""Return the backend model identifier."""
[docs]
async def generate(
self,
snapshot: ConversationSnapshot,
max_new_tokens: int,
temperature: float,
top_k: int,
) -> GenerationResult:
"""Generate model output for the given snapshot."""