interlens.participant¶
interlens.participant
¶
Participant
¶
Bases: ABC
A participant in a conversation, either a model or a person.
A participant owns three things: an identity within the conversation (name + self_role/
others_role), its private framing (system_prompt + private_context — instructions/knowledge
only it sees), and the ability to turn a rendered view into its next message (generate). The
Conversation assembles the structured view from the shared transcript; the participant flattens that view
to what its chat template expects via finalize_view and generates.
name
instance-attribute
¶
A name or identifier to uniquely identify this participant within a conversation.
finalize_view
¶
Flatten the structured, context-fitted view into the [{role, content}] list the chat template
consumes. Applies family-specific repairs driven by the capability flags:
supports_system_role=False→ fold the leading system content into the first user turn (Gemma's template errors on a standalonesystemrole).requires_alternating_roles=True→ merge consecutive same-role segments (Gemma requires strict user/model alternation; the moderator seed + another speaker + private context can otherwise produce consecutiveuserturns that the template rejects). Merged turns keep author labels so speaker identity isn't lost in the concatenation.
Source code in src/interlens/participant/participant.py
generate
abstractmethod
¶
generate(
view: list[dict],
*,
steering=None,
capture=None,
patch=None,
return_logprobs: bool = False,
turn: int | None = None,
max_new_tokens: int | None = None
) -> Message
Produce this participant's next message given view — the conversation flattened to
[{"role", "content"}] from this participant's perspective. Returns a Message it authored.
Interp options apply to local-model participants: steering (a SteeringSpec), capture (a
CaptureRequest), patch (a Patch), and return_logprobs; turn is the message index used
to tag captured activations. Participants that can't honor an interp request (e.g. API-backed) must raise
rather than silently ignore it — a failed capture/steer must fail loudly.