Skip to main content

agentchat.chat

ChatResult

@dataclass
class ChatResult()

(Experimental) The result of a chat. Almost certain to be changed.

chat_id

chat id

chat_history

The chat history.

summary

A summary obtained from the chat.

cost

The cost of the chat. The value for each usage type is a dictionary containing cost information for that specific type.

  • "usage_including_cached_inference": Cost information on the total usage, including the tokens in cached inference.
  • "usage_excluding_cached_inference": Cost information on the usage of tokens, excluding the tokens in cache. No larger than "usage_including_cached_inference".

human_input

A list of human input solicited during the chat.

initiate_chats

def initiate_chats(chat_queue: List[Dict[str, Any]]) -> List[ChatResult]

Initiate a list of chats.

Arguments:

  • chat_queue List[Dict] - A list of dictionaries containing the information about the chats.

    Each dictionary should contain the input arguments for ConversableAgent.initiate_chat. For example:

    • "sender" - the sender agent.
    • "recipient" - the recipient agent.
    • "clear_history" (bool) - whether to clear the chat history with the agent. Default is True.
    • "silent" (bool or None) - (Experimental) whether to print the messages in this conversation. Default is False.
    • "cache" (Cache or None) - the cache client to use for this conversation. Default is None.
    • "max_turns" (int or None) - maximum number of turns for the chat. If None, the chat will continue until a termination condition is met. Default is None.
    • "summary_method" (str or callable) - a string or callable specifying the method to get a summary from the chat. Default is DEFAULT_summary_method, i.e., "last_msg".
    • "summary_args" (dict) - a dictionary of arguments to be passed to the summary_method. Default is {}.
    • "message" (str, callable or None) - if None, input() will be called to get the initial message.
    • **context - additional context information to be passed to the chat.
    • "carryover" - It can be used to specify the carryover information to be passed to this chat. If provided, we will combine this carryover with the "message" content when generating the initial chat message in generate_init_message.
    • "finished_chat_indexes_to_exclude_from_carryover" - It can be used by specifying a list of indexes of the finished_chats list, from which to exclude the summaries for carryover. If 'finished_chat_indexes_to_exclude_from_carryover' is not provided or an empty list, then summary from all the finished chats will be taken.

Returns:

  • (list) - a list of ChatResult objects corresponding to the finished chats in the chat_queue.

a_initiate_chats

async def a_initiate_chats(
chat_queue: List[Dict[str, Any]]) -> Dict[int, ChatResult]

(async) Initiate a list of chats.

args:

  • Please refer to initiate_chats.

returns:

  • (Dict): a dict of ChatId: ChatResult corresponding to the finished chats in the chat_queue.