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

Revise message broker interface #3986

Conversation

collijk
Copy link
Contributor

@collijk collijk commented May 8, 2023

Updates the abstract interface for the message broker as it starts to meet the real world in #3969

@vercel
Copy link

vercel bot commented May 8, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
docs ⬜️ Ignored (Inspect) May 9, 2023 3:13am

@collijk collijk requested a review from rihp May 8, 2023 01:31
@github-actions
Copy link
Contributor

github-actions bot commented May 8, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@@ -1,31 +1,34 @@
import abc
import importlib
import inspect
from typing import Any, Callable, Optional, Tuple, Dict
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in this file is from running black. Sorry!

@collijk collijk added the re-arch label May 8, 2023
@anonhostpi
Copy link

I'm assuming this is related to #3831

class MessageMetadata:
"""Struct for metadata about a message."""

sender: Sender
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like this approach to cohesively have the sender in the meta data

sender: Sender
timestamp: datetime
additional_metadata: Dict = None
# TODO: what else goes here?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe commands and arguments ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messages won't always have commands, I think. The additional_metadata dict gives us a lot of flexibility for now until you and @merwanehamadi and others can pull together the data interchange standard


content: dict # Some json struct we can define with a strict schema
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be the msg broker contract we have talked about in the past?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where in the code should this structure be defined ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content and the metadata.

They should get define in this subpackage, but I'm not sure what tool you want to use. There are lots of good ones, though pydantic might be industry standard at this point. I'm agnostic as long as the schema is enforcable.

...

@abc.abstractmethod
def send_message(self, content: dict, **extra_metadata) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a return type to confirm that the message was sent? Maybe a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Q. I'm not sure if the send receipt would be implementation specific. We can readjust when we do our first real message broker implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll swap to a bool for now.

autogpt/core/messaging/base.py Show resolved Hide resolved
autogpt/core/messaging/base.py Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2023

This PR exceeds the recommended size of 200 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size

@collijk collijk merged commit b2ffa0a into Significant-Gravitas:agent-state-encapsulation May 9, 2023
4 checks passed
@collijk collijk deleted the revise-message-broker-interface branch May 9, 2023 03:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants