Utterance

class convokit.model.utterance.Utterance(owner=None, id: Optional[str] = None, speaker: Optional[convokit.model.speaker.Speaker] = None, conversation_id: Optional[str] = None, reply_to: Optional[str] = None, timestamp: Optional[int] = None, text: str = '', meta: Optional[Dict] = None, ai_meta: Optional[Dict] = None)

Represents a single utterance in the dataset.

Parameters
  • id – the unique id of the utterance.

  • speaker – the speaker giving the utterance.

  • conversation_id – the id of the root utterance of the conversation.

  • reply_to – id of the utterance this was a reply to.

  • timestamp – timestamp of the utterance. Can be any comparable type.

  • text – text of the utterance.

  • ai_meta –

    additional outputs from the speaker’s LLM call for this message (empty if there are none or the speaker is not an AI; see AI_FORMAT.md). Recognized keys:

    • "config": the generation config used to generate the message

    • "supports": list of Supports attached to this utterance

    An "ai_meta" entry in meta (as in a dumped corpus) is moved into this attribute, unless this argument is given.

Variables
  • id – the unique id of the utterance.

  • speaker – the speaker giving the utterance.

  • conversation_id – the id of the root utterance of the conversation.

  • reply_to – id of the utterance this was a reply to.

  • timestamp – timestamp of the utterance.

  • text – text of the utterance.

  • meta – A dictionary-like view object providing read-write access to utterance-level metadata.

  • ai_meta – AI metadata of the utterance. Unlike the other classes, assigning replaces the existing ai_meta instead of merging into it.

  • supports – the Supports attached to this utterance

add_meta(key: str, value) → None

Adds a key-value pair to the metadata of the corpus object

Parameters
  • key – name of metadata attribute

  • value – value of metadata attribute

Returns

None

add_vector(vector_name: str)

Logs in the Corpus component object’s internal vectors list that the component object has a vector row associated with it in the vector matrix named vector_name.

Transformers that add vectors to the Corpus should use this to update the relevant component objects during the transform() step.

Parameters

vector_name – name of vector matrix

Returns

None

property ai_meta

The AI metadata of this utterance.

delete_vector(vector_name: str)

Delete a vector associated with this Corpus component object.

Parameters

vector_name –

Returns

None

get_conversation()

Get the Conversation (identified by Utterance.conversation_id) this Utterance belongs to

Returns

a Conversation object

get_speaker()

Get the Speaker that made this Utterance.

Returns

a Speaker object

get_transcript(supports: bool = False) → str

Get a plain-text transcript of this utterance’s Conversation, from its beginning up to and including this utterance. See Conversation.get_transcript.

Parameters

supports – whether to include Supports (Supports replying to this utterance come after it, so they are not included)

Returns

the transcript as a single string

Raises

ValueError – if the utterance is not part of a Corpus

get_vector(vector_name: str, as_dataframe: bool = False, columns: Optional[List[str]] = None)

Get the vector stored as vector_name for this object.

Parameters
  • vector_name – name of vector

  • as_dataframe – whether to return the vector as a dataframe (True) or in its raw array form (False). False by default.

  • columns – optional list of named columns of the vector to include. All columns returned otherwise. This parameter is only used if as_dataframe is set to True

Returns

a numpy / scipy array

retrieve_meta(key: str)

Retrieves a value stored under the key of the metadata of corpus object

Parameters

key – name of metadata attribute

Returns

value

property supports

The Supports attached to this utterance (a new list; assign to modify).