chatflock.base

Module Contents

chatflock.base.TOutputSchema
class chatflock.base.ChatParticipant(name)

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:

name (str)

name: str
on_new_chat_message(chat, message)
Parameters:
Return type:

None

on_chat_started(chat)
Parameters:

chat (Chat)

Return type:

None

on_chat_ended(chat)
Parameters:

chat (Chat)

Return type:

None

on_participant_joined_chat(chat, participant)
Parameters:
Return type:

None

on_participant_left_chat(chat, participant)
Parameters:
Return type:

None

__str__()
Return type:

str

detailed_str(level=0)
Parameters:

level (int)

Return type:

str

class chatflock.base.ActiveChatParticipant(name, symbol='👤', messages_hidden=False)

Bases: ChatParticipant

Helper class that provides a standard way to create an ABC using inheritance.

Parameters:
symbol: str
messages_hidden: bool = False
abstract respond_to_chat(chat)
Parameters:

chat (Chat)

Return type:

str

__str__()
Return type:

str

detailed_str(level=0)
Parameters:

level (int)

Return type:

str

class chatflock.base.ChatMessage

Bases: pydantic.BaseModel

id: int
sender_name: str
content: str
timestamp: datetime.datetime
class chatflock.base.ChatConductor

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract select_next_speaker(chat)
Parameters:

chat (Chat)

Return type:

Optional[ActiveChatParticipant]

get_chat_result(chat)
Parameters:

chat (Chat)

Return type:

str

prepare_chat(chat, **kwargs)
Parameters:
  • chat (Chat)

  • kwargs (Any)

Return type:

None

initiate_dialog(chat, initial_message=None, from_participant=None, **kwargs)
Parameters:
Return type:

str

start_chat(chat)
Parameters:

chat (Chat)

Return type:

None

end_chat(chat)
Parameters:

chat (Chat)

Return type:

None

class chatflock.base.ChatDataBackingStore

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract get_messages()
Return type:

List[ChatMessage]

abstract add_message(sender_name, content, timestamp=None)
Parameters:
Return type:

ChatMessage

abstract clear_messages()
Return type:

None

abstract get_active_participants()
Return type:

List[ActiveChatParticipant]

abstract get_non_active_participants()
Return type:

List[ChatParticipant]

abstract get_active_participant_by_name(name)
Parameters:

name (str)

Return type:

Optional[ActiveChatParticipant]

abstract get_non_active_participant_by_name(name)
Parameters:

name (str)

Return type:

Optional[ChatParticipant]

abstract add_participant(participant)
Parameters:

participant (ChatParticipant)

Return type:

None

abstract remove_participant(participant)
Parameters:

participant (ChatParticipant)

Return type:

None

abstract has_active_participant_with_name(participant_name)
Parameters:

participant_name (str)

Return type:

bool

abstract has_non_active_participant_with_name(participant_name)
Parameters:

participant_name (str)

Return type:

bool

class chatflock.base.ChatRenderer

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract render_new_chat_message(chat, message)
Parameters:
Return type:

None

class chatflock.base.GeneratedChatComposition
participants: Sequence[ChatParticipant]
participants_interaction_schema: str
class chatflock.base.ChatCompositionGenerator

Bases: abc.ABC

Helper class that provides a standard way to create an ABC using inheritance.

abstract generate_composition_for_chat(chat, goal, composition_suggestion=None, interaction_schema=None)
Parameters:
  • chat (Chat)

  • goal (str)

  • composition_suggestion (Optional[str])

  • interaction_schema (Optional[str])

Return type:

GeneratedChatComposition

class chatflock.base.Chat(backing_store, renderer, initial_participants=None, name=None, max_total_messages=None, hide_messages=False)
Parameters:
backing_store: ChatDataBackingStore
renderer: ChatRenderer
name: str | None = None
max_total_messages: int | None = None
hide_messages: bool = False
add_participant(participant)
Parameters:

participant (ChatParticipant)

Return type:

None

remove_participant(participant)
Parameters:

participant (ChatParticipant)

Return type:

None

add_message(sender_name, content)
Parameters:
  • sender_name (str)

  • content (str)

Return type:

None

get_messages()
Return type:

List[ChatMessage]

clear_messages()
get_active_participants()
Return type:

List[ActiveChatParticipant]

get_non_active_participants()
Return type:

List[ChatParticipant]

get_active_participant_by_name(name)
Parameters:

name (str)

Return type:

Optional[ActiveChatParticipant]

get_non_active_participant_by_name(name)
Parameters:

name (str)

Return type:

Optional[ChatParticipant]

has_active_participant_with_name(participant_name)
Parameters:

participant_name (str)

Return type:

bool

has_non_active_participant_with_name(participant_name)
Parameters:

participant_name (str)

Return type:

bool

property active_participants_str