From 32166b5e3e95e353103fc9f0b3e7ce1c25cc6ea6 Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Tue, 1 Oct 2024 16:55:31 -0700 Subject: [PATCH] Use native logger formatter (#3594) --- autogen/oai/client.py | 2 +- autogen/oai/client_utils.py | 5 +++++ autogen/oai/cohere.py | 3 +-- autogen/oai/completion.py | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/autogen/oai/client.py b/autogen/oai/client.py index cbabe93d874..833cc777219 100644 --- a/autogen/oai/client.py +++ b/autogen/oai/client.py @@ -6,7 +6,6 @@ import uuid from typing import Any, Callable, Dict, List, Optional, Protocol, Tuple, Union -from flaml.automl.logger import logger_formatter from pydantic import BaseModel from autogen.cache import Cache @@ -16,6 +15,7 @@ from autogen.runtime_logging import log_chat_completion, log_new_client, log_new_wrapper, logging_enabled from autogen.token_count_utils import count_token +from .client_utils import logger_formatter from .rate_limiters import RateLimiter, TimeRateLimiter TOOL_ENABLED = False diff --git a/autogen/oai/client_utils.py b/autogen/oai/client_utils.py index 55730485b40..5da4c49c2a9 100644 --- a/autogen/oai/client_utils.py +++ b/autogen/oai/client_utils.py @@ -1,8 +1,13 @@ """Utilities for client classes""" +import logging import warnings from typing import Any, Dict, List, Optional, Tuple +logger_formatter = logging.Formatter( + "[%(name)s: %(asctime)s] {%(lineno)d} %(levelname)s - %(message)s", "%m-%d %H:%M:%S" +) + def validate_parameter( params: Dict[str, Any], diff --git a/autogen/oai/cohere.py b/autogen/oai/cohere.py index e9a89c9cabd..cd30c74dd87 100644 --- a/autogen/oai/cohere.py +++ b/autogen/oai/cohere.py @@ -31,12 +31,11 @@ from cohere import Client as Cohere from cohere.types import ToolParameterDefinitionsValue, ToolResult -from flaml.automl.logger import logger_formatter from openai.types.chat import ChatCompletion, ChatCompletionMessageToolCall from openai.types.chat.chat_completion import ChatCompletionMessage, Choice from openai.types.completion_usage import CompletionUsage -from autogen.oai.client_utils import validate_parameter +from .client_utils import logger_formatter, validate_parameter logger = logging.getLogger(__name__) if not logger.handlers: diff --git a/autogen/oai/completion.py b/autogen/oai/completion.py index 5a62cde33df..d4866d34514 100644 --- a/autogen/oai/completion.py +++ b/autogen/oai/completion.py @@ -8,9 +8,9 @@ import numpy as np from flaml import BlendSearch, tune -from flaml.automl.logger import logger_formatter from flaml.tune.space import is_constant +from .client_utils import logger_formatter from .openai_utils import get_key try: