Skip to content

feat: add get_thread() method to BaseGroupChat#7685

Open
yahyasaqban-lab wants to merge 1 commit into
microsoft:mainfrom
yahyasaqban-lab:feat/get-thread-method
Open

feat: add get_thread() method to BaseGroupChat#7685
yahyasaqban-lab wants to merge 1 commit into
microsoft:mainfrom
yahyasaqban-lab:feat/get-thread-method

Conversation

@yahyasaqban-lab
Copy link
Copy Markdown

Why

For BaseGroupChat, there is currently no public method to retrieve all messages exchanged so far in a session. Users have to track messages externally. This PR adds a simple get_thread() method.

Changes

New Events (_events.py)

  • GroupChatGetThread — request event for retrieving the current message thread
  • GroupChatGetThreadResponse — response event containing the list of messages

BaseGroupChatManager (_base_group_chat_manager.py)

  • Added handle_get_thread RPC handler that returns the current _message_thread as a GroupChatGetThreadResponse

BaseGroupChat (_base_group_chat.py)

  • Added get_thread() public async method that sends a GroupChatGetThread request to the group chat manager and returns the message list

Usage

result = await team.run(task="Count from 1 to 10, respond one at a time.")
thread = await team.get_thread()
print(f"Total messages: {len(thread)}")
for msg in thread:
    print(f"{msg.source}: {msg.content}")

Fixes #6085

Adds a public method to retrieve the current message thread from a
group chat team via a new RPC event (GroupChatGetThread).

Changes:
- Add GroupChatGetThread and GroupChatGetThreadResponse event types
- Add handle_get_thread RPC handler in BaseGroupChatManager
- Add get_thread() public method on BaseGroupChat

Part of microsoft#6085
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get current message thread from a group chat team.

2 participants