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

Use native logger formatter #3594

Merged
merged 1 commit into from
Oct 2, 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
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
Loading