Compare commits

...

2 Commits

Author SHA1 Message Date
  Davor Runje 13ce8bc9aa add isort to pre-commit 2 years ago
  Davor Runje 939c9a68a5 Sort import with isort 2 years ago
100 changed files with 374 additions and 301 deletions
Split View
  1. +6
    -1
      .pre-commit-config.yaml
  2. +4
    -4
      autogen/__init__.py
  3. +1
    -1
      autogen/agentchat/__init__.py
  4. +2
    -1
      autogen/agentchat/assistant_agent.py
  5. +7
    -7
      autogen/agentchat/chat.py
  6. +7
    -6
      autogen/agentchat/contrib/agent_builder.py
  7. +5
    -4
      autogen/agentchat/contrib/capabilities/context_handling.py
  8. +1
    -1
      autogen/agentchat/contrib/capabilities/generate_images.py
  9. +4
    -1
      autogen/agentchat/contrib/capabilities/teachability.py
  10. +5
    -5
      autogen/agentchat/contrib/compressible_agent.py
  11. +8
    -8
      autogen/agentchat/contrib/gpt_assistant_agent.py
  12. +2
    -1
      autogen/agentchat/contrib/llava_agent.py
  13. +5
    -5
      autogen/agentchat/contrib/math_user_proxy_agent.py
  14. +1
    -5
      autogen/agentchat/contrib/multimodal_conversable_agent.py
  15. +3
    -3
      autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py
  16. +2
    -1
      autogen/agentchat/contrib/retrieve_assistant_agent.py
  17. +7
    -6
      autogen/agentchat/contrib/retrieve_user_proxy_agent.py
  18. +4
    -3
      autogen/agentchat/contrib/society_of_mind_agent.py
  19. +2
    -1
      autogen/agentchat/contrib/text_analyzer_agent.py
  20. +7
    -5
      autogen/agentchat/contrib/web_surfer.py
  21. +1
    -1
      autogen/agentchat/user_proxy_agent.py
  22. +2
    -1
      autogen/agentchat/utils.py
  23. +6
    -5
      autogen/browser_utils.py
  24. +1
    -1
      autogen/cache/abstract_cache_base.py
  25. +3
    -4
      autogen/cache/cache.py
  26. +2
    -2
      autogen/cache/cache_factory.py
  27. +3
    -1
      autogen/cache/disk_cache.py
  28. +3
    -1
      autogen/cache/redis_cache.py
  29. +2
    -2
      autogen/code_utils.py
  30. +2
    -2
      autogen/coding/__init__.py
  31. +1
    -0
      autogen/coding/base.py
  32. +7
    -7
      autogen/coding/docker_commandline_code_executor.py
  33. +1
    -1
      autogen/coding/factory.py
  34. +2
    -2
      autogen/coding/jupyter/__init__.py
  35. +8
    -8
      autogen/coding/jupyter/docker_jupyter_server.py
  36. +1
    -1
      autogen/coding/jupyter/embedded_ipython_code_executor.py
  37. +4
    -4
      autogen/coding/jupyter/jupyter_client.py
  38. +3
    -4
      autogen/coding/jupyter/jupyter_code_executor.py
  39. +6
    -6
      autogen/coding/jupyter/local_jupyter_server.py
  40. +3
    -5
      autogen/coding/local_commandline_code_executor.py
  41. +1
    -1
      autogen/coding/markdown_code_extractor.py
  42. +2
    -2
      autogen/graph_utils.py
  43. +3
    -3
      autogen/logger/base_logger.py
  44. +1
    -0
      autogen/logger/logger_factory.py
  45. +4
    -4
      autogen/logger/sqlite_logger.py
  46. +2
    -1
      autogen/math_utils.py
  47. +7
    -7
      autogen/oai/__init__.py
  48. +10
    -11
      autogen/oai/client.py
  49. +12
    -16
      autogen/oai/completion.py
  50. +0
    -1
      autogen/oai/openai_utils.py
  51. +9
    -5
      autogen/retrieve_utils.py
  52. +5
    -5
      autogen/runtime_logging.py
  53. +3
    -3
      autogen/token_count_utils.py
  54. +5
    -0
      pyproject.toml
  55. +2
    -3
      samples/apps/auto-anny/bot.py
  56. +1
    -1
      samples/apps/autogen-studio/autogenstudio/__init__.py
  57. +7
    -5
      samples/apps/autogen-studio/autogenstudio/chatmanager.py
  58. +3
    -2
      samples/apps/autogen-studio/autogenstudio/cli.py
  59. +2
    -1
      samples/apps/autogen-studio/autogenstudio/datamodel.py
  60. +3
    -3
      samples/apps/autogen-studio/autogenstudio/utils/dbutils.py
  61. +6
    -3
      samples/apps/autogen-studio/autogenstudio/utils/utils.py
  62. +6
    -12
      samples/apps/autogen-studio/autogenstudio/web/app.py
  63. +4
    -3
      samples/apps/autogen-studio/autogenstudio/workflowmanager.py
  64. +5
    -3
      samples/apps/cap/py/autogencap/Actor.py
  65. +4
    -2
      samples/apps/cap/py/autogencap/ActorConnector.py
  66. +3
    -2
      samples/apps/cap/py/autogencap/Broker.py
  67. +3
    -2
      samples/apps/cap/py/autogencap/DebugLog.py
  68. +8
    -7
      samples/apps/cap/py/autogencap/DirectorySvc.py
  69. +6
    -4
      samples/apps/cap/py/autogencap/LocalActorNetwork.py
  70. +3
    -1
      samples/apps/cap/py/autogencap/ag_adapter/AG2CAP.py
  71. +2
    -0
      samples/apps/cap/py/autogencap/ag_adapter/AutoGenConnector.py
  72. +4
    -2
      samples/apps/cap/py/autogencap/ag_adapter/CAP2AG.py
  73. +4
    -2
      samples/apps/cap/py/autogencap/ag_adapter/CAPGroupChat.py
  74. +5
    -3
      samples/apps/cap/py/autogencap/ag_adapter/CAPGroupChatManager.py
  75. +6
    -2
      samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi
  76. +7
    -8
      samples/apps/cap/py/autogencap/proto/CAP_pb2.pyi
  77. +1
    -1
      samples/apps/cap/py/autogencap/setup.py
  78. +3
    -2
      samples/apps/cap/py/demo/App.py
  79. +2
    -2
      samples/apps/cap/py/demo/AppAgents.py
  80. +4
    -3
      samples/apps/cap/py/demo/CAPAutGenGroupDemo.py
  81. +4
    -2
      samples/apps/cap/py/demo/CAPAutoGenPairDemo.py
  82. +3
    -2
      samples/apps/cap/py/demo/ComplexActorDemo.py
  83. +1
    -0
      samples/apps/cap/py/demo/SimpleActorDemo.py
  84. +1
    -1
      samples/apps/cap/py/demo/_paths.py
  85. +4
    -2
      samples/apps/cap/py/demo/standalone/Assistant.py
  86. +5
    -3
      samples/apps/cap/py/demo/standalone/UserProxy.py
  87. +1
    -1
      samples/apps/cap/py/demo/standalone/_paths.py
  88. +1
    -1
      samples/simple_chat.py
  89. +3
    -2
      samples/tools/autogenbench/autogenbench/cli.py
  90. +4
    -2
      samples/tools/autogenbench/autogenbench/clone_cmd.py
  91. +1
    -1
      samples/tools/autogenbench/autogenbench/load_module.py
  92. +8
    -5
      samples/tools/autogenbench/autogenbench/run_cmd.py
  93. +3
    -1
      samples/tools/autogenbench/autogenbench/tabulate_cmd.py
  94. +5
    -3
      samples/tools/autogenbench/autogenbench/template/testbed_utils.py
  95. +1
    -0
      samples/tools/autogenbench/scenarios/AutoGPT/Scripts/custom_tabulate.py
  96. +4
    -3
      samples/tools/autogenbench/scenarios/AutoGPT/Scripts/init_tasks.py
  97. +2
    -2
      samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py
  98. +3
    -1
      samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/scenario.py
  99. +4
    -2
      samples/tools/autogenbench/scenarios/Examples/Templates/ThreeAgents/scenario.py
  100. +4
    -2
      samples/tools/autogenbench/scenarios/Examples/Templates/TwoAgents/scenario.py

+ 6
- 1
.pre-commit-config.yaml View File

@@ -22,12 +22,17 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: no-commit-to-branch
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.3
rev: v0.3.4
hooks:
- id: ruff
args: ["--fix"]


+ 4
- 4
autogen/__init__.py View File

@@ -1,10 +1,10 @@
import logging
from .version import __version__
from .oai import *

from .agentchat import *
from .exception_utils import *
from .code_utils import DEFAULT_MODEL, FAST_MODEL

from .exception_utils import *
from .oai import *
from .version import __version__

# Set the root logger.
logger = logging.getLogger(__name__)


+ 1
- 1
autogen/agentchat/__init__.py View File

@@ -1,9 +1,9 @@
from .agent import Agent
from .assistant_agent import AssistantAgent
from .chat import ChatResult, initiate_chats
from .conversable_agent import ConversableAgent, register_function
from .groupchat import GroupChat, GroupChatManager
from .user_proxy_agent import UserProxyAgent
from .chat import initiate_chats, ChatResult
from .utils import gather_usage_summary

__all__ = (


+ 2
- 1
autogen/agentchat/assistant_agent.py View File

@@ -1,7 +1,8 @@
from typing import Callable, Dict, Literal, Optional, Union

from autogen.runtime_logging import log_new_agent, logging_enabled

from .conversable_agent import ConversableAgent
from autogen.runtime_logging import logging_enabled, log_new_agent


class AssistantAgent(ConversableAgent):


+ 7
- 7
autogen/agentchat/chat.py View File

@@ -1,14 +1,14 @@
import asyncio
from functools import partial
import logging
from collections import defaultdict, abc
from typing import Dict, List, Any, Set, Tuple
from dataclasses import dataclass
from .utils import consolidate_chat_info
import datetime
import logging
import warnings
from ..formatting_utils import colored
from collections import abc, defaultdict
from dataclasses import dataclass
from functools import partial
from typing import Any, Dict, List, Set, Tuple

from ..formatting_utils import colored
from .utils import consolidate_chat_info

logger = logging.getLogger(__name__)
Prerequisite = Tuple[int, int]


+ 7
- 6
autogen/agentchat/contrib/agent_builder.py View File

@@ -1,10 +1,11 @@
import autogen
import time
import subprocess as sp
import socket
import json
import hashlib
from typing import Optional, List, Dict, Tuple
import json
import socket
import subprocess as sp
import time
from typing import Dict, List, Optional, Tuple

import autogen


def _config_check(config: Dict):


+ 5
- 4
autogen/agentchat/contrib/capabilities/context_handling.py View File

@@ -1,9 +1,10 @@
import sys
from termcolor import colored
from typing import Dict, Optional, List
from autogen import ConversableAgent
from autogen import token_count_utils
from typing import Dict, List, Optional

import tiktoken
from termcolor import colored

from autogen import ConversableAgent, token_count_utils


class TransformChatHistory:


+ 1
- 1
autogen/agentchat/contrib/capabilities/generate_images.py View File

@@ -5,10 +5,10 @@ from openai import OpenAI
from PIL.Image import Image

from autogen import Agent, ConversableAgent, code_utils
from autogen.cache import Cache
from autogen.agentchat.contrib import img_utils
from autogen.agentchat.contrib.capabilities.agent_capability import AgentCapability
from autogen.agentchat.contrib.text_analyzer_agent import TextAnalyzerAgent
from autogen.cache import Cache

SYSTEM_MESSAGE = "You've been given the special ability to generate images."
DESCRIPTION_MESSAGE = "This agent has the ability to generate images."


+ 4
- 1
autogen/agentchat/contrib/capabilities/teachability.py View File

@@ -1,11 +1,14 @@
import os
import pickle
from typing import Dict, Optional, Union

import chromadb
from chromadb.config import Settings
import pickle
from autogen.agentchat.assistant_agent import ConversableAgent
from autogen.agentchat.contrib.capabilities.agent_capability import AgentCapability
from autogen.agentchat.contrib.text_analyzer_agent import TextAnalyzerAgent

from ....formatting_utils import colored




+ 5
- 5
autogen/agentchat/contrib/compressible_agent.py View File

@@ -1,10 +1,10 @@
from typing import Callable, Dict, Optional, Union, Tuple, List, Any
from autogen import OpenAIWrapper
from autogen import Agent, ConversableAgent
import copy
import asyncio
import logging
import copy
import inspect
import logging
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from autogen import Agent, ConversableAgent, OpenAIWrapper
from autogen.token_count_utils import count_token, get_max_token_limit, num_tokens_from_functions

from ...formatting_utils import colored


+ 8
- 8
autogen/agentchat/contrib/gpt_assistant_agent.py View File

@@ -1,16 +1,16 @@
from collections import defaultdict
import openai
import copy
import json
import time
import logging
import copy
import time
from collections import defaultdict
from typing import Any, Dict, List, Optional, Tuple, Union

import openai

from autogen import OpenAIWrapper
from autogen.oai.openai_utils import retrieve_assistants_by_name
from autogen.agentchat.agent import Agent
from autogen.agentchat.assistant_agent import ConversableAgent
from autogen.agentchat.assistant_agent import AssistantAgent
from typing import Dict, Optional, Union, List, Tuple, Any
from autogen.agentchat.assistant_agent import AssistantAgent, ConversableAgent
from autogen.oai.openai_utils import retrieve_assistants_by_name

logger = logging.getLogger(__name__)



+ 2
- 1
autogen/agentchat/contrib/llava_agent.py View File

@@ -1,6 +1,7 @@
import json
import logging
from typing import List, Optional, Tuple

import replicate
import requests

@@ -8,8 +9,8 @@ from autogen.agentchat.agent import Agent
from autogen.agentchat.contrib.img_utils import get_image_data, llava_formatter
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
from autogen.code_utils import content_str
from ...formatting_utils import colored

from ...formatting_utils import colored

logger = logging.getLogger(__name__)



+ 5
- 5
autogen/agentchat/contrib/math_user_proxy_agent.py View File

@@ -1,15 +1,15 @@
import re
import os
from pydantic import BaseModel, Extra, root_validator
from typing import Any, Callable, Dict, List, Optional, Union, Tuple
import re
from time import sleep
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from pydantic import BaseModel, Extra, root_validator

from autogen._pydantic import PYDANTIC_V1
from autogen.agentchat import Agent, UserProxyAgent
from autogen.code_utils import UNKNOWN, extract_code, execute_code, infer_lang
from autogen.code_utils import UNKNOWN, execute_code, extract_code, infer_lang
from autogen.math_utils import get_answer


PROMPTS = {
# default
"default": """Let's use Python to solve a math problem.


+ 1
- 5
autogen/agentchat/contrib/multimodal_conversable_agent.py View File

@@ -3,15 +3,11 @@ from typing import Dict, List, Optional, Tuple, Union

from autogen import OpenAIWrapper
from autogen.agentchat import Agent, ConversableAgent
from autogen.agentchat.contrib.img_utils import (
gpt4v_formatter,
message_formatter_pil_to_b64,
)
from autogen.agentchat.contrib.img_utils import gpt4v_formatter, message_formatter_pil_to_b64
from autogen.code_utils import content_str

from ..._pydantic import model_dump


DEFAULT_LMM_SYS_MSG = """You are a helpful AI assistant."""
DEFAULT_MODEL = "gpt-4-vision-preview"



+ 3
- 3
autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py View File

@@ -1,15 +1,15 @@
import logging
from typing import Callable, Dict, List, Optional

from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent
from autogen.retrieve_utils import get_files_from_dir, split_files_to_chunks, TEXT_FORMATS
import logging
from autogen.retrieve_utils import TEXT_FORMATS, get_files_from_dir, split_files_to_chunks

logger = logging.getLogger(__name__)

try:
import fastembed
from qdrant_client import QdrantClient, models
from qdrant_client.fastembed_common import QueryResponse
import fastembed
except ImportError as e:
logging.fatal("Failed to import qdrant_client with fastembed. Try running 'pip install qdrant_client[fastembed]'")
raise e


+ 2
- 1
autogen/agentchat/contrib/retrieve_assistant_agent.py View File

@@ -1,6 +1,7 @@
from typing import Any, Dict, List, Optional, Tuple, Union

from autogen.agentchat.agent import Agent
from autogen.agentchat.assistant_agent import AssistantAgent
from typing import Dict, Optional, Union, List, Tuple, Any


class RetrieveAssistantAgent(AssistantAgent):


+ 7
- 6
autogen/agentchat/contrib/retrieve_user_proxy_agent.py View File

@@ -1,19 +1,20 @@
import re
from typing import Callable, Dict, Optional, Union, List, Tuple, Any
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from IPython import get_ipython

try:
import chromadb
except ImportError:
raise ImportError("Please install dependencies first. `pip install pyautogen[retrievechat]`")
from autogen.agentchat.agent import Agent
from autogen import logger
from autogen.agentchat import UserProxyAgent
from autogen.retrieve_utils import create_vector_db_from_dir, query_vector_db, TEXT_FORMATS
from autogen.token_count_utils import count_token
from autogen.agentchat.agent import Agent
from autogen.code_utils import extract_code
from autogen import logger
from ...formatting_utils import colored
from autogen.retrieve_utils import TEXT_FORMATS, create_vector_db_from_dir, query_vector_db
from autogen.token_count_utils import count_token

from ...formatting_utils import colored

PROMPT_DEFAULT = """You're a retrieve augmented chatbot. You answer user's questions based on your own knowledge and the
context provided by the user. You should follow the following steps to answer a question:


+ 4
- 3
autogen/agentchat/contrib/society_of_mind_agent.py View File

@@ -1,10 +1,11 @@
# ruff: noqa: E722
import copy
import json
import traceback
import copy
from dataclasses import dataclass
from typing import Dict, List, Optional, Union, Callable, Literal, Tuple
from autogen import Agent, ConversableAgent, GroupChatManager, GroupChat, OpenAIWrapper
from typing import Callable, Dict, List, Literal, Optional, Tuple, Union

from autogen import Agent, ConversableAgent, GroupChat, GroupChatManager, OpenAIWrapper


class SocietyOfMindAgent(ConversableAgent):


+ 2
- 1
autogen/agentchat/contrib/text_analyzer_agent.py View File

@@ -1,7 +1,8 @@
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from autogen import oai
from autogen.agentchat.agent import Agent
from autogen.agentchat.assistant_agent import ConversableAgent
from typing import Callable, Dict, Optional, Union, List, Tuple, Any

system_message = """You are an expert in text analysis.
The user will give you TEXT to analyze.


+ 7
- 5
autogen/agentchat/contrib/web_surfer.py View File

@@ -1,16 +1,18 @@
import json
import copy
import json
import logging
import re
from dataclasses import dataclass
from typing import Any, Dict, List, Optional, Union, Callable, Literal, Tuple
from datetime import datetime
from typing import Any, Callable, Dict, List, Literal, Optional, Tuple, Union

from typing_extensions import Annotated
from ... import Agent, ConversableAgent, AssistantAgent, UserProxyAgent, GroupChatManager, GroupChat, OpenAIWrapper

from ... import Agent, AssistantAgent, ConversableAgent, GroupChat, GroupChatManager, OpenAIWrapper, UserProxyAgent
from ...browser_utils import SimpleTextBrowser
from ...code_utils import content_str
from datetime import datetime
from ...token_count_utils import count_token, get_max_token_limit
from ...oai.openai_utils import filter_config
from ...token_count_utils import count_token, get_max_token_limit

logger = logging.getLogger(__name__)



+ 1
- 1
autogen/agentchat/user_proxy_agent.py View File

@@ -1,7 +1,7 @@
from typing import Callable, Dict, List, Literal, Optional, Union

from ..runtime_logging import log_new_agent, logging_enabled
from .conversable_agent import ConversableAgent
from ..runtime_logging import logging_enabled, log_new_agent


class UserProxyAgent(ConversableAgent):


+ 2
- 1
autogen/agentchat/utils.py View File

@@ -1,4 +1,5 @@
from typing import Any, List, Dict, Tuple, Callable
from typing import Any, Callable, Dict, List, Tuple

from .agent import Agent




+ 6
- 5
autogen/browser_utils.py View File

@@ -1,14 +1,15 @@
import io
import json
import mimetypes
import os
import requests
import re
import markdownify
import io
import uuid
import mimetypes
from typing import Any, Dict, List, Optional, Tuple, Union
from urllib.parse import urljoin, urlparse

import markdownify
import requests
from bs4 import BeautifulSoup
from typing import Any, Dict, List, Optional, Union, Tuple

# Optional PDF support
IS_PDF_CAPABLE = False


+ 1
- 1
autogen/cache/abstract_cache_base.py View File

@@ -1,7 +1,7 @@
import sys
from abc import ABC, abstractmethod
from types import TracebackType
from typing import Any, Optional, Type
import sys

if sys.version_info >= (3, 11):
from typing import Self


+ 3
- 4
autogen/cache/cache.py View File

@@ -1,13 +1,12 @@
from __future__ import annotations

import sys
from types import TracebackType
from typing import Dict, Any, Optional, Type, Union
from typing import Any, Dict, Optional, Type, Union

from .abstract_cache_base import AbstractCache

from .cache_factory import CacheFactory

import sys

if sys.version_info >= (3, 11):
from typing import Self
else:


+ 2
- 2
autogen/cache/cache_factory.py View File

@@ -1,9 +1,9 @@
import logging
from typing import Optional, Union

from .abstract_cache_base import AbstractCache
from .disk_cache import DiskCache

import logging


class CacheFactory:
@staticmethod


+ 3
- 1
autogen/cache/disk_cache.py View File

@@ -1,8 +1,10 @@
import sys
from types import TracebackType
from typing import Any, Optional, Type, Union

import diskcache

from .abstract_cache_base import AbstractCache
import sys

if sys.version_info >= (3, 11):
from typing import Self


+ 3
- 1
autogen/cache/redis_cache.py View File

@@ -1,8 +1,10 @@
import pickle
import sys
from types import TracebackType
from typing import Any, Optional, Type, Union

import redis
import sys
from .abstract_cache_base import AbstractCache

if sys.version_info >= (3, 11):


+ 2
- 2
autogen/code_utils.py View File

@@ -10,10 +10,10 @@ from concurrent.futures import ThreadPoolExecutor, TimeoutError
from hashlib import md5
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

from autogen import oai

import docker

from autogen import oai

from .types import UserMessageImageContentPart, UserMessageTextContentPart

SENTINEL = object()


+ 2
- 2
autogen/coding/__init__.py View File

@@ -1,8 +1,8 @@
from .base import CodeBlock, CodeExecutor, CodeExtractor, CodeResult
from .docker_commandline_code_executor import DockerCommandLineCodeExecutor
from .factory import CodeExecutorFactory
from .markdown_code_extractor import MarkdownCodeExtractor
from .local_commandline_code_executor import LocalCommandLineCodeExecutor
from .docker_commandline_code_executor import DockerCommandLineCodeExecutor
from .markdown_code_extractor import MarkdownCodeExtractor

__all__ = (
"CodeBlock",


+ 1
- 0
autogen/coding/base.py View File

@@ -1,4 +1,5 @@
from __future__ import annotations

from typing import Any, List, Literal, Mapping, Optional, Protocol, TypedDict, Union, runtime_checkable

from pydantic import BaseModel, Field


+ 7
- 7
autogen/coding/docker_commandline_code_executor.py View File

@@ -1,22 +1,22 @@
from __future__ import annotations

import atexit
from hashlib import md5
import logging
import sys
import uuid
from hashlib import md5
from pathlib import Path
from time import sleep
from types import TracebackType
import uuid
from typing import Any, List, Optional, Type, Union

import docker
from docker.errors import ImageNotFound

from .utils import _get_file_name_from_content, silence_pip
from .base import CommandLineCodeResult

from ..code_utils import TIMEOUT_MSG, _cmd
from .base import CodeBlock, CodeExecutor, CodeExtractor
from .base import CodeBlock, CodeExecutor, CodeExtractor, CommandLineCodeResult
from .markdown_code_extractor import MarkdownCodeExtractor
import sys
from .utils import _get_file_name_from_content, silence_pip

if sys.version_info >= (3, 11):
from typing import Self


+ 1
- 1
autogen/coding/factory.py View File

@@ -1,4 +1,4 @@
from .base import CodeExecutor, CodeExecutionConfig
from .base import CodeExecutionConfig, CodeExecutor

__all__ = ("CodeExecutorFactory",)



+ 2
- 2
autogen/coding/jupyter/__init__.py View File

@@ -1,9 +1,9 @@
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_client import JupyterClient
from .jupyter_code_executor import JupyterCodeExecutor
from .local_jupyter_server import LocalJupyterServer

__all__ = [
"JupyterConnectable",


+ 8
- 8
autogen/coding/jupyter/docker_jupyter_server.py View File

@@ -1,15 +1,16 @@
from __future__ import annotations

from pathlib import Path
import atexit
import io
import logging
import secrets
import sys
from types import TracebackType
import uuid
from pathlib import Path
from types import TracebackType
from typing import Dict, Optional, Type, Union

import docker
import secrets
import io
import atexit
import logging

from ..docker_commandline_code_executor import _wait_for_ready

@@ -18,9 +19,8 @@ if sys.version_info >= (3, 11):
else:
from typing_extensions import Self


from .jupyter_client import JupyterClient
from .base import JupyterConnectable, JupyterConnectionInfo
from .jupyter_client import JupyterClient


class DockerJupyterServer(JupyterConnectable):


+ 1
- 1
autogen/coding/jupyter/embedded_ipython_code_executor.py View File

@@ -1,9 +1,9 @@
import base64
import json
import os
from pathlib import Path
import re
import uuid
from pathlib import Path
from queue import Empty
from typing import Any, ClassVar, List



+ 4
- 4
autogen/coding/jupyter/jupyter_client.py View File

@@ -1,22 +1,22 @@
from __future__ import annotations

import sys
from dataclasses import dataclass
from types import TracebackType
from typing import Any, Dict, List, Optional, Type, cast
import sys

if sys.version_info >= (3, 11):
from typing import Self
else:
from typing_extensions import Self

import datetime
import json
import uuid
import datetime
import requests
from requests.adapters import HTTPAdapter, Retry

import requests
import websocket
from requests.adapters import HTTPAdapter, Retry
from websocket import WebSocket

from .base import JupyterConnectionInfo


+ 3
- 4
autogen/coding/jupyter/jupyter_code_executor.py View File

@@ -1,12 +1,12 @@
import base64
import json
import os
from pathlib import Path
import re
from types import TracebackType
import sys
import uuid
from pathlib import Path
from types import TracebackType
from typing import Any, ClassVar, List, Optional, Type, Union
import sys

from autogen.coding.utils import silence_pip

@@ -15,7 +15,6 @@ if sys.version_info >= (3, 11):
else:
from typing_extensions import Self


from ...agentchat.agent import LLMAgent
from ..base import CodeBlock, CodeExecutor, CodeExtractor, IPythonCodeResult
from ..markdown_code_extractor import MarkdownCodeExtractor


+ 6
- 6
autogen/coding/jupyter/local_jupyter_server.py View File

@@ -1,14 +1,14 @@
from __future__ import annotations
from types import TracebackType

from typing import Optional, Type, Union, cast
import subprocess
import signal
import sys
import atexit
import json
import secrets
import signal
import socket
import atexit
import subprocess
import sys
from types import TracebackType
from typing import Optional, Type, Union, cast

if sys.version_info >= (3, 11):
from typing import Self


+ 3
- 5
autogen/coding/local_commandline_code_executor.py View File

@@ -1,21 +1,19 @@
from hashlib import md5
import os
from pathlib import Path
import re
import subprocess
import sys
import uuid
import warnings
from hashlib import md5
from pathlib import Path
from typing import ClassVar, List, Union

from ..agentchat.agent import LLMAgent
from ..code_utils import TIMEOUT_MSG, WIN32, _cmd, execute_code
from .base import CodeBlock, CodeExecutor, CodeExtractor, CommandLineCodeResult
from .markdown_code_extractor import MarkdownCodeExtractor

from .utils import _get_file_name_from_content, silence_pip

import subprocess

__all__ = ("LocalCommandLineCodeExecutor",)




+ 1
- 1
autogen/coding/markdown_code_extractor.py View File

@@ -2,8 +2,8 @@ import re
from typing import Any, Dict, List, Optional, Union

from ..code_utils import CODE_BLOCK_PATTERN, UNKNOWN, content_str, infer_lang
from .base import CodeBlock, CodeExtractor
from ..types import UserMessageImageContentPart, UserMessageTextContentPart
from .base import CodeBlock, CodeExtractor

__all__ = ("MarkdownCodeExtractor",)



+ 2
- 2
autogen/graph_utils.py View File

@@ -1,5 +1,5 @@
from typing import Dict, List
import logging
from typing import Dict, List

from autogen.agentchat.groupchat import Agent

@@ -115,8 +115,8 @@ def visualize_speaker_transitions_dict(speaker_transitions_dict: dict, agents: L
Visualize the speaker_transitions_dict using networkx.
"""
try:
import networkx as nx
import matplotlib.pyplot as plt
import networkx as nx
except ImportError as e:
logging.fatal("Failed to import networkx or matplotlib. Try running 'pip install autogen[graphs]'")
raise e


+ 3
- 3
autogen/logger/base_logger.py View File

@@ -1,11 +1,11 @@
from __future__ import annotations

from abc import ABC, abstractmethod
from typing import Any, Dict, List, TYPE_CHECKING, Union
import sqlite3
import uuid
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Dict, List, Union

from openai import OpenAI, AzureOpenAI
from openai import AzureOpenAI, OpenAI
from openai.types.chat import ChatCompletion

if TYPE_CHECKING:


+ 1
- 0
autogen/logger/logger_factory.py View File

@@ -1,4 +1,5 @@
from typing import Any, Dict, Optional

from autogen.logger.base_logger import BaseLogger
from autogen.logger.sqlite_logger import SqliteLogger



+ 4
- 4
autogen/logger/sqlite_logger.py View File

@@ -6,16 +6,16 @@ import os
import sqlite3
import threading
import uuid
from typing import TYPE_CHECKING, Any, Dict, List, Tuple, Union

from openai import AzureOpenAI, OpenAI
from openai.types.chat import ChatCompletion

from autogen.logger.base_logger import BaseLogger
from autogen.logger.logger_utils import get_current_ts, to_dict

from openai import OpenAI, AzureOpenAI
from openai.types.chat import ChatCompletion
from typing import Any, Dict, List, TYPE_CHECKING, Tuple, Union
from .base_logger import LLMConfig


if TYPE_CHECKING:
from autogen import ConversableAgent, OpenAIWrapper



+ 2
- 1
autogen/math_utils.py View File

@@ -1,5 +1,6 @@
from typing import Optional
from autogen import oai, DEFAULT_MODEL

from autogen import DEFAULT_MODEL, oai

_MATH_PROMPT = "{problem} Solve the problem carefully. Simplify your answer as much as possible. Put the final answer in \\boxed{{}}."
_MATH_CONFIG = {


+ 7
- 7
autogen/oai/__init__.py View File

@@ -1,15 +1,15 @@
from autogen.oai.client import OpenAIWrapper, ModelClient
from autogen.oai.completion import Completion, ChatCompletion
from autogen.cache.cache import Cache
from autogen.oai.client import ModelClient, OpenAIWrapper
from autogen.oai.completion import ChatCompletion, Completion
from autogen.oai.openai_utils import (
get_config_list,
config_list_from_dotenv,
config_list_from_json,
config_list_from_models,
config_list_gpt4_gpt35,
config_list_openai_aoai,
config_list_from_models,
config_list_from_json,
config_list_from_dotenv,
filter_config,
get_config_list,
)
from autogen.cache.cache import Cache

__all__ = [
"OpenAIWrapper",


+ 10
- 11
autogen/oai/client.py View File

@@ -1,21 +1,19 @@
from __future__ import annotations

import sys
from typing import Any, List, Optional, Dict, Callable, Tuple, Union
import logging
import inspect
import logging
import sys
import uuid
from flaml.automl.logger import logger_formatter
from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Union

from flaml.automl.logger import logger_formatter
from pydantic import BaseModel
from typing import Protocol

from autogen.cache.cache import Cache
from autogen.oai.openai_utils import get_key, is_valid_api_key, OAI_PRICE1K
from autogen.token_count_utils import count_token

from autogen.runtime_logging import logging_enabled, log_chat_completion, log_new_client, log_new_wrapper
from autogen.logger.logger_utils import get_current_ts
from autogen.oai.openai_utils import OAI_PRICE1K, get_key, is_valid_api_key
from autogen.runtime_logging import log_chat_completion, log_new_client, log_new_wrapper, logging_enabled
from autogen.token_count_utils import count_token

TOOL_ENABLED = False
try:
@@ -26,14 +24,15 @@ except ImportError:
AzureOpenAI = object
else:
# raises exception if openai>=1 is installed and something is wrong with imports
from openai import OpenAI, AzureOpenAI, APIError, APITimeoutError, __version__ as OPENAIVERSION
from openai import APIError, APITimeoutError, AzureOpenAI, OpenAI
from openai import __version__ as OPENAIVERSION
from openai.resources import Completions
from openai.types.chat import ChatCompletion
from openai.types.chat.chat_completion import ChatCompletionMessage, Choice # type: ignore [attr-defined]
from openai.types.chat.chat_completion_chunk import (
ChoiceDeltaFunctionCall,
ChoiceDeltaToolCall,
ChoiceDeltaToolCallFunction,
ChoiceDeltaFunctionCall,
)
from openai.types.completion import Completion
from openai.types.completion_usage import CompletionUsage


+ 12
- 16
autogen/oai/completion.py View File

@@ -1,28 +1,24 @@
from time import sleep
import logging
import time
from typing import List, Optional, Dict, Callable, Union
import sys
import shutil
import sys
import time
from collections import defaultdict
from time import sleep
from typing import Callable, Dict, List, Optional, Union

import numpy as np
from flaml import tune, BlendSearch
from flaml.tune.space import is_constant
from flaml import BlendSearch, tune
from flaml.automl.logger import logger_formatter
from flaml.tune.space import is_constant

from .openai_utils import get_key
from collections import defaultdict

try:
import diskcache
import openai
from openai import (
RateLimitError,
APIError,
BadRequestError,
APIConnectionError,
Timeout,
AuthenticationError,
)
from openai import APIConnectionError, APIError, AuthenticationError, BadRequestError
from openai import Completion as openai_Completion
import diskcache
from openai import RateLimitError, Timeout

ERROR = None
assert openai.__version__ < "1"


+ 0
- 1
autogen/oai/openai_utils.py View File

@@ -7,7 +7,6 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Union

from dotenv import find_dotenv, load_dotenv

from openai import OpenAI
from openai.types.beta.assistant import Assistant



+ 9
- 5
autogen/retrieve_utils.py View File

@@ -1,18 +1,22 @@
from typing import List, Union, Callable
import glob
import os
import requests
from typing import Callable, List, Union
from urllib.parse import urlparse
import glob
import chromadb
import requests

if chromadb.__version__ < "0.4.15":
from chromadb.api import API
else:
from chromadb.api import ClientAPI as API
from chromadb.api.types import QueryResult
import chromadb.utils.embedding_functions as ef

import logging

import chromadb.utils.embedding_functions as ef
import pypdf
from chromadb.api.types import QueryResult

from autogen.token_count_utils import count_token

try:


+ 5
- 5
autogen/runtime_logging.py View File

@@ -1,16 +1,16 @@
from __future__ import annotations

from autogen.logger.logger_factory import LoggerFactory
from autogen.logger.base_logger import LLMConfig

import logging
import sqlite3
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
import uuid
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union

from openai import OpenAI, AzureOpenAI
from openai import AzureOpenAI, OpenAI
from openai.types.chat import ChatCompletion

from autogen.logger.base_logger import LLMConfig
from autogen.logger.logger_factory import LoggerFactory

if TYPE_CHECKING:
from autogen import ConversableAgent, OpenAIWrapper



+ 3
- 3
autogen/token_count_utils.py View File

@@ -1,9 +1,9 @@
from typing import List, Union, Dict
import logging
import json
import tiktoken
import logging
import re
from typing import Dict, List, Union

import tiktoken

logger = logging.getLogger(__name__)



+ 5
- 0
pyproject.toml View File

@@ -99,3 +99,8 @@ warn_unused_ignores = true
disallow_incomplete_defs = true
disallow_untyped_decorators = true
disallow_any_unimported = true

[tool.isort]

profile = "black"
line_length = 120

+ 2
- 3
samples/apps/auto-anny/bot.py View File

@@ -1,11 +1,10 @@
import os
import logging
import logging.handlers
import os

import discord
from discord.ext import commands

from agent_utils import solve_task
from discord.ext import commands

logger = logging.getLogger("anny")
logger.setLevel(logging.INFO)


+ 1
- 1
samples/apps/autogen-studio/autogenstudio/__init__.py View File

@@ -1,4 +1,4 @@
from .chatmanager import *
from .workflowmanager import *
from .datamodel import *
from .version import __version__
from .workflowmanager import *

+ 7
- 5
samples/apps/autogen-studio/autogenstudio/chatmanager.py View File

@@ -1,12 +1,14 @@
import asyncio
from datetime import datetime
import json
from queue import Queue
import time
from typing import Any, List, Dict, Optional, Tuple
import os
from fastapi import WebSocket, WebSocketDisconnect
import time
from datetime import datetime
from queue import Queue
from typing import Any, Dict, List, Optional, Tuple

import websockets
from fastapi import WebSocket, WebSocketDisconnect

from .datamodel import AgentWorkFlowConfig, Message, SocketMessage
from .utils import extract_successful_code_blocks, get_modified_files, summarize_chat_history
from .workflowmanager import AutoGenWorkFlowManager


+ 3
- 2
samples/apps/autogen-studio/autogenstudio/cli.py View File

@@ -1,10 +1,11 @@
import os
from typing_extensions import Annotated
import typer
import uvicorn
from typing_extensions import Annotated

from .version import VERSION
from .utils.dbutils import DBManager
from .version import VERSION

app = typer.Typer()



+ 2
- 1
samples/apps/autogen-studio/autogenstudio/datamodel.py View File

@@ -1,8 +1,9 @@
import uuid
from dataclasses import asdict, field
from datetime import datetime
from typing import Any, Callable, Dict, List, Literal, Optional, Union

from pydantic.dataclasses import dataclass
from dataclasses import asdict, field


@dataclass


+ 3
- 3
samples/apps/autogen-studio/autogenstudio/utils/dbutils.py View File

@@ -1,13 +1,13 @@
import json
import logging
import os
import sqlite3
import threading
import os
from typing import Any, List, Dict, Optional, Tuple
from typing import Any, Dict, List, Optional, Tuple
from ..datamodel import AgentFlowSpec, AgentWorkFlowConfig, Gallery, Message, Model, Session, Skill
from ..version import __version__ as __db_version__


VERSION_TABLE_SQL = """
CREATE TABLE IF NOT EXISTS version (



+ 6
- 3
samples/apps/autogen-studio/autogenstudio/utils/utils.py View File

@@ -1,14 +1,17 @@
import base64
import hashlib
from typing import List, Dict, Tuple, Union
import os
import re
import shutil
from pathlib import Path
import re
from typing import Dict, List, Tuple, Union

from dotenv import load_dotenv

import autogen
from autogen.oai.client import OpenAIWrapper

from ..datamodel import AgentConfig, AgentFlowSpec, AgentWorkFlowConfig, LLMConfig, Model, Skill
from dotenv import load_dotenv
from ..version import APP_NAME




+ 6
- 12
samples/apps/autogen-studio/autogenstudio/web/app.py View File

@@ -1,26 +1,20 @@
import asyncio
from contextlib import asynccontextmanager
import json
import os
import queue
import threading
import traceback
from fastapi import FastAPI, WebSocket, WebSocketDisconnect
from contextlib import asynccontextmanager

from fastapi import FastAPI, HTTPException, WebSocket, WebSocketDisconnect
from fastapi.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles
from fastapi import HTTPException
from openai import OpenAIError
from ..version import VERSION, APP_NAME

from ..datamodel import (
DBWebRequestModel,
DeleteMessageWebRequestModel,
Message,
Session,
)
from ..utils import md5_hash, init_app_folders, DBManager, dbutils, test_model
from ..chatmanager import AutoGenChatManager, WebSocketConnectionManager

from ..datamodel import DBWebRequestModel, DeleteMessageWebRequestModel, Message, Session
from ..utils import DBManager, dbutils, init_app_folders, md5_hash, test_model
from ..version import APP_NAME, VERSION

managers = {"chat": None} # manage calls to autogen
# Create thread-safe queue for messages between api thread and autogen threads


+ 4
- 3
samples/apps/autogen-studio/autogenstudio/workflowmanager.py View File

@@ -1,12 +1,13 @@
import os
from typing import List, Optional, Union, Dict
from datetime import datetime
from typing import Dict, List, Optional, Union

from requests import Session

import autogen

from .datamodel import AgentConfig, AgentFlowSpec, AgentWorkFlowConfig, Message, SocketMessage
from .utils import get_skills_from_prompt, clear_folder, sanitize_model
from datetime import datetime
from .utils import clear_folder, get_skills_from_prompt, sanitize_model


class AutoGenWorkFlowManager:


+ 5
- 3
samples/apps/cap/py/autogencap/Actor.py View File

@@ -1,9 +1,11 @@
import zmq
import threading
import traceback
import time
from .DebugLog import Debug, Info
import traceback

import zmq

from .Config import xpub_url
from .DebugLog import Debug, Info


class Actor:


+ 4
- 2
samples/apps/cap/py/autogencap/ActorConnector.py View File

@@ -1,11 +1,13 @@
# Agent_Sender takes a zmq context, Topic and creates a
# socket that can publish to that topic. It exposes this functionality
# using send_msg method
import zmq
import time
import uuid

import zmq

from .Config import xpub_url, xsub_url
from .DebugLog import Debug, Error
from .Config import xsub_url, xpub_url


class ActorConnector:


+ 3
- 2
samples/apps/cap/py/autogencap/Broker.py View File

@@ -1,8 +1,9 @@
import threading
import time

import zmq
import threading
from autogencap.Config import xpub_url, xsub_url
from autogencap.DebugLog import Debug, Info, Warn
from autogencap.Config import xsub_url, xpub_url


class Broker:


+ 3
- 2
samples/apps/cap/py/autogencap/DebugLog.py View File

@@ -1,6 +1,7 @@
import threading
import datetime
from autogencap.Config import LOG_LEVEL, IGNORED_LOG_CONTEXTS
import threading

from autogencap.Config import IGNORED_LOG_CONTEXTS, LOG_LEVEL
from termcolor import colored

# Define log levels as constants


+ 8
- 7
samples/apps/cap/py/autogencap/DirectorySvc.py View File

@@ -1,13 +1,14 @@
from autogencap.Constants import Directory_Svc_Topic
from autogencap.Config import xpub_url, xsub_url
from autogencap.DebugLog import Debug, Info, Error
from autogencap.ActorConnector import ActorConnector
from autogencap.Actor import Actor
from autogencap.proto.CAP_pb2 import ActorRegistration, ActorInfo, ActorLookup, ActorLookupResponse, Ping, Pong
import zmq
import threading
import time

import zmq
from autogencap.Actor import Actor
from autogencap.ActorConnector import ActorConnector
from autogencap.Config import xpub_url, xsub_url
from autogencap.Constants import Directory_Svc_Topic
from autogencap.DebugLog import Debug, Error, Info
from autogencap.proto.CAP_pb2 import ActorInfo, ActorLookup, ActorLookupResponse, ActorRegistration, Ping, Pong

# TODO (Future DirectorySv PR) use actor description, network_id, other properties to make directory
# service more generic and powerful



+ 6
- 4
samples/apps/cap/py/autogencap/LocalActorNetwork.py View File

@@ -1,12 +1,14 @@
import time

import zmq
from .DebugLog import Debug, Warn

from .Actor import Actor
from .ActorConnector import ActorConnector
from .Broker import Broker
from .DirectorySvc import DirectorySvc
from .Constants import Termination_Topic
from .Actor import Actor
from .DebugLog import Debug, Warn
from .DirectorySvc import DirectorySvc
from .proto.CAP_pb2 import ActorInfo
import time

# TODO: remove time import



+ 3
- 1
samples/apps/cap/py/autogencap/ag_adapter/AG2CAP.py View File

@@ -1,8 +1,10 @@
import time
from typing import Callable, Dict, List, Optional, Union

from autogen import Agent, ConversableAgent
from .AutoGenConnector import AutoGenConnector
from ..LocalActorNetwork import LocalActorNetwork
from .AutoGenConnector import AutoGenConnector


class AG2CAP(ConversableAgent):


+ 2
- 0
samples/apps/cap/py/autogencap/ag_adapter/AutoGenConnector.py View File

@@ -1,5 +1,7 @@
from typing import Dict, Optional, Union

from autogen import Agent

from ..ActorConnector import ActorConnector
from ..proto.Autogen_pb2 import GenReplyReq, GenReplyResp, PrepChat, ReceiveReq, Terminate



+ 4
- 2
samples/apps/cap/py/autogencap/ag_adapter/CAP2AG.py View File

@@ -1,11 +1,13 @@
from enum import Enum
from typing import Optional

from autogen import ConversableAgent

from ..DebugLog import Debug, Error, Info, Warn, shorten
from ..LocalActorNetwork import LocalActorNetwork
from ..proto.Autogen_pb2 import GenReplyReq, GenReplyResp, PrepChat, ReceiveReq, Terminate
from .AGActor import AGActor
from .AG2CAP import AG2CAP
from autogen import ConversableAgent
from .AGActor import AGActor


class CAP2AG(AGActor):


+ 4
- 2
samples/apps/cap/py/autogencap/ag_adapter/CAPGroupChat.py View File

@@ -1,8 +1,10 @@
from autogen import Agent, AssistantAgent, GroupChat
from typing import List

from autogencap.ag_adapter.AG2CAP import AG2CAP
from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.LocalActorNetwork import LocalActorNetwork
from typing import List

from autogen import Agent, AssistantAgent, GroupChat


class CAPGroupChat(GroupChat):


+ 5
- 3
samples/apps/cap/py/autogencap/ag_adapter/CAPGroupChatManager.py View File

@@ -1,9 +1,11 @@
from autogen import GroupChatManager
import time

from autogencap.ActorConnector import ActorConnector
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.ag_adapter.CAPGroupChat import CAPGroupChat
import time
from autogencap.LocalActorNetwork import LocalActorNetwork

from autogen import GroupChatManager


class CAPGroupChatManager:


+ 6
- 2
samples/apps/cap/py/autogencap/proto/Autogen_pb2.pyi View File

@@ -1,7 +1,11 @@
from google.protobuf.internal import containers as _containers
from typing import ClassVar as _ClassVar
from typing import Mapping as _Mapping
from typing import Optional as _Optional
from typing import Union as _Union

from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import ClassVar as _ClassVar, Mapping as _Mapping, Optional as _Optional, Union as _Union
from google.protobuf.internal import containers as _containers

DESCRIPTOR: _descriptor.FileDescriptor



+ 7
- 8
samples/apps/cap/py/autogencap/proto/CAP_pb2.pyi View File

@@ -1,13 +1,12 @@
from google.protobuf.internal import containers as _containers
from typing import ClassVar as _ClassVar
from typing import Iterable as _Iterable
from typing import Mapping as _Mapping
from typing import Optional as _Optional
from typing import Union as _Union

from google.protobuf import descriptor as _descriptor
from google.protobuf import message as _message
from typing import (
ClassVar as _ClassVar,
Iterable as _Iterable,
Mapping as _Mapping,
Optional as _Optional,
Union as _Union,
)
from google.protobuf.internal import containers as _containers

DESCRIPTOR: _descriptor.FileDescriptor



+ 1
- 1
samples/apps/cap/py/autogencap/setup.py View File

@@ -1,4 +1,4 @@
from setuptools import setup, find_packages
from setuptools import find_packages, setup

setup(
name="autogencap",


+ 3
- 2
samples/apps/cap/py/demo/App.py View File

@@ -3,16 +3,17 @@ Demo App
"""

import argparse

import _paths
from autogencap.Config import LOG_LEVEL, IGNORED_LOG_CONTEXTS
import autogencap.DebugLog as DebugLog
from SimpleActorDemo import simple_actor_demo
from AGDemo import ag_demo
from AGGroupChatDemo import ag_groupchat_demo
from autogencap.Config import IGNORED_LOG_CONTEXTS, LOG_LEVEL
from CAPAutGenGroupDemo import cap_ag_group_demo
from CAPAutoGenPairDemo import cap_ag_pair_demo
from ComplexActorDemo import complex_actor_demo
from RemoteAGDemo import remote_ag_demo
from SimpleActorDemo import simple_actor_demo

####################################################################################################



+ 2
- 2
samples/apps/cap/py/demo/AppAgents.py View File

@@ -4,10 +4,10 @@ Each agent represents a different role and knows how to connect to external syst
to retrieve information.
"""

from autogencap.Actor import Actor
from autogencap.ActorConnector import ActorConnector
from autogencap.DebugLog import Debug, Info, shorten
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ActorConnector import ActorConnector
from autogencap.Actor import Actor


class GreeterAgent(Actor):


+ 4
- 3
samples/apps/cap/py/demo/CAPAutGenGroupDemo.py View File

@@ -1,8 +1,9 @@
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ag_adapter.CAPGroupChat import CAPGroupChat
from autogencap.ag_adapter.CAPGroupChatManager import CAPGroupChatManager
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork

from autogen import AssistantAgent, UserProxyAgent, config_list_from_json


def cap_ag_group_demo():


+ 4
- 2
samples/apps/cap/py/demo/CAPAutoGenPairDemo.py View File

@@ -1,9 +1,11 @@
import time
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
from autogencap.DebugLog import Info

from autogencap.ag_adapter.CAPPair import CAPPair
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork

from autogen import AssistantAgent, UserProxyAgent, config_list_from_json


def cap_ag_pair_demo():
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST")


+ 3
- 2
samples/apps/cap/py/demo/ComplexActorDemo.py View File

@@ -1,7 +1,8 @@
import time
from termcolor import colored
from autogencap.LocalActorNetwork import LocalActorNetwork

from AppAgents import FidelityAgent, FinancialPlannerAgent, PersonalAssistant, QuantAgent, RiskManager
from autogencap.LocalActorNetwork import LocalActorNetwork
from termcolor import colored


def complex_actor_demo():


+ 1
- 0
samples/apps/cap/py/demo/SimpleActorDemo.py View File

@@ -1,4 +1,5 @@
import time

from AppAgents import GreeterAgent
from autogencap.LocalActorNetwork import LocalActorNetwork



+ 1
- 1
samples/apps/cap/py/demo/_paths.py View File

@@ -1,7 +1,7 @@
# Add autogencap to system path in case autogencap is not pip installed
# Since this library has not been published to PyPi, it is not easy to install using pip
import sys
import os
import sys

absparent = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(absparent)

+ 4
- 2
samples/apps/cap/py/demo/standalone/Assistant.py View File

@@ -1,9 +1,11 @@
import time

import _paths
from autogen import AssistantAgent, config_list_from_json
from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ag_adapter.CAP2AG import CAP2AG

from autogen import AssistantAgent, config_list_from_json


# Starts the Broker and the Assistant. The UserProxy is started separately.


+ 5
- 3
samples/apps/cap/py/demo/standalone/UserProxy.py View File

@@ -1,10 +1,12 @@
import time

import _paths
from autogen import UserProxyAgent, config_list_from_json
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.Config import IGNORED_LOG_CONTEXTS
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork

from autogen import UserProxyAgent, config_list_from_json


# Starts the Broker and the Assistant. The UserProxy is started separately.


+ 1
- 1
samples/apps/cap/py/demo/standalone/_paths.py View File

@@ -1,7 +1,7 @@
# Add autogencap to system path in case autogencap is not pip installed
# Since this library has not been published to PyPi, it is not easy to install using pip
import sys
import os
import sys

absparent = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(absparent)

+ 1
- 1
samples/simple_chat.py View File

@@ -1,4 +1,4 @@
from autogen import UserProxyAgent, ConversableAgent, config_list_from_json
from autogen import ConversableAgent, UserProxyAgent, config_list_from_json


def main():


+ 3
- 2
samples/tools/autogenbench/autogenbench/cli.py View File

@@ -1,8 +1,9 @@
import sys
from .version import __version__
from .run_cmd import run_cli

from .clone_cmd import clone_cli
from .run_cmd import run_cli
from .tabulate_cmd import tabulate_cli
from .version import __version__


def main(args=None):


+ 4
- 2
samples/tools/autogenbench/autogenbench/clone_cmd.py View File

@@ -1,7 +1,9 @@
import os
import json
import argparse
import json
import os

import requests

from .load_module import load_module

# Figure out where everything is


+ 1
- 1
samples/tools/autogenbench/autogenbench/load_module.py View File

@@ -1,6 +1,6 @@
import importlib.util
import os
import sys
import importlib.util


def load_module(module_path):


+ 8
- 5
samples/tools/autogenbench/autogenbench/run_cmd.py View File

@@ -1,16 +1,19 @@
import os
import argparse
import errno
import json
import os
import pathlib
import random
import shutil
import subprocess
import json
import sys
import time
import pathlib
import argparse

import docker
import random
from autogen import config_list_from_json
from autogen.oai.openai_utils import filter_config

from .version import __version__

# Figure out where everything is


+ 3
- 1
samples/tools/autogenbench/autogenbench/tabulate_cmd.py View File

@@ -1,7 +1,9 @@
import argparse
import os
import sys
import argparse
import tabulate as tb

from .load_module import load_module

# Figure out where everything is


+ 5
- 3
samples/tools/autogenbench/autogenbench/template/testbed_utils.py View File

@@ -1,8 +1,10 @@
from pkg_resources import packaging
from datetime import datetime
import json
import os
from datetime import datetime

from pkg_resources import packaging

import autogen
import json

AUTOGEN_VERSION = packaging.version.parse(autogen.__version__)



+ 1
- 0
samples/tools/autogenbench/scenarios/AutoGPT/Scripts/custom_tabulate.py View File

@@ -1,5 +1,6 @@
import os
import sys

from autogenbench.tabulate_cmd import default_tabulate




+ 4
- 3
samples/tools/autogenbench/scenarios/AutoGPT/Scripts/init_tasks.py View File

@@ -3,12 +3,13 @@
# (default: ../scenarios/human_eval_two_agents_gpt4.jsonl and ./scenarios/human_eval_two_agents_gpt35.jsonl)
#

import base64
import glob
import json
import os
import sys
import glob
import base64
import re
import sys

from huggingface_hub import snapshot_download

SCRIPT_PATH = os.path.realpath(__file__)


+ 2
- 2
samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/check.py View File

@@ -2,11 +2,11 @@
# ruff: noqa: F821

import glob
import json
import os
import shutil
import subprocess
import sys
import shutil
import json


def scoring(content: str, should_contain: list, should_not_contain: list):


+ 3
- 1
samples/tools/autogenbench/scenarios/AutoGPT/Templates/TwoAgents/scenario.py View File

@@ -2,9 +2,11 @@
# ruff: noqa: E722

import traceback
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
import testbed_utils

from autogen import AssistantAgent, UserProxyAgent, config_list_from_json

# Assistant agent can call check.py to check if all the unit tests have passed
testbed_utils.init()



+ 4
- 2
samples/tools/autogenbench/scenarios/Examples/Templates/ThreeAgents/scenario.py View File

@@ -1,8 +1,10 @@
import os
import json
import autogen
import os

import testbed_utils

import autogen

testbed_utils.init()
##############################



+ 4
- 2
samples/tools/autogenbench/scenarios/Examples/Templates/TwoAgents/scenario.py View File

@@ -1,8 +1,10 @@
import os
import json
import autogen
import os

import testbed_utils

import autogen

testbed_utils.init()
##############################



Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save