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

Added a tool server that exposes all tools as endpoints #79

Merged
merged 13 commits into from
Oct 24, 2024
Merged

Conversation

whitead
Copy link
Contributor

@whitead whitead commented Oct 22, 2024

This adds a new method - make_tool_server - that will create an authenticated server that has all environment tools exposed as endpoints.

This is used in a new entry point:

aviary tools [env name]

which will then start a server and host the tools:

image

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Oct 22, 2024
@whitead whitead requested a review from Ryan-Rhys October 22, 2024 07:21
src/aviary/main.py Show resolved Hide resolved
src/aviary/main.py Outdated Show resolved Hide resolved
src/aviary/tools/server.py Outdated Show resolved Hide resolved
src/aviary/tools/server.py Show resolved Hide resolved
src/aviary/tools/server.py Outdated Show resolved Hide resolved
src/aviary/tools/server.py Outdated Show resolved Hide resolved
src/aviary/tools/server.py Outdated Show resolved Hide resolved
tests/test_tools.py Outdated Show resolved Hide resolved
src/aviary/main.py Outdated Show resolved Hide resolved
src/aviary/tools/server.py Outdated Show resolved Hide resolved
Comment on lines +161 to +162
class EnvStateMessage(Message):
"""A message that contains the current state of the environment."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this used at all?

And if it's used, do you mind documenting where the current state gets housed (e.g. is it JSON in the content)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is related to tree search - I had to promote this code to prevent dependence on aviary-internal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, I think when @sidnarayanan promotes the rest of his code it will be documented then.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fwiw, tree search is not going to be in aviary, it will be in LDP. Should we put it in LDP with tree search?

I guess I think it's confusing to have this message subclass here without usage or docs, and no specialized behaviors

Copy link
Collaborator

Choose a reason for hiding this comment

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

EnvStateMessage should be in aviary - it can be used by environments to indicate that a particular message in the returned observation represents the state of the env. I don't see any harm in keeping it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll have to work this out in another PR - basically @sidnarayanan needs this message type in cloning, cloning should not depend on ldp or aviary-internal.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we at least put Sid's comment into the docstring for EnvStateMessage then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Beyond "A message that contains the current state of the environment." ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about something like this:

Suggested change
class EnvStateMessage(Message):
"""A message that contains the current state of the environment."""
class EnvStateMessage(Message):
"""
A message variant whose contents are known to contain the environment state.
For example, the contents can be a JSON serialization of the environment state.
"""

src/aviary/tools/server.py Outdated Show resolved Hide resolved
@pytest.mark.asyncio
async def test_make_tool_server():
def add(a: int, b: int) -> int:
"""Add two numbers."""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"""Add two numbers."""
"""Add two numbers.""" # Allows testing empty descriptions

@whitead whitead merged commit 3c1c9a8 into main Oct 24, 2024
5 of 6 checks passed
@whitead whitead deleted the tool-server branch October 24, 2024 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants