ChatMessage#

class council.contexts.ChatMessage(message: str, kind: ChatMessageKind, data: Any | None = None, source: str = '', is_error: bool = False)[source]#

Bases: object

Represents a chat message.

__init__(message: str, kind: ChatMessageKind, data: Any | None = None, source: str = '', is_error: bool = False)[source]#

Initialize a new instance

Parameters:
  • message (str) – the message content as readable text

  • kind (ChatMessageKind) – the kind of message

  • data (Any) – structured data associated with the message, if any

  • source (str) – the source of the message, when it is generated by Council

  • is_error (bool) – is the message considered an error

static agent(message: str, data: Any | None = None, source: str = '', is_error: bool = False) ChatMessage[source]#
Helper function to create message of kind ChatMessageKind.Agent.

See ChatMessage.__init__() for details

static chain(message: str, data: Any | None = None, source: str = '', is_error: bool = False) ChatMessage[source]#
Helper function to create message of kind ChatMessageKind.Chain.

See ChatMessage.__init__() for details

property data: Any#

Returns the data, if any, associated with the message.

Return type:

Any

property is_error: bool#

Returns True if the message is an error, False otherwise

Return type:

bool

is_from_source(source: str) bool[source]#

Returns True if the message is of the given source, otherwise False

Parameters:

source

Returns:

property is_kind_agent: bool#

True if the kind is ChatMessageKind.Agent, otherwise False

Return type:

bool

property is_kind_chain: bool#

True if the kind is ChatMessageKind.Chain, otherwise False

Return type:

bool

property is_kind_skill: bool#

True if the kind is ChatMessageKind.Skill, otherwise False

Return type:

bool

property is_kind_user: bool#

True if the kind is ChatMessageKind.User, otherwise False

Return type:

bool

is_of_kind(kind: ChatMessageKind) bool[source]#

Returns True if the message is of the given kind, otherwise False

Return type:

bool

property is_ok: bool#

Returns True if the message is ok (not an error), False otherwise

Return type:

bool

property kind: ChatMessageKind#

The kind of message

Return type:

ChatMessageKind

property message: str#

The readable text message

Return type:

str

static skill(message: str, data: Any | None = None, source: str = '', is_error: bool = False) ChatMessage[source]#
Helper function to create message of kind ChatMessageKind.Skill.

See ChatMessage.__init__() for details

property source: str#

Returns the source of the message

Return type:

str

static user(message: str, data: Any | None = None, source: str = '', is_error: bool = False) ChatMessage[source]#
Helper function to create message of kind ChatMessageKind.User.

See ChatMessage.__init__() for details