def display_answer()

in chat.py [0:0]


def display_answer(answer):
    """
    Display the assistant's answer, reasoning, and SQL query extracted from a JSON-formatted string or dictionary.

    Args:
        answer (dict): The assistant's answer in dictionary format.
    """
    if not answer:
        logger.warning("No answer provided.")
        print("No answer provided.")
        return

    # ANSI escape sequences for colors
    BLUE = '\033[94m'
    GREY = '\033[90m'
    RESET = '\033[0m'

    try:
        # Ensure the answer is a dictionary
        if isinstance(answer, str):
            answer = json.loads(answer)

        if not isinstance(answer, dict):
            logger.error("Parsed JSON is not a dictionary.")
            print("Assistant: The provided answer is not in the expected JSON object format.")
            return

        # Extract keys with default messages if keys are missing
        assistant_answer = answer.get("answer", "No answer provided.")
        assistant_reasoning = answer.get("reasoning", "No reasoning provided.")
        assistant_data_points = answer.get("data_points", "No data points provided.")

        print(f"{BLUE}Answer: {assistant_answer}{RESET}")
        print(f"{BLUE}Reasoning: {GREY}{assistant_reasoning}{RESET}")
        print(f"{BLUE}Data Points: {GREY}{assistant_data_points}{RESET}")

    except json.JSONDecodeError as e:
        logger.error(f"JSON decoding failed: {e}")
        print("Assistant: Unable to parse the answer due to invalid JSON format.")
    except Exception as e:
        logger.exception(f"An unexpected error occurred: {e}")
        print("Assistant: An unexpected error occurred while processing the answer.")