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

Code executors #1405

Merged
merged 72 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
be75414
code executor
ekzhu Jan 24, 2024
2ea759b
Merge branch 'main' into coding
ekzhu Jan 24, 2024
36fb1be
test
ekzhu Jan 25, 2024
93d0fc6
revert to main conversable agent
ekzhu Jan 25, 2024
71d3cfa
prepare for pr
ekzhu Jan 25, 2024
af3c7ae
Merge branch 'main' into coding
ekzhu Jan 25, 2024
fc3d70a
kernel
ekzhu Jan 26, 2024
be4b34c
run open ai tests only when it's out of draft status
ekzhu Jan 26, 2024
d42a086
update workflow file
ekzhu Jan 26, 2024
5e069c0
revert workflow changes
ekzhu Jan 26, 2024
907bc8a
ipython executor
ekzhu Jan 27, 2024
4a68901
check kernel installed; fix tests
ekzhu Jan 27, 2024
c2eac94
fix tests
ekzhu Jan 27, 2024
3e96f01
fix tests
ekzhu Jan 27, 2024
57ee0b6
update system prompt
ekzhu Jan 27, 2024
b74d369
Update notebook, more tests
ekzhu Jan 27, 2024
c4dc779
notebook
ekzhu Jan 27, 2024
4e222c0
raise instead of return None
ekzhu Jan 27, 2024
c20de12
Merge branch 'main' into coding
ekzhu Jan 27, 2024
fa84009
allow user provided code executor.
ekzhu Jan 29, 2024
0441eb1
fixing types
davorrunje Jan 30, 2024
8fa7341
Merge remote-tracking branch 'origin/main' into coding
davorrunje Jan 30, 2024
00f08d6
Merge remote-tracking branch 'origin/main' into coding-review
davorrunje Jan 30, 2024
7c1b559
wip
davorrunje Jan 31, 2024
7181cf2
Merge remote-tracking branch 'origin/main' into coding-review
davorrunje Jan 31, 2024
ebd242b
refactoring
davorrunje Jan 31, 2024
85802d8
polishing
davorrunje Jan 31, 2024
6bf887e
Merge branch 'coding-review' into coding
davorrunje Jan 31, 2024
702bdd3
fixed failing tests
davorrunje Feb 1, 2024
778caf0
Merge branch 'coding-review' into coding
davorrunje Feb 1, 2024
a87a7f1
resolved merge conflict
davorrunje Feb 1, 2024
0e38de5
fixing failing test
davorrunje Feb 1, 2024
9ec323d
wip
ekzhu Feb 1, 2024
ca0d890
Merge branch 'coding' of github.com:ekzhu/autogen into coding
ekzhu Feb 1, 2024
0e65e86
local command line executor and embedded ipython executor
ekzhu Feb 1, 2024
363708a
revert notebook
ekzhu Feb 1, 2024
4346e51
Merge branch 'main' into coding
ekzhu Feb 1, 2024
f8b129d
fix format
ekzhu Feb 1, 2024
439afb5
fix merged error
ekzhu Feb 1, 2024
d8b3061
fix lmm test
ekzhu Feb 1, 2024
03e9d59
fix lmm test
ekzhu Feb 1, 2024
db64958
Merge branch 'main' into coding
ekzhu Feb 2, 2024
7d7cb2a
move warning
ekzhu Feb 2, 2024
11bfa93
name and description should be part of the agent protocol, reset is n…
ekzhu Feb 2, 2024
09eb58f
version for dependency
ekzhu Feb 2, 2024
b2bc99d
Update autogen/agentchat/conversable_agent.py
ekzhu Feb 3, 2024
eb55228
Merge branch 'main' into coding
ekzhu Feb 3, 2024
1de5c1e
ordering of protocol
ekzhu Feb 3, 2024
a9f8ca4
description
ekzhu Feb 3, 2024
6835d54
fix tests
ekzhu Feb 3, 2024
2f0701e
Merge branch 'main' into coding
ekzhu Feb 5, 2024
b3e5747
make ipython executor dependency optional
ekzhu Feb 5, 2024
371eb28
update document optional dependencies
ekzhu Feb 5, 2024
07c5195
Merge branch 'main' into coding
AaronWard Feb 6, 2024
8a29a62
Merge branch 'main' into coding
ekzhu Feb 6, 2024
34cc504
Remove exclude from Agent protocol
ekzhu Feb 6, 2024
ac41ba1
Make ConversableAgent consistent with Agent
ekzhu Feb 6, 2024
fc684c1
fix tests
ekzhu Feb 6, 2024
8eb6603
add doc string
ekzhu Feb 6, 2024
7b65133
add doc string
ekzhu Feb 6, 2024
95b4f7f
fix notebook
ekzhu Feb 6, 2024
8ab5b53
merge
ekzhu Feb 7, 2024
ba1c6d6
Merge branch 'main' into coding
sonichi Feb 7, 2024
b640c17
Merge branch 'main' into coding
ekzhu Feb 7, 2024
01cd408
Merge branch 'main' into coding
AaronWard Feb 8, 2024
fa748e0
fix interface
ekzhu Feb 8, 2024
0ddb245
Merge branch 'main' into coding
ekzhu Feb 9, 2024
547a481
merge and update agents
ekzhu Feb 9, 2024
cc601cc
disable config usage in reply function
ekzhu Feb 9, 2024
313b12f
description field setter
ekzhu Feb 9, 2024
088ce19
customize system message update
ekzhu Feb 9, 2024
2c4ae6f
update doc
ekzhu Feb 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ jobs:
pip install -e .
python -c "import autogen"
pip install pytest mock
pip install jupyter-client ipykernel
python -m ipykernel install --user --name python3
- name: Set AUTOGEN_USE_DOCKER based on OS
shell: bash
run: |
if [[ ${{ matrix.os }} != ubuntu-latest ]]; then
echo "AUTOGEN_USE_DOCKER=False" >> $GITHUB_ENV
fi
- name: Test with pytest skipping openai tests
if: matrix.python-version != '3.10' && matrix.os == 'ubuntu-latest'
run: |
Expand Down
134 changes: 100 additions & 34 deletions autogen/agentchat/agent.py
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.
ekzhu marked this conversation as resolved.
Show resolved Hide resolved

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],
recipient: "Agent",
ekzhu marked this conversation as resolved.
Show resolved Hide resolved
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:
"""The system message of this agent."""
BeibinLi marked this conversation as resolved.
Show resolved Hide resolved

def update_system_message(self, system_message: str) -> None:
"""Update this agent's system message.

Args:
system_message (str): system message for inference.
"""
Loading
Loading