Skip to content
Open
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
14 changes: 11 additions & 3 deletions src/cai/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,19 +1414,27 @@ def fix_message_list(messages): # pylint: disable=R0914,R0915,R0912
return processed_messages


def cli_print_tool_call(tool_name="", args="", output="", prefix=" "):
"""Print a tool call with pretty formatting"""
def cli_print_tool_call(tool_name="", args="", output="", prefix=" ", **kwargs):
"""Print a tool call with pretty formatting
Args:
tool_name: Name of the tool being called
output: Output from the tool execution
**kwargs: Accept additional parameters for backwards compatibility"""
if not tool_name:
return

if not args and 'tool_args' in kwargs:
args = kwargs['tool_args']
if not output and 'tool_output' in kwargs:
output = kwargs['tool_output']

print(f"{prefix}{color('Tool Call:', fg='cyan')}")
print(f"{prefix}{color('Name:', fg='cyan')} {tool_name}")
if args:
print(f"{prefix}{color('Args:', fg='cyan')} {args}")
if output:
print(f"{prefix}{color('Output:', fg='cyan')} {output}")


def get_model_input_tokens(model):
"""
Get the number of input tokens for
Expand Down