Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new event types #381

Merged
merged 12 commits into from
Nov 12, 2024
Merged

Add new event types #381

merged 12 commits into from
Nov 12, 2024

Conversation

jlowin
Copy link
Member

@jlowin jlowin commented Nov 12, 2024

This pull request includes significant refactoring and improvements to the event handling system in the controlflow package. The changes aim to simplify the event model, improve consistency, and enhance the functionality of event handlers.

A primary, tangible benefit of this PR is enhanced PrintHandler output by using the new public event hooks, e.g.:

printhandler.mp4

The following settings/env vars are respected:

enable_default_print_handler # default True
default_print_handler_show_completion_tools # default True
default_print_handler_show_completion_tool_results # default False

Refactoring and Simplification:

  • Removed ToolCallEvent and ToolResultEvent classes, replacing them with AgentToolCall and ToolResult respectively in src/controlflow/events/events.py. [1] [2] [3] [4] [5]
  • Updated methods to yield related events using the new all_related_events method in AgentMessage and AgentMessageDelta classes. [1] [2] [3]

Enhancements to Event Handling:

  • Added CallbackHandler and AsyncCallbackHandler classes to handle events by calling a callback function.
  • Introduced QueueHandler and AsyncQueueHandler classes to queue events, with optional filtering capabilities.

Code Consistency:

  • Standardized the __repr__ method in the Event class for better readability.
  • Updated import statements and type annotations for consistency and clarity across multiple files. [1] [2] [3]

Additional Changes:

  • Introduced new methods in AgentMessage and AgentMessageDelta to convert messages to tool calls and content events, enhancing the modularity of event handling. [1] [2]
  • Updated the message_compiler to use the new event classes and methods.

These changes collectively improve the maintainability and functionality of the event handling system in the controlflow package.

@github-actions github-actions bot added enhancement Enhance an existing feature feature New feature that doesn't exist today labels Nov 12, 2024
@github-actions github-actions bot added the tests Adds or improves unit tests label Nov 12, 2024
@jlowin jlowin merged commit b3ad535 into main Nov 12, 2024
4 checks passed
@jlowin jlowin deleted the events branch November 12, 2024 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhance an existing feature feature New feature that doesn't exist today tests Adds or improves unit tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant