Skip to content

Commit

Permalink
Use native logger formatter (#3594)
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzhu authored Oct 1, 2024
1 parent 27c8828 commit 32166b5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion autogen/oai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions autogen/oai/client_utils.py
Original file line number Diff line number Diff line change
@@ -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],
Expand Down
3 changes: 1 addition & 2 deletions autogen/oai/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion autogen/oai/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 32166b5

Please sign in to comment.