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

feat(core): add message endpoint for inspector #490

Merged
merged 33 commits into from
Aug 30, 2024

Conversation

Alejandro-Morales
Copy link
Contributor

Received and sent local messages can now be retrieved through http://localhost:<PORT>/messages endpoint

Copy link
Member

@Archento Archento left a comment

Choose a reason for hiding this comment

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

This topic currently needs more discussion so we'll postpone the review for now.

Copy link
Member

@Archento Archento left a comment

Choose a reason for hiding this comment

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

Nice! Good Progress :)
I've added some small proposals and we still need to discuss message retention but I think we're pretty much there.

python/src/uagents/agent.py Outdated Show resolved Hide resolved
python/src/uagents/asgi.py Outdated Show resolved Hide resolved
python/src/uagents/communication.py Outdated Show resolved Hide resolved
python/src/uagents/dispatch.py Outdated Show resolved Hide resolved
@Archento
Copy link
Member

We can probably add a serialiser to the Envelope History List as well that automatically returns the sorted list when we call .model_dump_json()

class EnvelopeHistory(BaseModel):
    envelopes: List[EnvelopeHistoryEntry]

    @field_serializer("envelopes", when_used="json")
    def serialize_envelopes_in_order(
        self, envelopes: List[EnvelopeHistoryEntry], _info
    ):
        return sorted(envelopes, key=lambda e: e.timestamp)

Copy link
Member

@Archento Archento left a comment

Choose a reason for hiding this comment

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

I'm inclined to move the storage of received messages back into the asgi module as it seems like it introduces unnecessary overhead by touching the variables twice when storing them.
How about we move the storing action to the asgi right in front of await dispatcher.dispatch(...)?
And since the envelope is not needed afterwards it would be ok to do the same approach as you did in the dispenser by using the env_dict and reuse that from there on.

python/src/uagents/asgi.py Outdated Show resolved Hide resolved
python/src/uagents/asgi.py Outdated Show resolved Hide resolved
python/src/uagents/envelope.py Outdated Show resolved Hide resolved
python/src/uagents/communication.py Outdated Show resolved Hide resolved
python/src/uagents/dispatch.py Outdated Show resolved Hide resolved
@dominic22
Copy link
Contributor

dominic22 commented Aug 22, 2024

  • please also return the agent address from the agent_info endpoint

@Archento Archento requested review from Archento and removed request for Archento August 30, 2024 09:27
Archento
Archento previously approved these changes Aug 30, 2024
Copy link
Member

@Archento Archento left a comment

Choose a reason for hiding this comment

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

It looks good now and feels rounded 👍🏻

Copy link
Contributor

@jrriehl jrriehl left a comment

Choose a reason for hiding this comment

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

Really nice! Just one question / suggestion about the data type for storing the history.

@Alejandro-Morales Alejandro-Morales merged commit 1cf7147 into main Aug 30, 2024
9 checks passed
@Alejandro-Morales Alejandro-Morales deleted the feat/message-inspector branch August 30, 2024 16:03
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.

4 participants