From the uDemy course on LLM engineering.
https://www.udemy.com/course/llm-engineering-master-ai-and-large-language-models
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
764 B
33 lines
764 B
import logging |
|
|
|
class Agent: |
|
""" |
|
An abstract superclass for Agents |
|
Used to log messages in a way that can identify each Agent |
|
""" |
|
|
|
# Foreground colors |
|
RED = '\033[31m' |
|
GREEN = '\033[32m' |
|
YELLOW = '\033[33m' |
|
BLUE = '\033[34m' |
|
MAGENTA = '\033[35m' |
|
CYAN = '\033[36m' |
|
WHITE = '\033[37m' |
|
|
|
# Background color |
|
BG_BLACK = '\033[40m' |
|
|
|
# Reset code to return to default color |
|
RESET = '\033[0m' |
|
|
|
name: str = "" |
|
color: str = '\033[37m' |
|
|
|
def log(self, message): |
|
""" |
|
Log this as an info message, identifying the agent |
|
""" |
|
color_code = self.BG_BLACK + self.color |
|
message = f"[{self.name}] {message}" |
|
logging.info(color_code + message + self.RESET) |