Skip to content

A programming framework for agentic AI

Use native logger formatter (#3594)

Eric Zhu32166b5e3e95
diff --git a/autogen/oai/client.py b/autogen/oai/client.py
index cbabe93d8..833cc7772 100644
--- a/autogen/oai/client.py
+++ b/autogen/oai/client.py
@@ -6,7 +6,6 @@ import sys
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.oai.openai_utils import OAI_PRICE1K, get_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
+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 55730485b..5da4c49c2 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 e9a89c9ca..cd30c74dd 100644
--- a/autogen/oai/cohere.py
+++ b/autogen/oai/cohere.py
@@ -31,12 +31,11 @@ from typing import Any, Dict, List
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 5a62cde33..d4866d345 100644
--- a/autogen/oai/completion.py
+++ b/autogen/oai/completion.py
@@ -8,9 +8,9 @@ from typing import Callable, Dict, List, Optional, Union
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: