Skip to content

Convo

dopus.core.Convo

A class to manage the conversational context window.

Attributes:

Name Type Description
__messages List[Dict[str, Any]]

A list of messages.

__init__

__init__()

clear

clear() -> None

Clears all messages in the conversation.

add_tool_call

add_tool_call(metadata: Dict[str, Any], result: Any) -> None

Adds a tool call and its result to the conversation.

Parameters:

Name Type Description Default
metadata Dict[str, Any]

Metadata about the tool call.

required
result Any

The result of the tool call.

required

append

append(role: str, message: Dict[str, Any], msg_type: str = 'default') -> None

Appends a message to the conversation.

Parameters:

Name Type Description Default
role str

The role of the message sender (e.g., 'user', 'assistant').

required
message Dict[str, Any]

The message content.

required
msg_type str

The type of the message. Defaults to "default".

'default'

get_all_of_type

get_all_of_type(msg_type: str) -> List[Dict[str, Any]]

Retrieves all messages of a specific type.

Parameters:

Name Type Description Default
msg_type str

The type of messages to retrieve.

required

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: A list of messages of the specified type.

remove_all_of_type

remove_all_of_type(msg_type: str) -> None

Removes all messages of a specific type.

Parameters:

Name Type Description Default
msg_type str

The type of messages to remove.

required

get_messages

get_messages() -> List[Dict[str, Any]]

Retrieves all messages in the conversation.

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: A list of all messages.