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
Unified 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: trailing-whitespace
- id: end-of-file-fixer - id: end-of-file-fixer
- id: no-commit-to-branch - 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 - repo: https://github.com/psf/black
rev: 24.3.0 rev: 24.3.0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/charliermarsh/ruff-pre-commit - repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.3
rev: v0.3.4
hooks: hooks:
- id: ruff - id: ruff
args: ["--fix"] args: ["--fix"]


+ 4
- 4
autogen/__init__.py View File

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

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

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


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


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

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


__all__ = ( __all__ = (


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

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


from autogen.runtime_logging import log_new_agent, logging_enabled

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




class AssistantAgent(ConversableAgent): class AssistantAgent(ConversableAgent):


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

@@ -1,14 +1,14 @@
import asyncio 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 datetime
import logging
import warnings 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__) logger = logging.getLogger(__name__)
Prerequisite = Tuple[int, int] 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 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): def _config_check(config: Dict):


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

@@ -1,9 +1,10 @@
import sys 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 import tiktoken
from termcolor import colored

from autogen import ConversableAgent, token_count_utils




class TransformChatHistory: 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 PIL.Image import Image


from autogen import Agent, ConversableAgent, code_utils from autogen import Agent, ConversableAgent, code_utils
from autogen.cache import Cache
from autogen.agentchat.contrib import img_utils from autogen.agentchat.contrib import img_utils
from autogen.agentchat.contrib.capabilities.agent_capability import AgentCapability from autogen.agentchat.contrib.capabilities.agent_capability import AgentCapability
from autogen.agentchat.contrib.text_analyzer_agent import TextAnalyzerAgent 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." SYSTEM_MESSAGE = "You've been given the special ability to generate images."
DESCRIPTION_MESSAGE = "This agent has the 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 os
import pickle
from typing import Dict, Optional, Union from typing import Dict, Optional, Union

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

from ....formatting_utils import colored 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 asyncio
import logging
import copy
import inspect 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 autogen.token_count_utils import count_token, get_max_token_limit, num_tokens_from_functions


from ...formatting_utils import colored 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 json
import time
import logging 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 import OpenAIWrapper
from autogen.oai.openai_utils import retrieve_assistants_by_name
from autogen.agentchat.agent import Agent 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__) logger = logging.getLogger(__name__)




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

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

import replicate import replicate
import requests 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.img_utils import get_image_data, llava_formatter
from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent from autogen.agentchat.contrib.multimodal_conversable_agent import MultimodalConversableAgent
from autogen.code_utils import content_str from autogen.code_utils import content_str
from ...formatting_utils import colored


from ...formatting_utils import colored


logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)




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

@@ -1,15 +1,15 @@
import re
import os 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 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._pydantic import PYDANTIC_V1
from autogen.agentchat import Agent, UserProxyAgent 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 from autogen.math_utils import get_answer



PROMPTS = { PROMPTS = {
# default # default
"default": """Let's use Python to solve a math problem. "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 import OpenAIWrapper
from autogen.agentchat import Agent, ConversableAgent 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 autogen.code_utils import content_str


from ..._pydantic import model_dump from ..._pydantic import model_dump



DEFAULT_LMM_SYS_MSG = """You are a helpful AI assistant.""" DEFAULT_LMM_SYS_MSG = """You are a helpful AI assistant."""
DEFAULT_MODEL = "gpt-4-vision-preview" 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 typing import Callable, Dict, List, Optional


from autogen.agentchat.contrib.retrieve_user_proxy_agent import RetrieveUserProxyAgent 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__) logger = logging.getLogger(__name__)


try: try:
import fastembed
from qdrant_client import QdrantClient, models from qdrant_client import QdrantClient, models
from qdrant_client.fastembed_common import QueryResponse from qdrant_client.fastembed_common import QueryResponse
import fastembed
except ImportError as e: except ImportError as e:
logging.fatal("Failed to import qdrant_client with fastembed. Try running 'pip install qdrant_client[fastembed]'") logging.fatal("Failed to import qdrant_client with fastembed. Try running 'pip install qdrant_client[fastembed]'")
raise e 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.agent import Agent
from autogen.agentchat.assistant_agent import AssistantAgent from autogen.agentchat.assistant_agent import AssistantAgent
from typing import Dict, Optional, Union, List, Tuple, Any




class RetrieveAssistantAgent(AssistantAgent): class RetrieveAssistantAgent(AssistantAgent):


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

@@ -1,19 +1,20 @@
import re 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 from IPython import get_ipython


try: try:
import chromadb import chromadb
except ImportError: except ImportError:
raise ImportError("Please install dependencies first. `pip install pyautogen[retrievechat]`") 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.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.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 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: 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 # ruff: noqa: E722
import copy
import json import json
import traceback import traceback
import copy
from dataclasses import dataclass 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): 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 import oai
from autogen.agentchat.agent import Agent from autogen.agentchat.agent import Agent
from autogen.agentchat.assistant_agent import ConversableAgent 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. system_message = """You are an expert in text analysis.
The user will give you TEXT to analyze. 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 copy
import json
import logging import logging
import re import re
from dataclasses import dataclass 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 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 ...browser_utils import SimpleTextBrowser
from ...code_utils import content_str 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 ...oai.openai_utils import filter_config
from ...token_count_utils import count_token, get_max_token_limit


logger = logging.getLogger(__name__) 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 typing import Callable, Dict, List, Literal, Optional, Union


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




class UserProxyAgent(ConversableAgent): 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 from .agent import Agent






+ 6
- 5
autogen/browser_utils.py View File

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

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


# Optional PDF support # Optional PDF support
IS_PDF_CAPABLE = False 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 abc import ABC, abstractmethod
from types import TracebackType from types import TracebackType
from typing import Any, Optional, Type from typing import Any, Optional, Type
import sys


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


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

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

import sys
from types import TracebackType 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 .abstract_cache_base import AbstractCache

from .cache_factory import CacheFactory from .cache_factory import CacheFactory


import sys

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


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

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

from .abstract_cache_base import AbstractCache from .abstract_cache_base import AbstractCache
from .disk_cache import DiskCache from .disk_cache import DiskCache


import logging



class CacheFactory: class CacheFactory:
@staticmethod @staticmethod


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

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

import diskcache import diskcache

from .abstract_cache_base import AbstractCache from .abstract_cache_base import AbstractCache
import sys


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


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

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

import redis import redis
import sys
from .abstract_cache_base import AbstractCache from .abstract_cache_base import AbstractCache


if sys.version_info >= (3, 11): 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 hashlib import md5
from typing import Any, Callable, Dict, List, Optional, Tuple, Union from typing import Any, Callable, Dict, List, Optional, Tuple, Union


from autogen import oai

import docker import docker


from autogen import oai

from .types import UserMessageImageContentPart, UserMessageTextContentPart from .types import UserMessageImageContentPart, UserMessageTextContentPart


SENTINEL = object() SENTINEL = object()


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

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


__all__ = ( __all__ = (
"CodeBlock", "CodeBlock",


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

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

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


from pydantic import BaseModel, Field from pydantic import BaseModel, Field


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

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

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

import docker import docker
from docker.errors import ImageNotFound 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 ..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 from .markdown_code_extractor import MarkdownCodeExtractor
import sys
from .utils import _get_file_name_from_content, silence_pip


if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
from typing import Self 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",) __all__ = ("CodeExecutorFactory",)




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

@@ -1,9 +1,9 @@
from .base import JupyterConnectable, JupyterConnectionInfo from .base import JupyterConnectable, JupyterConnectionInfo
from .jupyter_client import JupyterClient
from .local_jupyter_server import LocalJupyterServer
from .docker_jupyter_server import DockerJupyterServer from .docker_jupyter_server import DockerJupyterServer
from .embedded_ipython_code_executor import EmbeddedIPythonCodeExecutor from .embedded_ipython_code_executor import EmbeddedIPythonCodeExecutor
from .jupyter_client import JupyterClient
from .jupyter_code_executor import JupyterCodeExecutor from .jupyter_code_executor import JupyterCodeExecutor
from .local_jupyter_server import LocalJupyterServer


__all__ = [ __all__ = [
"JupyterConnectable", "JupyterConnectable",


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

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


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

import docker import docker
import secrets
import io
import atexit
import logging


from ..docker_commandline_code_executor import _wait_for_ready from ..docker_commandline_code_executor import _wait_for_ready


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



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




class DockerJupyterServer(JupyterConnectable): class DockerJupyterServer(JupyterConnectable):


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

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




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

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


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


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


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


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


from .base import JupyterConnectionInfo from .base import JupyterConnectionInfo


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

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


from autogen.coding.utils import silence_pip from autogen.coding.utils import silence_pip


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



from ...agentchat.agent import LLMAgent from ...agentchat.agent import LLMAgent
from ..base import CodeBlock, CodeExecutor, CodeExtractor, IPythonCodeResult from ..base import CodeBlock, CodeExecutor, CodeExtractor, IPythonCodeResult
from ..markdown_code_extractor import MarkdownCodeExtractor 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 __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 json
import secrets import secrets
import signal
import socket 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): if sys.version_info >= (3, 11):
from typing import Self 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 import os
from pathlib import Path
import re import re
import subprocess
import sys import sys
import uuid import uuid
import warnings import warnings
from hashlib import md5
from pathlib import Path
from typing import ClassVar, List, Union from typing import ClassVar, List, Union


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

from .utils import _get_file_name_from_content, silence_pip from .utils import _get_file_name_from_content, silence_pip


import subprocess

__all__ = ("LocalCommandLineCodeExecutor",) __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 typing import Any, Dict, List, Optional, Union


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


__all__ = ("MarkdownCodeExtractor",) __all__ = ("MarkdownCodeExtractor",)




+ 2
- 2
autogen/graph_utils.py View File

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


from autogen.agentchat.groupchat import Agent 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. Visualize the speaker_transitions_dict using networkx.
""" """
try: try:
import networkx as nx
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import networkx as nx
except ImportError as e: except ImportError as e:
logging.fatal("Failed to import networkx or matplotlib. Try running 'pip install autogen[graphs]'") logging.fatal("Failed to import networkx or matplotlib. Try running 'pip install autogen[graphs]'")
raise e raise e


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

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


from abc import ABC, abstractmethod
from typing import Any, Dict, List, TYPE_CHECKING, Union
import sqlite3 import sqlite3
import uuid 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 from openai.types.chat import ChatCompletion


if TYPE_CHECKING: if TYPE_CHECKING:


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

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

from autogen.logger.base_logger import BaseLogger from autogen.logger.base_logger import BaseLogger
from autogen.logger.sqlite_logger import SqliteLogger 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 sqlite3
import threading import threading
import uuid 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.base_logger import BaseLogger
from autogen.logger.logger_utils import get_current_ts, to_dict 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 from .base_logger import LLMConfig



if TYPE_CHECKING: if TYPE_CHECKING:
from autogen import ConversableAgent, OpenAIWrapper from autogen import ConversableAgent, OpenAIWrapper




+ 2
- 1
autogen/math_utils.py View File

@@ -1,5 +1,6 @@
from typing import Optional 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_PROMPT = "{problem} Solve the problem carefully. Simplify your answer as much as possible. Put the final answer in \\boxed{{}}."
_MATH_CONFIG = { _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 ( 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_gpt4_gpt35,
config_list_openai_aoai, config_list_openai_aoai,
config_list_from_models,
config_list_from_json,
config_list_from_dotenv,
filter_config, filter_config,
get_config_list,
) )
from autogen.cache.cache import Cache


__all__ = [ __all__ = [
"OpenAIWrapper", "OpenAIWrapper",


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

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


import sys
from typing import Any, List, Optional, Dict, Callable, Tuple, Union
import logging
import inspect import inspect
import logging
import sys
import uuid 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 pydantic import BaseModel
from typing import Protocol


from autogen.cache.cache import Cache 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.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 TOOL_ENABLED = False
try: try:
@@ -26,14 +24,15 @@ except ImportError:
AzureOpenAI = object AzureOpenAI = object
else: else:
# raises exception if openai>=1 is installed and something is wrong with imports # 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.resources import Completions
from openai.types.chat import ChatCompletion 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 import ChatCompletionMessage, Choice # type: ignore [attr-defined]
from openai.types.chat.chat_completion_chunk import ( from openai.types.chat.chat_completion_chunk import (
ChoiceDeltaFunctionCall,
ChoiceDeltaToolCall, ChoiceDeltaToolCall,
ChoiceDeltaToolCallFunction, ChoiceDeltaToolCallFunction,
ChoiceDeltaFunctionCall,
) )
from openai.types.completion import Completion from openai.types.completion import Completion
from openai.types.completion_usage import CompletionUsage 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 logging
import time
from typing import List, Optional, Dict, Callable, Union
import sys
import shutil 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 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.automl.logger import logger_formatter
from flaml.tune.space import is_constant

from .openai_utils import get_key from .openai_utils import get_key
from collections import defaultdict


try: try:
import diskcache
import openai 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 from openai import Completion as openai_Completion
import diskcache
from openai import RateLimitError, Timeout


ERROR = None ERROR = None
assert openai.__version__ < "1" 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 typing import Any, Dict, List, Optional, Set, Union


from dotenv import find_dotenv, load_dotenv from dotenv import find_dotenv, load_dotenv

from openai import OpenAI from openai import OpenAI
from openai.types.beta.assistant import Assistant 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 os
import requests
from typing import Callable, List, Union
from urllib.parse import urlparse from urllib.parse import urlparse
import glob
import chromadb import chromadb
import requests


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

import logging import logging

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

from autogen.token_count_utils import count_token from autogen.token_count_utils import count_token


try: try:


+ 5
- 5
autogen/runtime_logging.py View File

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


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

import logging import logging
import sqlite3 import sqlite3
from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union
import uuid 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 openai.types.chat import ChatCompletion


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

if TYPE_CHECKING: if TYPE_CHECKING:
from autogen import ConversableAgent, OpenAIWrapper 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 json
import tiktoken
import logging
import re import re
from typing import Dict, List, Union


import tiktoken


logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)




+ 5
- 0
pyproject.toml View File

@@ -99,3 +99,8 @@ warn_unused_ignores = true
disallow_incomplete_defs = true disallow_incomplete_defs = true
disallow_untyped_decorators = true disallow_untyped_decorators = true
disallow_any_unimported = 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
import logging.handlers import logging.handlers
import os


import discord import discord
from discord.ext import commands

from agent_utils import solve_task from agent_utils import solve_task
from discord.ext import commands


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


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

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

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

@@ -1,12 +1,14 @@
import asyncio import asyncio
from datetime import datetime
import json import json
from queue import Queue
import time
from typing import Any, List, Dict, Optional, Tuple
import os 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 import websockets
from fastapi import WebSocket, WebSocketDisconnect

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


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

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


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


app = typer.Typer() app = typer.Typer()




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

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

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




@dataclass @dataclass


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

@@ -1,13 +1,13 @@
import json import json
import logging import logging
import os
import sqlite3 import sqlite3
import threading 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 ..datamodel import AgentFlowSpec, AgentWorkFlowConfig, Gallery, Message, Model, Session, Skill
from ..version import __version__ as __db_version__ from ..version import __version__ as __db_version__



VERSION_TABLE_SQL = """ VERSION_TABLE_SQL = """
CREATE TABLE IF NOT EXISTS version ( 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 base64
import hashlib import hashlib
from typing import List, Dict, Tuple, Union
import os import os
import re
import shutil import shutil
from pathlib import Path from pathlib import Path
import re
from typing import Dict, List, Tuple, Union

from dotenv import load_dotenv

import autogen import autogen
from autogen.oai.client import OpenAIWrapper from autogen.oai.client import OpenAIWrapper

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






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

@@ -1,26 +1,20 @@
import asyncio import asyncio
from contextlib import asynccontextmanager
import json import json
import os import os
import queue import queue
import threading import threading
import traceback 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.middleware.cors import CORSMiddleware
from fastapi.staticfiles import StaticFiles from fastapi.staticfiles import StaticFiles
from fastapi import HTTPException
from openai import OpenAIError 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 ..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 managers = {"chat": None} # manage calls to autogen
# Create thread-safe queue for messages between api thread and autogen threads # 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 import os
from typing import List, Optional, Union, Dict
from datetime import datetime
from typing import Dict, List, Optional, Union


from requests import Session from requests import Session


import autogen import autogen

from .datamodel import AgentConfig, AgentFlowSpec, AgentWorkFlowConfig, Message, SocketMessage 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: class AutoGenWorkFlowManager:


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

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

import zmq

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




class Actor: 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 # Agent_Sender takes a zmq context, Topic and creates a
# socket that can publish to that topic. It exposes this functionality # socket that can publish to that topic. It exposes this functionality
# using send_msg method # using send_msg method
import zmq
import time import time
import uuid import uuid

import zmq

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




class ActorConnector: class ActorConnector:


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

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

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




class Broker: class Broker:


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

@@ -1,6 +1,7 @@
import threading
import datetime 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 from termcolor import colored


# Define log levels as constants # 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 threading
import time 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 # TODO (Future DirectorySv PR) use actor description, network_id, other properties to make directory
# service more generic and powerful # service more generic and powerful




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

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

import zmq import zmq
from .DebugLog import Debug, Warn

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


# TODO: remove time import # TODO: remove time import




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

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

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




class AG2CAP(ConversableAgent): 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 typing import Dict, Optional, Union

from autogen import Agent from autogen import Agent

from ..ActorConnector import ActorConnector from ..ActorConnector import ActorConnector
from ..proto.Autogen_pb2 import GenReplyReq, GenReplyResp, PrepChat, ReceiveReq, Terminate 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 enum import Enum
from typing import Optional from typing import Optional

from autogen import ConversableAgent

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




class CAP2AG(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.AG2CAP import AG2CAP
from autogencap.ag_adapter.CAP2AG import CAP2AG from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.LocalActorNetwork import LocalActorNetwork from autogencap.LocalActorNetwork import LocalActorNetwork
from typing import List

from autogen import Agent, AssistantAgent, GroupChat




class CAPGroupChat(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.ActorConnector import ActorConnector
from autogencap.LocalActorNetwork import LocalActorNetwork
from autogencap.ag_adapter.CAP2AG import CAP2AG from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.ag_adapter.CAPGroupChat import CAPGroupChat from autogencap.ag_adapter.CAPGroupChat import CAPGroupChat
import time
from autogencap.LocalActorNetwork import LocalActorNetwork

from autogen import GroupChatManager




class CAPGroupChatManager: 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 descriptor as _descriptor
from google.protobuf import message as _message 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 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 descriptor as _descriptor
from google.protobuf import message as _message 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 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( setup(
name="autogencap", name="autogencap",


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

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


import argparse import argparse

import _paths import _paths
from autogencap.Config import LOG_LEVEL, IGNORED_LOG_CONTEXTS
import autogencap.DebugLog as DebugLog import autogencap.DebugLog as DebugLog
from SimpleActorDemo import simple_actor_demo
from AGDemo import ag_demo from AGDemo import ag_demo
from AGGroupChatDemo import ag_groupchat_demo from AGGroupChatDemo import ag_groupchat_demo
from autogencap.Config import IGNORED_LOG_CONTEXTS, LOG_LEVEL
from CAPAutGenGroupDemo import cap_ag_group_demo from CAPAutGenGroupDemo import cap_ag_group_demo
from CAPAutoGenPairDemo import cap_ag_pair_demo from CAPAutoGenPairDemo import cap_ag_pair_demo
from ComplexActorDemo import complex_actor_demo from ComplexActorDemo import complex_actor_demo
from RemoteAGDemo import remote_ag_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. to retrieve information.
""" """


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




class GreeterAgent(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.CAPGroupChat import CAPGroupChat
from autogencap.ag_adapter.CAPGroupChatManager import CAPGroupChatManager 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(): def cap_ag_group_demo():


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

@@ -1,9 +1,11 @@
import time 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.ag_adapter.CAPPair import CAPPair
from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork from autogencap.LocalActorNetwork import LocalActorNetwork


from autogen import AssistantAgent, UserProxyAgent, config_list_from_json



def cap_ag_pair_demo(): def cap_ag_pair_demo():
config_list = config_list_from_json(env_or_file="OAI_CONFIG_LIST") 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 import time
from termcolor import colored
from autogencap.LocalActorNetwork import LocalActorNetwork

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




def complex_actor_demo(): def complex_actor_demo():


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

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

from AppAgents import GreeterAgent from AppAgents import GreeterAgent
from autogencap.LocalActorNetwork import LocalActorNetwork 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 # 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 # Since this library has not been published to PyPi, it is not easy to install using pip
import sys
import os import os
import sys


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

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

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

import _paths import _paths
from autogen import AssistantAgent, config_list_from_json
from autogencap.ag_adapter.CAP2AG import CAP2AG
from autogencap.DebugLog import Info from autogencap.DebugLog import Info
from autogencap.LocalActorNetwork import LocalActorNetwork 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. # 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 time

import _paths 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.ag_adapter.CAP2AG import CAP2AG
from autogencap.Config import IGNORED_LOG_CONTEXTS 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. # 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 # 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 # Since this library has not been published to PyPi, it is not easy to install using pip
import sys
import os import os
import sys


absparent = os.path.abspath(os.path.join(os.path.dirname(__file__), "../..")) absparent = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
sys.path.append(absparent) 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(): def main():


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

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

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




def main(args=None): 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 argparse
import json
import os

import requests import requests

from .load_module import load_module from .load_module import load_module


# Figure out where everything is # 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 os
import sys import sys
import importlib.util




def load_module(module_path): 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 errno
import json
import os
import pathlib
import random
import shutil import shutil
import subprocess import subprocess
import json
import sys import sys
import time import time
import pathlib
import argparse

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

from .version import __version__ from .version import __version__


# Figure out where everything is # 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 os
import sys import sys
import argparse
import tabulate as tb import tabulate as tb

from .load_module import load_module from .load_module import load_module


# Figure out where everything is # 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 import os
from datetime import datetime

from pkg_resources import packaging

import autogen import autogen
import json


AUTOGEN_VERSION = packaging.version.parse(autogen.__version__) 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 os
import sys import sys

from autogenbench.tabulate_cmd import default_tabulate 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) # (default: ../scenarios/human_eval_two_agents_gpt4.jsonl and ./scenarios/human_eval_two_agents_gpt35.jsonl)
# #


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

from huggingface_hub import snapshot_download from huggingface_hub import snapshot_download


SCRIPT_PATH = os.path.realpath(__file__) 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 # ruff: noqa: F821


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




def scoring(content: str, should_contain: list, should_not_contain: list): 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 # ruff: noqa: E722


import traceback import traceback
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
import testbed_utils 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 # Assistant agent can call check.py to check if all the unit tests have passed
testbed_utils.init() 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 json
import autogen
import os

import testbed_utils import testbed_utils


import autogen

testbed_utils.init() 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 json
import autogen
import os

import testbed_utils import testbed_utils


import autogen

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




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

Loading…
Cancel
Save