Skip to content

Commit d37802e

Browse files
committed
fix: style console output, and test ci-cd
1 parent 6e8a5a8 commit d37802e

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

app/prompt.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from app.logging_config import get_logger, setup_logging
2424
from app.settings import LLM_ASSISTANT_NAME, LLM_TOOL_CHOICE
2525
from app.stackademy import stackademy_app
26-
from app.utils import dump_json_colored
26+
from app.utils import color_text, dump_json_colored
2727

2828

2929
setup_logging()
@@ -114,7 +114,8 @@ def process_tool_calls(message: ChatCompletionMessage) -> list[str]:
114114
role="assistant", content=assistant_content, tool_calls=tool_calls_param, name=LLM_ASSISTANT_NAME
115115
)
116116
)
117-
logger.info("Function call detected: %s with args %s", function_name, function_args)
117+
msg = f"Calling function: {function_name} with args {json.dumps(function_args)}"
118+
logger.info(color_text(msg, "green"))
118119

119120
function_result = handle_function_call(function_name, function_args)
120121

app/stackademy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from app.database import db
1212
from app.exceptions import ConfigurationException
1313
from app.logging_config import get_logger, setup_logging
14+
from app.utils import color_text
1415

1516

1617
setup_logging()
@@ -144,7 +145,8 @@ def get_courses(self, description: Optional[str] = None, max_cost: Optional[floa
144145

145146
try:
146147
retval = self.db.execute_query(query, tuple(params))
147-
logger.info("get_courses() retrieved %d rows from %s", len(retval), self.db.connection_string)
148+
msg = f"get_courses() retrieved {len(retval)} rows from {self.db.connection_string}"
149+
logger.info(color_text(msg, "green"))
148150
return retval
149151
# pylint: disable=broad-except
150152
except Exception as e:

app/utils.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,35 @@
66
import json
77

88

9+
# ANSI color codes
10+
colors = {
11+
"blue": "\033[94m", # Bright blue
12+
"green": "\033[92m", # Bright green
13+
"reset": "\033[0m", # Reset to default color
14+
}
15+
16+
17+
def color_text(text, color="blue"):
18+
"""
19+
Colors a string as blue or green.
20+
21+
Args:
22+
text (str): The string to color
23+
color (str): Color to apply - either "blue" or "green" (default: "blue")
24+
25+
Returns:
26+
str: The colored string with ANSI escape codes
27+
28+
Raises:
29+
ValueError: If color is not "blue" or "green"
30+
"""
31+
32+
if color not in ["blue", "green"]:
33+
raise ValueError("Color must be either 'blue' or 'green'")
34+
35+
return f"{colors[color]}{text}{colors['reset']}"
36+
37+
938
def dump_json_colored(data, color="reset", indent=2, sort_keys=False):
1039
"""
1140
Dumps a JSON dictionary with colored text output.
@@ -23,12 +52,6 @@ def dump_json_colored(data, color="reset", indent=2, sort_keys=False):
2352
ValueError: If color is not "blue" or "green"
2453
TypeError: If data is not JSON serializable
2554
"""
26-
# ANSI color codes
27-
colors = {
28-
"blue": "\033[94m", # Bright blue
29-
"green": "\033[92m", # Bright green
30-
"reset": "\033[0m", # Reset to default color
31-
}
3255

3356
if color not in ["blue", "green"]:
3457
raise ValueError("Color must be either 'blue' or 'green'")

0 commit comments

Comments
 (0)