-
Notifications
You must be signed in to change notification settings - Fork 310
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 environment modules #378
Open
pan-x-c
wants to merge
181
commits into
modelscope:main
Choose a base branch
from
pan-x-c:feature/pxc/env
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DavdGao
reviewed
Aug 6, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Move the environment modules into examples like what rag and react did before, and we should consider to merge it into the library when it's ready.
- Will it enter an infinite loop? For example, agentA and agentB subscribe to the locations of each other and trigger each other, leading to an endless actions cycle.
agentA move ==> agentB listen ==> agent B move ==> agentA listen ==> agentB move ....
add a simple auction simulation example for environment
move chatroom to environments subdir
qbc2016
reviewed
Oct 12, 2024
qbc2016
reviewed
Oct 12, 2024
qbc2016
reviewed
Oct 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Add Environment Modules (
Env
and its sub-classes)Env
is a key concept of AgentScope, representing global data shared among agents.Each env has name and value, and multiple envs can be organized into a tree structure, where each env can have multiple children envs and one parent env.
Different implementations of envs may have different event functions, which are marked by
@event_func
.Users can bind
EventListener
to specific event functions, and the listener will be activated when the event function is called.Similar to
AgentBase
sub-classes,Env
sub-classes also support theto_dist
call, and the parameter is the same asAgentBase
.Decouple distribution-related functions from other AgentScope modules
Move
to_dist
intoRpcMeta
RpcMeta
is a meta-class that integrates allto_dist
related methods/parameters.Now,
to_dist
function/parameter can be used directly if the class is a subclass ofRpcMeta
.The original
to_dist
and_AgentMeta
is removed.Extend
RpcAgent
intoRpcObject
RpcObject
is an enhanced version ofRpcAgent
, and can be used to represent any object (unlikeRpcAgent
which can only representAgent
)Users can call any public methods or get any attributes on the
RpcObject
, and theRpcObject
will forward the request to the real object running in the RPC server.The original
RpcAgent
is removed.Add
@async_func
andAsyncResult
to replace thereply
andPlaceholder
Because the
RpcObject
supports calling any public methods and returns any results, the oldPlaceholder
cannot cover this complex scenario. Therefore,@async_func
andAsyncResult
are added.Functions decorated with
@async_func
will automatically returnAsyncResult
objects in distributed mode.The usage of
AsyncResult
is the same asPlaceholder
, which is instantiated only when its internal objects are accessed.AsyncResult
can be used to represent any type of data, not justMsg
.The original
PlaceholderMessage
is removed.Through the above modification, the
agent
andmessage
modules are decoupled from the distributed mode.Note that the user interface of the distributed mode is unchanged, all modifications above are completely hidden from the user, and all previous distributed examples can be run without any modification.
Add Guess Two Third of the Average Game example
The code of "Very Large-Scale Multi-Agent Simulation in AgentScope" is released under
examples/paper_large_scale_simulation
Checklist
Please check the following items before code is ready to be reviewed.