Chat
Waldiez chat model.
WaldiezChat
¶
Bases: WaldiezBase
Chat class.
Attributes:
Name | Type | Description |
---|---|---|
id | str | The chat ID. |
data | WaldiezChatData | The chat data. See |
name | str | The chat name. |
source | str | The chat source. |
target | str | The chat target. |
nested_chat | WaldiezChatNested | The nested chat message/reply if any. |
message | WaldiezChatMessage | The chat message. |
message_content | Optional[str] | The chat message content if any. If method, the method's body. |
Methods:
Name | Description |
---|---|
get_chat_args | Get the chat arguments to use in autogen. |
after_work: Optional[WaldiezSwarmAfterWork]
property
¶
Get the after work.
chat_id: int
property
¶
Get the chat ID.
context_variables: Dict[str, Any]
property
¶
Get the context variables.
description: str
property
¶
Get the description.
get_chat_args(for_queue: bool, sender: Optional[WaldiezAgent] = None) -> Dict[str, Any]
¶
Get the chat arguments to use in autogen.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
for_queue | bool | Whether to get the chat arguments for a chat queue. | required |
sender | WaldiezAgent | The sender agent, to check if it's a RAG user. | None |
Returns:
Type | Description |
---|---|
dict | The chat arguments. |
Source code in waldiez/models/chat/chat.py
get_message_function(name_prefix: Optional[str] = None, name_suffix: Optional[str] = None, is_rag: bool = False) -> Tuple[str, str]
¶
Get the message function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name_prefix | str | The function name prefix. | None |
name_suffix | str | The function name suffix. | None |
is_rag | bool | If the message is from a RAG user. | False |
Returns:
Type | Description |
---|---|
Tuple[str, str] | The message function and the function name. |
Source code in waldiez/models/chat/chat.py
get_nested_chat_message_function(name_prefix: Optional[str] = None, name_suffix: Optional[str] = None) -> Tuple[str, str]
¶
Get the nested chat message function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name_prefix | str | The function name prefix. | None |
name_suffix | str | The function name suffix. | None |
Returns:
Type | Description |
---|---|
Tuple[str, str] | The nested chat message function and the function name. |
Source code in waldiez/models/chat/chat.py
get_nested_chat_reply_function(name_prefix: Optional[str] = None, name_suffix: Optional[str] = None) -> Tuple[str, str]
¶
Get the nested chat reply function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name_prefix | str | The function name prefix. | None |
name_suffix | str | The function name suffix. | None |
Returns:
Type | Description |
---|---|
Tuple[str, str] | The nested chat reply function and the function name. |
Source code in waldiez/models/chat/chat.py
max_rounds: int
property
¶
Get the max rounds for swarm chat.
message: WaldiezChatMessage
property
¶
Get the message.
message_content: Optional[str]
property
¶
Get the message content.
model_dump(**kwargs: Any) -> Dict[str, Any]
¶
Dump the model to a dict including the chat attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs | Any | The keyword arguments. | {} |
Returns:
Type | Description |
---|---|
Dict[str, Any] | The model dump with the chat attributes. |
Source code in waldiez/models/chat/chat.py
name: str
property
¶
Get the name.
nested_chat: WaldiezChatNested
property
¶
Get the nested chat.
order: int
property
¶
Get the order.
prerequisites: List[int]
property
¶
Get the chat prerequisites.
set_chat_id(value: int) -> None
¶
set_prerequisites(value: List[int]) -> None
¶
source: str
property
¶
Get the source.
target: str
property
¶
Get the target.
Chat data model.
WaldiezChatData
¶
Bases: WaldiezBase
Chat data class.
Attributes:
Name | Type | Description |
---|---|---|
name | str | The name of the chat. |
source | str | The source of the chat (sender). |
target | str | The target of the chat (recipient). |
description | str | The description of the chat. |
position | int | The position of the chat. Ignored (UI related). |
order | int | The of the chat. If negative, ignored. |
clear_history | (Optional[bool], optional) | Whether to clear the chat history, by default None. |
message | Union[str, WaldiezChatMessage] | The message of the chat. |
nested_chat | WaldiezChatNested | The nested chat config. |
summary | WaldiezChatSummary | The summary method and options for the chat. |
max_turns | Optional[int] | The maximum number of turns for the chat, by default None (no limit). |
silent | (Optional[bool], optional) | Whether to run the chat silently, by default None (ignored). |
summary_args | Optional[Dict[str, Any]] | The summary args to use in autogen. |
real_source | Optional[str] | The real source of the chat (overrides the source). |
real_target | Optional[str] | The real target of the chat (overrides the target). |
max_rounds | int | Maximum number of conversation rounds (swarm). |
after_work | Optional[WaldiezSwarmAfterWork] | The work to do after the chat (swarm). |
Methods:
Name | Description |
---|---|
validate_message | Validate the message. |
validate_summary_method | Validate the summary method. |
serialize_summary_method | Serialize summary method. |
get_chat_args | Get the chat arguments to use in autogen. |
get_chat_args(for_queue: bool) -> Dict[str, Any]
¶
Get the chat arguments to use in autogen.
Without the 'message' key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
for_queue | bool | Whether to get the arguments for a chat queue. | required |
Returns:
Type | Description |
---|---|
Dict[str, Any] | The dictionary to pass as kwargs. |
Source code in waldiez/models/chat/chat_data.py
get_chat_id() -> int
¶
get_prerequisites() -> List[int]
¶
message_content: Optional[str]
property
¶
Get the message content.
set_chat_id(value: int) -> None
¶
set_prerequisites(value: List[int]) -> None
¶
summary_args: Optional[Dict[str, Any]]
property
¶
Get the summary args.
validate_chat_data() -> Self
¶
Validate the chat data.
Returns:
Type | Description |
---|---|
WaldiezChatData | The validated chat data. |
Raises:
Type | Description |
---|---|
ValueError | If the validation fails. |
Source code in waldiez/models/chat/chat_data.py
validate_context_variables(value: Optional[Dict[str, Any]]) -> Optional[Dict[str, Any]]
classmethod
¶
Validate the context variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Optional[Dict[str, Any]] | The context variables value. | required |
Returns:
Type | Description |
---|---|
Optional[Dict[str, Any]] | The validated context variables value. |
Raises:
Type | Description |
---|---|
ValueError | If the validation fails. |
Source code in waldiez/models/chat/chat_data.py
validate_message(value: Any) -> WaldiezChatMessage
classmethod
¶
Validate the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Any | The message value. | required |
Returns:
Type | Description |
---|---|
WaldiezChatMessage | The validated message value. |
Raises:
Type | Description |
---|---|
ValueError | If the validation fails. |
Source code in waldiez/models/chat/chat_data.py
Waldiez Message Model.
WaldiezChatMessage
¶
Bases: WaldiezBase
Waldiez Message.
A generic message with a type and content.
If the type is not none
, the content is a string. If the type is 'method', the content is the source code of a method. If the type is 'last_carryover', the content is a method to return the last carryover from the context. If the type is 'rag_message_generator', and the sender is a RAG user agent, the content will be generated by the sender.message_generator
method.
Attributes:
Name | Type | Description |
---|---|---|
type | WaldiezChatMessageType | The type of the message: - string - method - rag_message_generator - none If the sender is a RAG user agent, and the type is |
content | Optional[str] | The content of the message (string or method). |
context | Dict[str, Any] | Extra context of the message. |
content_body: Optional[str]
property
¶
Get the content body.
validate_content() -> Self
¶
Validate the content (if not a method).
Returns:
Type | Description |
---|---|
WaldiezChatMessage | The validated instance. |
Raises:
Type | Description |
---|---|
ValueError | If the content is invalid. |
Source code in waldiez/models/chat/chat_message.py
validate_context_vars() -> Self
¶
Try to detect bools nulls and numbers from the context values.
Returns:
Type | Description |
---|---|
WaldiezChatMessage | The validated instance. |
Source code in waldiez/models/chat/chat_message.py
validate_method(function_name: str, function_args: List[str]) -> str
¶
Validate a method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function_name | str | The method name. | required |
function_args | List[str] | The expected method arguments. | required |
Returns:
Type | Description |
---|---|
str | The validated method body. |
Raises:
Type | Description |
---|---|
ValueError | If the validation fails. |
Source code in waldiez/models/chat/chat_message.py
WaldiezChatMessageType = Literal['string', 'method', 'rag_message_generator', 'none']
module-attribute
¶
Possible types for the message.
get_last_carryover_method_content(text_content: str) -> str
¶
Get the last carryover method content.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text_content | str | Text content before the carryover. | required |
Returns:
Type | Description |
---|---|
str | The last carryover method content. |
Source code in waldiez/models/chat/chat_message.py
Nested chat model.
WaldiezChatNested
¶
Bases: WaldiezBase
Nested chat class.
Attributes:
Name | Type | Description |
---|---|---|
message | WaldiezChatMessage | The message in a nested chat (sender -> recipient). |
reply | WaldiezChatMessage | The reply in a nested chat (recipient -> sender). |
message_content: Optional[str]
property
¶
Get the message content.
reply_content: Optional[str]
property
¶
Get the reply content.
validate_message(value: Any) -> WaldiezChatMessage
classmethod
¶
Validate the message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Any | The value. | required |
Returns:
Type | Description |
---|---|
WaldiezChatMessage | The validated message. |
Raises:
Type | Description |
---|---|
ValueError | If the validation fails. |
Source code in waldiez/models/chat/chat_nested.py
validate_nested_chat() -> Self
¶
Validate the nested chat.
Returns:
Type | Description |
---|---|
WaldiezChatNested | The validated nested chat. |
Raises:
Type | Description |
---|---|
ValueError | If the validation fails. |
Source code in waldiez/models/chat/chat_nested.py
Waldiez chat summary options.
WaldiezChatSummary
¶
Bases: WaldiezBase
Llm summary method options.
Attributes:
Name | Type | Description |
---|---|---|
method | Optional[WaldiezChatSummaryMethod] | The method to use for the LLM summary. Defaults to "last_msg". |
prompt | str | The prompt for the LLM summary method. |
args | Optional[Dict[str, Any]] | The additional arguments for the LLM summary method, by default None. |
serialize_summary_method(value: Any, info: FieldSerializationInfo) -> Any
classmethod
¶
Serialize summary method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Any | The value to serialize. | required |
info | FieldSerializationInfo | The serialization info. | required |
Returns:
Type | Description |
---|---|
Any | The serialized value. |
Source code in waldiez/models/chat/chat_summary.py
validate_summary_method(value: Optional[WaldiezChatSummaryMethod]) -> Optional[WaldiezChatSummaryMethod]
classmethod
¶
Validate the summary method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value | Optional[WaldiezChatSummaryMethod] | The passed WaldiezChatSummaryMethod | required |
Returns:
Type | Description |
---|---|
Optional[WaldiezChatSummaryMethod] | The validated message summary method |
Source code in waldiez/models/chat/chat_summary.py
WaldiezChatSummaryMethod = Literal['reflectionWithLlm', 'lastMsg', 'reflection_with_llm', 'last_msg']
module-attribute
¶
Possible methods for the LLM summary.