normalize_tool_name (text/response_format.py)

ductor · ductor_bot/text/response_format.py · python · MIT
ai, tag:knn-classified

Formats bot response text, error messages, and technical footers for user-friendly output.

# Source: https://github.com/PleasePrompto/ductor | License: MIT | Copyright 2025-2026 PleasePrompto
# Provided via justclaw.it.com; keep this notice with the code.
"""Shared formatting primitives for command response text."""

from __future__ import annotations

from ductor_bot.i18n import t

SEP = "\u2500\u2500\u2500"

_SHELL_TOOLS = frozenset({"bash", "powershell", "cmd", "sh", "zsh", "shell"})
_TOOL_LABELS = {
    "toolsearch": "Search",
    "searchtool": "Search",
    "webfetch": "Web fetch",
    "websearch": "Web search",
}


def normalize_tool_name(name: str) -> str:
    """Normalize shell-related tool names to 'Shell' for display."""
    lower = name.lower()
    if lower in _SHELL_TOOLS:
        return "Shell"
    return _TOOL_LABELS.get(lower, name)


def fmt(*blocks: str) -> str:

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key