-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Code executors #1405
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
Merged
Merged
Code executors #1405
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
be75414
code executor
ekzhu 2ea759b
Merge branch 'main' into coding
ekzhu 36fb1be
test
ekzhu 93d0fc6
revert to main conversable agent
ekzhu 71d3cfa
prepare for pr
ekzhu af3c7ae
Merge branch 'main' into coding
ekzhu fc3d70a
kernel
ekzhu be4b34c
run open ai tests only when it's out of draft status
ekzhu d42a086
update workflow file
ekzhu 5e069c0
revert workflow changes
ekzhu 907bc8a
ipython executor
ekzhu 4a68901
check kernel installed; fix tests
ekzhu c2eac94
fix tests
ekzhu 3e96f01
fix tests
ekzhu 57ee0b6
update system prompt
ekzhu b74d369
Update notebook, more tests
ekzhu c4dc779
notebook
ekzhu 4e222c0
raise instead of return None
ekzhu c20de12
Merge branch 'main' into coding
ekzhu fa84009
allow user provided code executor.
ekzhu 0441eb1
fixing types
davorrunje 8fa7341
Merge remote-tracking branch 'origin/main' into coding
davorrunje 00f08d6
Merge remote-tracking branch 'origin/main' into coding-review
davorrunje 7c1b559
wip
davorrunje 7181cf2
Merge remote-tracking branch 'origin/main' into coding-review
davorrunje ebd242b
refactoring
davorrunje 85802d8
polishing
davorrunje 6bf887e
Merge branch 'coding-review' into coding
davorrunje 702bdd3
fixed failing tests
davorrunje 778caf0
Merge branch 'coding-review' into coding
davorrunje a87a7f1
resolved merge conflict
davorrunje 0e38de5
fixing failing test
davorrunje 9ec323d
wip
ekzhu ca0d890
Merge branch 'coding' of github.com:ekzhu/autogen into coding
ekzhu 0e65e86
local command line executor and embedded ipython executor
ekzhu 363708a
revert notebook
ekzhu 4346e51
Merge branch 'main' into coding
ekzhu f8b129d
fix format
ekzhu 439afb5
fix merged error
ekzhu d8b3061
fix lmm test
ekzhu 03e9d59
fix lmm test
ekzhu db64958
Merge branch 'main' into coding
ekzhu 7d7cb2a
move warning
ekzhu 11bfa93
name and description should be part of the agent protocol, reset is n…
ekzhu 09eb58f
version for dependency
ekzhu b2bc99d
Update autogen/agentchat/conversable_agent.py
ekzhu eb55228
Merge branch 'main' into coding
ekzhu 1de5c1e
ordering of protocol
ekzhu a9f8ca4
description
ekzhu 6835d54
fix tests
ekzhu 2f0701e
Merge branch 'main' into coding
ekzhu b3e5747
make ipython executor dependency optional
ekzhu 371eb28
update document optional dependencies
ekzhu 07c5195
Merge branch 'main' into coding
AaronWard 8a29a62
Merge branch 'main' into coding
ekzhu 34cc504
Remove exclude from Agent protocol
ekzhu ac41ba1
Make ConversableAgent consistent with Agent
ekzhu fc684c1
fix tests
ekzhu 8eb6603
add doc string
ekzhu 7b65133
add doc string
ekzhu 95b4f7f
fix notebook
ekzhu 8ab5b53
merge
ekzhu ba1c6d6
Merge branch 'main' into coding
sonichi b640c17
Merge branch 'main' into coding
ekzhu 01cd408
Merge branch 'main' into coding
AaronWard fa748e0
fix interface
ekzhu 0ddb245
Merge branch 'main' into coding
ekzhu 547a481
merge and update agents
ekzhu cc601cc
disable config usage in reply function
ekzhu 313b12f
description field setter
ekzhu 088ce19
customize system message update
ekzhu 2c4ae6f
update doc
ekzhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,70 +1,136 @@ | ||
| from typing import Dict, List, Optional, Union | ||
| from typing import Any, Dict, List, Optional, Protocol, Union, runtime_checkable | ||
|
|
||
|
|
||
| class Agent: | ||
| """(In preview) An abstract class for AI agent. | ||
| @runtime_checkable | ||
| class Agent(Protocol): | ||
| """(In preview) A protocol for Agent. | ||
|
|
||
| An agent can communicate with other agents and perform actions. | ||
| Different agents can differ in what actions they perform in the `receive` method. | ||
| """ | ||
|
|
||
| def __init__( | ||
| @property | ||
| def name(self) -> str: | ||
| """The name of the agent.""" | ||
| ... | ||
|
|
||
| @property | ||
| def description(self) -> str: | ||
| """The description of the agent. Used for the agent's introduction in | ||
| a group chat setting.""" | ||
| ... | ||
|
|
||
| def send( | ||
| self, | ||
| name: str, | ||
| ): | ||
| """ | ||
| message: Union[Dict[str, Any], str], | ||
| recipient: "Agent", | ||
| request_reply: Optional[bool] = None, | ||
| ) -> None: | ||
| """Send a message to another agent. | ||
|
|
||
| Args: | ||
| name (str): name of the agent. | ||
| message (dict or str): the message to send. If a dict, it should be | ||
| a JSON-serializable and follows the OpenAI's ChatCompletion schema. | ||
| recipient (Agent): the recipient of the message. | ||
| request_reply (bool): whether to request a reply from the recipient. | ||
| """ | ||
| # a dictionary of conversations, default value is list | ||
| self._name = name | ||
| ... | ||
|
|
||
| @property | ||
| def name(self): | ||
| """Get the name of the agent.""" | ||
| return self._name | ||
| async def a_send( | ||
| self, | ||
| message: Union[Dict[str, Any], str], | ||
ekzhu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| recipient: "Agent", | ||
| request_reply: Optional[bool] = None, | ||
| ) -> None: | ||
| """(Async) Send a message to another agent. | ||
|
|
||
| def send(self, message: Union[Dict, str], recipient: "Agent", request_reply: Optional[bool] = None): | ||
| """(Abstract method) Send a message to another agent.""" | ||
| Args: | ||
| message (dict or str): the message to send. If a dict, it should be | ||
| a JSON-serializable and follows the OpenAI's ChatCompletion schema. | ||
| recipient (Agent): the recipient of the message. | ||
| request_reply (bool): whether to request a reply from the recipient. | ||
| """ | ||
| ... | ||
|
|
||
| async def a_send(self, message: Union[Dict, str], recipient: "Agent", request_reply: Optional[bool] = None): | ||
| """(Abstract async method) Send a message to another agent.""" | ||
| def receive( | ||
| self, | ||
| message: Union[Dict[str, Any], str], | ||
| sender: "Agent", | ||
| request_reply: Optional[bool] = None, | ||
| ) -> None: | ||
| """Receive a message from another agent. | ||
|
|
||
| def receive(self, message: Union[Dict, str], sender: "Agent", request_reply: Optional[bool] = None): | ||
| """(Abstract method) Receive a message from another agent.""" | ||
| Args: | ||
| message (dict or str): the message received. If a dict, it should be | ||
| a JSON-serializable and follows the OpenAI's ChatCompletion schema. | ||
| sender (Agent): the sender of the message. | ||
| request_reply (bool): whether the sender requests a reply. | ||
| """ | ||
|
|
||
| async def a_receive(self, message: Union[Dict, str], sender: "Agent", request_reply: Optional[bool] = None): | ||
| """(Abstract async method) Receive a message from another agent.""" | ||
| async def a_receive( | ||
| self, | ||
| message: Union[Dict[str, Any], str], | ||
| sender: "Agent", | ||
| request_reply: Optional[bool] = None, | ||
| ) -> None: | ||
| """(Async) Receive a message from another agent. | ||
|
|
||
| def reset(self): | ||
| """(Abstract method) Reset the agent.""" | ||
| Args: | ||
| message (dict or str): the message received. If a dict, it should be | ||
| a JSON-serializable and follows the OpenAI's ChatCompletion schema. | ||
| sender (Agent): the sender of the message. | ||
| request_reply (bool): whether the sender requests a reply. | ||
| """ | ||
| ... | ||
|
|
||
| def generate_reply( | ||
| self, | ||
| messages: Optional[List[Dict]] = None, | ||
| messages: Optional[List[Dict[str, Any]]] = None, | ||
| sender: Optional["Agent"] = None, | ||
| **kwargs, | ||
| ) -> Union[str, Dict, None]: | ||
| """(Abstract method) Generate a reply based on the received messages. | ||
| **kwargs: Any, | ||
| ) -> Union[str, Dict[str, Any], None]: | ||
| """Generate a reply based on the received messages. | ||
|
|
||
| Args: | ||
| messages (list[dict]): a list of messages received. | ||
| messages (list[dict]): a list of messages received from other agents. | ||
| The messages are dictionaries that are JSON-serializable and | ||
| follows the OpenAI's ChatCompletion schema. | ||
| sender: sender of an Agent instance. | ||
|
|
||
| Returns: | ||
| str or dict or None: the generated reply. If None, no reply is generated. | ||
| """ | ||
|
|
||
| async def a_generate_reply( | ||
| self, | ||
| messages: Optional[List[Dict]] = None, | ||
| messages: Optional[List[Dict[str, Any]]] = None, | ||
| sender: Optional["Agent"] = None, | ||
| **kwargs, | ||
| ) -> Union[str, Dict, None]: | ||
| """(Abstract async method) Generate a reply based on the received messages. | ||
| **kwargs: Any, | ||
| ) -> Union[str, Dict[str, Any], None]: | ||
| """(Async) Generate a reply based on the received messages. | ||
|
|
||
| Args: | ||
| messages (list[dict]): a list of messages received. | ||
| messages (list[dict]): a list of messages received from other agents. | ||
| The messages are dictionaries that are JSON-serializable and | ||
| follows the OpenAI's ChatCompletion schema. | ||
| sender: sender of an Agent instance. | ||
|
|
||
| Returns: | ||
| str or dict or None: the generated reply. If None, no reply is generated. | ||
| """ | ||
|
|
||
|
|
||
| @runtime_checkable | ||
| class LLMAgent(Agent, Protocol): | ||
| """(In preview) A protocol for an LLM agent.""" | ||
|
|
||
| @property | ||
| def system_message(self) -> str: | ||
BeibinLi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| """The system message of this agent.""" | ||
|
|
||
| def update_system_message(self, system_message: str) -> None: | ||
| """Update this agent's system message. | ||
|
|
||
| Args: | ||
| system_message (str): system message for inference. | ||
| """ | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.