message
¶
AIMessage
¶
AIMessage(
content: Any = None,
*,
role: Optional[MessageRole] = None,
tool_calls: Optional[List[ToolCall]] = None,
**kwargs: Any
)
Bases: BaseMessage
An assistant message in the conversation.
Source code in src/appl/core/message.py
get_content
¶
Get the content of the message.
Materialize the content if it is a FutureValue.
Source code in src/appl/core/message.py
get_dict
¶
get_dict(
default_role: Optional[MessageRole] = None,
) -> Dict[str, Any]
Return a dict representation of the message.
Source code in src/appl/core/message.py
merge
¶
merge(other: 'BaseMessage') -> Optional['Message']
Merge the message with another message.
Source code in src/appl/core/message.py
should_merge
¶
should_merge(other: 'BaseMessage') -> bool
Whether the message should be merged with the other message.
Source code in src/appl/core/message.py
str_with_default_role
¶
str_with_default_role(
default_role: Optional[MessageRole] = None,
) -> str
Return the string representation of the message with default role.
validate_role
¶
validate_role(target_role: MessageRole) -> None
Validate the role of the message, fill the role if not provided.
Source code in src/appl/core/message.py
BaseMessage
¶
Bases: BaseModel
, ABC
The base class for messages.
Provides a more flexible way to create a message.
Source code in src/appl/core/message.py
get_content
¶
Get the content of the message.
Materialize the content if it is a FutureValue.
Source code in src/appl/core/message.py
get_dict
¶
get_dict(
default_role: Optional[MessageRole] = None,
) -> Dict[str, Any]
Return a dict representation of the message.
Source code in src/appl/core/message.py
merge
¶
merge(other: 'BaseMessage') -> Optional['Message']
Merge the message with another message.
Source code in src/appl/core/message.py
should_merge
¶
should_merge(other: 'BaseMessage') -> bool
Whether the message should be merged with the other message.
Source code in src/appl/core/message.py
str_with_default_role
¶
str_with_default_role(
default_role: Optional[MessageRole] = None,
) -> str
Return the string representation of the message with default role.
validate_role
¶
validate_role(target_role: MessageRole) -> None
Validate the role of the message, fill the role if not provided.
Source code in src/appl/core/message.py
ChatMessage
¶
ChatMessage(
content: Any = None,
*,
role: Optional[MessageRole] = None,
**kwargs: Any
)
Bases: BaseMessage
A message in the chat conversation.
Source code in src/appl/core/message.py
get_content
¶
Get the content of the message.
Materialize the content if it is a FutureValue.
Source code in src/appl/core/message.py
get_dict
¶
get_dict(
default_role: Optional[MessageRole] = None,
) -> Dict[str, Any]
Return a dict representation of the message.
Source code in src/appl/core/message.py
merge
¶
merge(other: 'BaseMessage') -> Optional['Message']
Merge the message with another message.
Source code in src/appl/core/message.py
should_merge
¶
should_merge(other: 'BaseMessage') -> bool
Whether the message should be merged with the other message.
Source code in src/appl/core/message.py
str_with_default_role
¶
str_with_default_role(
default_role: Optional[MessageRole] = None,
) -> str
Return the string representation of the message with default role.
validate_role
¶
validate_role(target_role: MessageRole) -> None
Validate the role of the message, fill the role if not provided.
Source code in src/appl/core/message.py
Conversation
¶
Bases: BaseModel
A conversation containing messages.
append
¶
Append a message to the conversation.
Source code in src/appl/core/message.py
as_list
¶
Return a list of dict representation of the conversation.
Source code in src/appl/core/message.py
collapse
¶
Collapse the messages in the conversation.
Source code in src/appl/core/message.py
extend
¶
Extend the conversation with another conversation.
make_copy
¶
materialize
¶
pop
¶
pop() -> BaseMessage
set_system_messages
¶
set_system_messages(messages: List[SystemMessage]) -> None
SystemMessage
¶
SystemMessage(
content: Any = None,
*,
role: Optional[MessageRole] = None,
**kwargs: Any
)
Bases: BaseMessage
A system message in the conversation.
Source code in src/appl/core/message.py
get_content
¶
Get the content of the message.
Materialize the content if it is a FutureValue.
Source code in src/appl/core/message.py
get_dict
¶
get_dict(
default_role: Optional[MessageRole] = None,
) -> Dict[str, Any]
Return a dict representation of the message.
Source code in src/appl/core/message.py
merge
¶
merge(other: 'BaseMessage') -> Optional['Message']
Merge the message with another message.
Source code in src/appl/core/message.py
should_merge
¶
should_merge(other: 'BaseMessage') -> bool
Whether the message should be merged with the other message.
Source code in src/appl/core/message.py
str_with_default_role
¶
str_with_default_role(
default_role: Optional[MessageRole] = None,
) -> str
Return the string representation of the message with default role.
validate_role
¶
validate_role(target_role: MessageRole) -> None
Validate the role of the message, fill the role if not provided.
Source code in src/appl/core/message.py
ToolMessage
¶
ToolMessage(
content: Any = None,
*,
role: Optional[MessageRole] = None,
tool_call_id: str = "",
**kwargs: Any
)
Bases: BaseMessage
A tool message in the conversation.
Source code in src/appl/core/message.py
get_content
¶
Get the content of the message.
Materialize the content if it is a FutureValue.
Source code in src/appl/core/message.py
get_dict
¶
Return a dict representation of the message.
merge
¶
merge(other: 'BaseMessage') -> Optional['Message']
Merge the message with another message.
Source code in src/appl/core/message.py
should_merge
¶
should_merge(other: 'BaseMessage') -> bool
Whether the message should be merged with the other message.
Source code in src/appl/core/message.py
str_with_default_role
¶
str_with_default_role(
default_role: Optional[MessageRole] = None,
) -> str
Return the string representation of the message with default role.
validate_role
¶
validate_role(target_role: MessageRole) -> None
Validate the role of the message, fill the role if not provided.
Source code in src/appl/core/message.py
UserMessage
¶
UserMessage(
content: Any = None,
*,
role: Optional[MessageRole] = None,
**kwargs: Any
)
Bases: BaseMessage
A user message in the conversation.
Source code in src/appl/core/message.py
get_content
¶
Get the content of the message.
Materialize the content if it is a FutureValue.
Source code in src/appl/core/message.py
get_dict
¶
get_dict(
default_role: Optional[MessageRole] = None,
) -> Dict[str, Any]
Return a dict representation of the message.
Source code in src/appl/core/message.py
merge
¶
merge(other: 'BaseMessage') -> Optional['Message']
Merge the message with another message.
Source code in src/appl/core/message.py
should_merge
¶
should_merge(other: 'BaseMessage') -> bool
Whether the message should be merged with the other message.
Source code in src/appl/core/message.py
str_with_default_role
¶
str_with_default_role(
default_role: Optional[MessageRole] = None,
) -> str
Return the string representation of the message with default role.
validate_role
¶
validate_role(target_role: MessageRole) -> None
Validate the role of the message, fill the role if not provided.
Source code in src/appl/core/message.py
as_message
¶
as_message(
role: Optional[MessageRole],
content: StrOrImg,
*args: Any,
**kwargs: Any
) -> BaseMessage
Create a message with role, content and extra arguments.
Source code in src/appl/core/message.py
collapse_messages
¶
Collapse a list of the messages by merging the messages with the same sender.
Source code in src/appl/core/message.py
get_colored_role_text
¶
get_colored_role_text(
role: Optional[MessageRole], content: str
) -> str
Get the colored text based on the role.
Source code in src/appl/core/message.py
get_role_color
¶
get_role_color(role: MessageRole) -> Optional[str]
Get the color of the message based on the role.