Skip to content

interlens.view

interlens.view

ViewSegment dataclass

ViewSegment(
    role: Role,
    content: str,
    origin: Origin,
    author: str | None = None,
)

One entry in a participant's structured view, before it is flattened to the [{role, content}] shape a chat template consumes.

Carrying origin (and author for turns) through the pipeline is the whole point: it keeps the semantic identity of each piece intact so context-trimming and author-labelling can act on it, rather than reverse-engineering meaning out of already-folded text.

as_message

as_message() -> dict

Flatten to the {"role", "content"} dict a chat template expects.

Source code in src/interlens/view.py
def as_message(self) -> dict:
	"""Flatten to the ``{"role", "content"}`` dict a chat template expects."""
	return {"role": self.role, "content": self.content}