Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isort #2265

Merged
merged 8 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions autogen/__init__.py
Original file line number Diff line number Diff line change
@@ -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__)
Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/__init__.py
Original file line number Diff line number Diff line change
@@ -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__ = (
Expand Down
3 changes: 2 additions & 1 deletion autogen/agentchat/assistant_agent.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
16 changes: 8 additions & 8 deletions autogen/agentchat/chat.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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 ..io.base import IOStream
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 ..io.base import IOStream
from .utils import consolidate_chat_info

logger = logging.getLogger(__name__)
Prerequisite = Tuple[int, int]
Expand Down
13 changes: 7 additions & 6 deletions autogen/agentchat/contrib/agent_builder.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
7 changes: 4 additions & 3 deletions autogen/agentchat/contrib/agent_optimizer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from autogen.code_utils import execute_code
from typing import List, Dict, Optional
import json
import copy
import json
from typing import Dict, List, Optional

import autogen
from autogen.code_utils import execute_code

ADD_FUNC = {
"type": "function",
Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/capabilities/generate_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from PIL.Image import Image

from autogen import Agent, ConversableAgent, code_utils
from autogen.cache import AbstractCache
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 AbstractCache

SYSTEM_MESSAGE = "You've been given the special ability to generate images."
DESCRIPTION_MESSAGE = "This agent has the ability to generate images."
Expand Down
5 changes: 4 additions & 1 deletion autogen/agentchat/contrib/capabilities/teachability.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from termcolor import colored

from autogen import ConversableAgent

from .transforms import MessageTransform


Expand Down
10 changes: 5 additions & 5 deletions autogen/agentchat/contrib/compressible_agent.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 8 additions & 8 deletions autogen/agentchat/contrib/gpt_assistant_agent.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down
3 changes: 2 additions & 1 deletion autogen/agentchat/contrib/llava_agent.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import json
import logging
from typing import List, Optional, Tuple

import replicate
import requests

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__)

Expand Down
10 changes: 5 additions & 5 deletions autogen/agentchat/contrib/math_user_proxy_agent.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 0 additions & 1 deletion autogen/agentchat/contrib/multimodal_conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from ..._pydantic import model_dump


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

Expand Down
6 changes: 3 additions & 3 deletions autogen/agentchat/contrib/qdrant_retrieve_user_proxy_agent.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion autogen/agentchat/contrib/retrieve_assistant_agent.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
13 changes: 7 additions & 6 deletions autogen/agentchat/contrib/retrieve_user_proxy_agent.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
7 changes: 4 additions & 3 deletions autogen/agentchat/contrib/society_of_mind_agent.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
3 changes: 2 additions & 1 deletion autogen/agentchat/contrib/text_analyzer_agent.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
12 changes: 7 additions & 5 deletions autogen/agentchat/contrib/web_surfer.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/conversable_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
from ..coding.factory import CodeExecutorFactory
from ..formatting_utils import colored
from ..function_utils import get_function_schema, load_basemodels_if_needed, serialize_to_str
from ..io.base import IOStream
from ..oai.client import ModelClient, OpenAIWrapper
from ..runtime_logging import log_new_agent, logging_enabled
from .agent import Agent, LLMAgent
from ..io.base import IOStream
from .chat import ChatResult, a_initiate_chats, initiate_chats
from .utils import consolidate_chat_info, gather_usage_summary

Expand Down
6 changes: 3 additions & 3 deletions autogen/agentchat/groupchat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
from dataclasses import dataclass, field
from typing import Callable, Dict, List, Literal, Optional, Tuple, Union

from .agent import Agent
from .conversable_agent import ConversableAgent
from ..io.base import IOStream
from ..code_utils import content_str
from ..exception_utils import AgentNameConflict, NoEligibleSpeaker, UndefinedNextAgent
from ..graph_utils import check_graph_validity, invert_disallowed_to_allowed
from ..io.base import IOStream
from ..runtime_logging import log_new_agent, logging_enabled
from .agent import Agent
from .conversable_agent import ConversableAgent

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion autogen/agentchat/user_proxy_agent.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
11 changes: 6 additions & 5 deletions autogen/browser_utils.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion autogen/cache/abstract_cache_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from types import TracebackType
from typing import Any, Optional, Protocol, Type
import sys

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