Skip to content

Commit

Permalink
Merge branch 'main' into history_cleaning_function_call
Browse files Browse the repository at this point in the history
  • Loading branch information
GregorD1A1 authored Mar 2, 2024
2 parents 025e9f8 + d604643 commit 698a443
Show file tree
Hide file tree
Showing 92 changed files with 1,008 additions and 402 deletions.
8 changes: 4 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ RUN apt-get update \
&& apt-get -y install --no-install-recommends build-essential npm \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-amd64.deb \
&& dpkg -i quarto-1.4.549-linux-amd64.deb \
&& rm -rf /var/lib/apt/lists/* quarto-1.4.549-linux-amd64.deb
&& wget https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-amd64.deb \
&& dpkg -i quarto-1.5.23-linux-amd64.deb \
&& rm -rf /var/lib/apt/lists/* quarto-1.5.23-linux-amd64.deb
ENV DEBIAN_FRONTEND=dialog

# For docs
RUN npm install --global yarn
RUN pip install pydoc-markdown
RUN pip install pyyaml
RUN pip install colored
RUN pip install colored
8 changes: 4 additions & 4 deletions .devcontainer/dev/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ RUN cd website
RUN yarn install --frozen-lockfile --ignore-engines

RUN arch=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) && \
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-${arch}.tar.gz && \
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-${arch}.tar.gz && \
mkdir -p /home/autogen/quarto/ && \
tar -xzf quarto-1.4.549-linux-${arch}.tar.gz --directory /home/autogen/quarto/ && \
rm quarto-1.4.549-linux-${arch}.tar.gz
tar -xzf quarto-1.5.23-linux-${arch}.tar.gz --directory /home/autogen/quarto/ && \
rm quarto-1.5.23-linux-${arch}.tar.gz

ENV PATH="${PATH}:/home/autogen/quarto/quarto-1.4.549/bin/"
ENV PATH="${PATH}:/home/autogen/quarto/quarto-1.5.23/bin/"

# Exposes the Yarn port for Docusaurus
EXPOSE 3000
Expand Down
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ body:
3. ...
4. See error
placeholder: How can we replicate the issue?
- type: textarea
id: modelused
attributes:
label: Model Used
description: A description of the model that was used when the error was encountered
placeholder: gpt-4, mistral-7B etc
- type: textarea
id: expected_behavior
attributes:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ jobs:
# code executors auto skip without deps, so only run for python 3.11
if: matrix.python-version == '3.11'
run: |
pip install jupyter-client ipykernel
pip install -e ".[jupyter-executor]"
python -m ipykernel install --user --name python3
pip install -e ".[local-jupyter-exec]"
- name: Set AUTOGEN_USE_DOCKER based on OS
shell: bash
run: |
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ jobs:
- name: quarto install
working-directory: ${{ runner.temp }}
run: |
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-amd64.tar.gz
tar -xzf quarto-1.4.549-linux-amd64.tar.gz
echo "$(pwd)/quarto-1.4.549/bin/" >> $GITHUB_PATH
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-amd64.tar.gz
tar -xzf quarto-1.5.23-linux-amd64.tar.gz
echo "$(pwd)/quarto-1.5.23/bin/" >> $GITHUB_PATH
- name: quarto run
run: |
quarto render .
- name: Process notebooks
run: |
python process_notebooks.py
python process_notebooks.py render
- name: Test Build
run: |
if [ -e yarn.lock ]; then
Expand Down Expand Up @@ -90,15 +90,15 @@ jobs:
- name: quarto install
working-directory: ${{ runner.temp }}
run: |
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.4.549/quarto-1.4.549-linux-amd64.tar.gz
tar -xzf quarto-1.4.549-linux-amd64.tar.gz
echo "$(pwd)/quarto-1.4.549/bin/" >> $GITHUB_PATH
wget -q https://github.com/quarto-dev/quarto-cli/releases/download/v1.5.23/quarto-1.5.23-linux-amd64.tar.gz
tar -xzf quarto-1.5.23-linux-amd64.tar.gz
echo "$(pwd)/quarto-1.5.23/bin/" >> $GITHUB_PATH
- name: quarto run
run: |
quarto render .
- name: Process notebooks
run: |
python process_notebooks.py
python process_notebooks.py render
- name: Build website
run: |
if [ -e yarn.lock ]; then
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/openai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- "notebook/agentchat_groupchat_finite_state_machine.ipynb"
- ".github/workflows/openai.yml"
permissions: {}
# actions: read
# actions: read
# checks: read
# contents: read
# deployments: read
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,5 @@ test/agentchat/test_agent_scripts/*

# test cache
.cache_test

notebook/result.png
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ repos:
rev: 1.7.1
hooks:
- id: nbqa-ruff
args: ["--fix"]
# Don't require notebooks to have all imports at the top
args: ["--fix", "--ignore=E402"]
- id: nbqa-black
13 changes: 8 additions & 5 deletions autogen/agentchat/contrib/gpt_assistant_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class GPTAssistantAgent(ConversableAgent):
This agent is unique in its reliance on the OpenAI Assistant for state management, differing from other agents like ConversableAgent.
"""

DEFAULT_MODEL_NAME = "gpt-4-0125-preview"

def __init__(
self,
name="GPT Assistant",
Expand Down Expand Up @@ -61,16 +63,17 @@ def __init__(

if llm_config is False:
raise ValueError("llm_config=False is not supported for GPTAssistantAgent.")

# Use AutoGen OpenAIWrapper to create a client
model_name = "gpt-4-0125-preview"
# Use AutooGen OpenAIWrapper to create a client
openai_client_cfg = copy.deepcopy(llm_config)
# Use the class variable
model_name = GPTAssistantAgent.DEFAULT_MODEL_NAME

# GPTAssistantAgent's azure_deployment param may cause NotFoundError (404) in client.beta.assistants.list()
# See: https://github.com/microsoft/autogen/pull/1721
if openai_client_cfg.get("config_list") is not None and len(openai_client_cfg["config_list"]) > 0:
model_name = openai_client_cfg["config_list"][0].pop("model", "gpt-4-0125-preview")
model_name = openai_client_cfg["config_list"][0].pop("model", GPTAssistantAgent.DEFAULT_MODEL_NAME)
else:
model_name = openai_client_cfg.pop("model", "gpt-4-0125-preview")
model_name = openai_client_cfg.pop("model", GPTAssistantAgent.DEFAULT_MODEL_NAME)

logger.warning("OpenAI client config of GPTAssistantAgent(%s) - model: %s", name, model_name)

Expand Down
15 changes: 9 additions & 6 deletions autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ def _summary_from_nested_chats(
def register_nested_chats(
self,
chat_queue: List[Dict[str, Any]],
trigger: Union[Type[Agent], str, Agent, Callable[[Agent], bool], List] = [Agent, None],
trigger: Union[Type[Agent], str, Agent, Callable[[Agent], bool], List],
reply_func_from_nested_chats: Union[str, Callable] = "summary_from_nested_chats",
position: int = 2,
**kwargs,
) -> None:
"""Register a nested chat reply function.
Args:
chat_queue (list): a list of chat objects to be initiated.
trigger (Agent class, str, Agent instance, callable, or list): Default to [Agent, None]. Ref to `register_reply` for details.
trigger (Agent class, str, Agent instance, callable, or list): refer to `register_reply` for details.
reply_func_from_nested_chats (Callable, str): the reply function for the nested chat.
The function takes a chat_queue for nested chat, recipient agent, a list of messages, a sender agent and a config as input and returns a reply message.
Default to "summary_from_nested_chats", which corresponds to a built-in reply function that get summary from the nested chat_queue.
Expand Down Expand Up @@ -552,7 +552,7 @@ def _process_message_before_send(
"""Process the message before sending it to the recipient."""
hook_list = self.hook_lists["process_message_before_send"]
for hook in hook_list:
message = hook(message, recipient, silent)
message = hook(sender=self, message=message, recipient=recipient, silent=silent)
return message

def send(
Expand Down Expand Up @@ -2139,15 +2139,18 @@ async def a_generate_init_message(self, **context) -> Union[str, Dict]:
self._process_carryover(context)
return context["message"]

def register_function(self, function_map: Dict[str, Callable]):
def register_function(self, function_map: Dict[str, Union[Callable, None]]):
"""Register functions to the agent.
Args:
function_map: a dictionary mapping function names to functions.
function_map: a dictionary mapping function names to functions. if function_map[name] is None, the function will be removed from the function_map.
"""
for name in function_map.keys():
for name, func in function_map.items():
self._assert_valid_name(name)
if func is None and name not in self._function_map.keys():
warnings.warn(f"The function {name} to remove doesn't exist", name)
self._function_map.update(function_map)
self._function_map = {k: v for k, v in self._function_map.items() if v is not None}

def update_function_signature(self, func_sig: Union[str, Dict], is_remove: None):
"""update a function_signature in the LLM configuration for function_call.
Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ async def a_run_chat(
# Broadcast the intro
intro = groupchat.introductions_msg()
for agent in groupchat.agents:
self.a_send(intro, agent, request_reply=False, silent=True)
await self.a_send(intro, agent, request_reply=False, silent=True)
# NOTE: We do not also append to groupchat.messages,
# since groupchat handles its own introductions

Expand Down
9 changes: 8 additions & 1 deletion autogen/coding/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@
from .factory import CodeExecutorFactory
from .markdown_code_extractor import MarkdownCodeExtractor

__all__ = ("CodeBlock", "CodeResult", "CodeExtractor", "CodeExecutor", "CodeExecutorFactory", "MarkdownCodeExtractor")
__all__ = (
"CodeBlock",
"CodeResult",
"CodeExtractor",
"CodeExecutor",
"CodeExecutorFactory",
"MarkdownCodeExtractor",
)
6 changes: 1 addition & 5 deletions autogen/coding/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ def create(code_execution_config: Dict[str, Any]) -> CodeExecutor:
# If the executor is already an instance of CodeExecutor, return it.
return executor
if executor == "ipython-embedded":
from .embedded_ipython_code_executor import EmbeddedIPythonCodeExecutor
from .jupyter.embedded_ipython_code_executor import EmbeddedIPythonCodeExecutor

return EmbeddedIPythonCodeExecutor(**code_execution_config.get("ipython-embedded", {}))
elif executor == "commandline-local":
from .local_commandline_code_executor import LocalCommandlineCodeExecutor

return LocalCommandlineCodeExecutor(**code_execution_config.get("commandline-local", {}))
elif executor == "jupyter-local":
from .jupyter_code_executor import LocalJupyterCodeExecutor

return LocalJupyterCodeExecutor(**code_execution_config.get("jupyter-local", {}))
else:
raise ValueError(f"Unknown code executor {executor}")
13 changes: 12 additions & 1 deletion autogen/coding/jupyter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
from .base import JupyterConnectable, JupyterConnectionInfo
from .jupyter_client import JupyterClient
from .local_jupyter_server import LocalJupyterServer
from .docker_jupyter_server import DockerJupyterServer
from .embedded_ipython_code_executor import EmbeddedIPythonCodeExecutor
from .jupyter_code_executor import JupyterCodeExecutor

__all__ = ["JupyterConnectable", "JupyterConnectionInfo", "JupyterClient", "LocalJupyterServer"]
__all__ = [
"JupyterConnectable",
"JupyterConnectionInfo",
"JupyterClient",
"LocalJupyterServer",
"DockerJupyterServer",
"EmbeddedIPythonCodeExecutor",
"JupyterCodeExecutor",
]
Loading

0 comments on commit 698a443

Please sign in to comment.