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

fix: logger setting for print_text_animated #1341

Merged
merged 2 commits into from
Dec 18, 2024
Merged
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
26 changes: 4 additions & 22 deletions camel/utils/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# limitations under the License.
# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========
import importlib
import logging
import os
import platform
import re
Expand Down Expand Up @@ -40,19 +39,14 @@
import requests
from pydantic import BaseModel

from camel.logger import get_logger
from camel.types import TaskType

from .constants import Constants

F = TypeVar('F', bound=Callable[..., Any])

logger = get_logger(__name__)


def print_text_animated(
text, delay: float = 0.02, end: str = "", log_level: int = logging.INFO
):
def print_text_animated(text, delay: float = 0.02, end: str = ""):
r"""Prints the given text with an animated effect.

Args:
Expand All @@ -61,22 +55,10 @@ def print_text_animated(
(default: :obj:`0.02`)
end (str, optional): The end character to print after each
character of text. (default: :obj:`""`)
log_level (int, optional): The log level to use.
See https://docs.python.org/3/library/logging.html#levels
(default: :obj:`logging.INFO`)
"""
if logger.isEnabledFor(log_level):
# timestamp and other prefixes
logger.log(log_level, '')

for char in text:
print(char, end=end, flush=True)
time.sleep(delay)
# Close the log entry
logger.log(log_level, '')
else:
# This may be relevant for logging frameworks
logger.log(log_level, text)
for char in text:
print(char, end=end, flush=True)
time.sleep(delay)


def get_prompt_template_key_words(template: str) -> Set[str]:
Expand Down
Loading