domain¶
Responsibility¶
Immutable value types shared by every other package: conversation input, players and their spans, coalition masks, generations, estimand labels, and the generation and runtime settings backends and the runtime read.
No input or output and no backend.
Public surface¶
TextPart(text),AudioPart(source, sample_rate)(sourceis a path or bytes;data()reads it),ContentPartunion (Message).Message(role, text=... | content=..., speaker=None):contentis a tuple of parts;textjoins the text parts with spaces;with_text(text)replaces the text parts and keeps audio and speaker;with_audio(audio)replaces the first audio part.Message.speakermust be a non-empty single line (speaker).Turn(messages);ConversationSnapshot(turns, snapshot_id)(Snapshot):from_turnsderivessnapshot_id(first 16 hex characters of a SHA-256 over every message; text-only messages hash role and text as before 0.1.18, other messages hash every part, audio by the SHA-256 of its bytes; a speaker is hashed only when set);messages()flattens the turns.ConversationSnapshot.from_json(text)/to_json(indent=2)with theSnapshotPayload,TurnPayload,MessagePayloadTypedDicts:{"turns": [{"messages": [{"role", "text" or "content", "speaker"?}]}]}plus an optionalsnapshot_idwhen it is not the content-derived one.contentlistsPartPayloadparts:text, oraudiowithsample_rateand eitherpath(resolved againstfrom_json(base_dir=...)) or base64data; shape errors raiseTypeError, bad JSON, roles or empty turns raiseValueError.PlayerSpan(message_index, start, end, text, speaker=None, label=None, samples=None)withdisplay_label;samplesis the[start, end)sample range of an audio player (Player span);PlayerSet(player_ids, spans=(), hidden_text=())withnum_players;hidden_textlists messages whose text policies drop (alignment-only transcripts).CoalitionMask(present):from_sequence,coalition_size(),validate_against(player_set)(masking).GenerationRecord:text,text_token_rows,audio_token_rows,logprobs(Nonewhen the backend returned none),embedding,contextual_embedding.domain/config.py:GenerationConfig(max_new_tokens=128, temperature=0.0, top_k=1, compute_embeddings=False),DedupConfig(enabled="auto"),KvCacheConfig(enabled=False, max_entries=8); also importable frommllm_shap.pipeline.config.Estimand(shapley,banzhaf),EstimandWire,estimand_to_wire(Estimand);Role(user,assistant,system) andRoleName, the same values as aLiteralfor plugin options (roles,text_roles);EmbeddingMode(static,contextual);CooperativeGame(player_set).
Data flow¶
Invariants¶
Every type is frozen; snapshots, turns, player sets and masks reject empty construction.
Snapshot ids of text-only conversations did not change in 0.1.18; two snapshots with the same text and different audio get different ids.
PlayerSet.spans, when present, has one span per player id, in player order.
Known issues¶
Audio parts reach the
transformersaudio models, theapibackend andmock_audio(backends).