Formats a dictionary of data into a structured user message with XML-style tags. Args: data (dict[str, str]): Dictionary of key-value pairs to format Returns: str: Formatted message with each key-value pair wrapped in appropriate tags
(data: dict[str, str])
| 1 | def format_user_message(data: dict[str, str]) -> str: |
| 2 | """ |
| 3 | Formats a dictionary of data into a structured user message with XML-style tags. |
| 4 | |
| 5 | Args: |
| 6 | data (dict[str, str]): Dictionary of key-value pairs to format |
| 7 | |
| 8 | Returns: |
| 9 | str: Formatted message with each key-value pair wrapped in appropriate tags |
| 10 | """ |
| 11 | parts = [] |
| 12 | for key, value in data.items(): |
| 13 | # Map keys to their XML-style tags |
| 14 | if key == "file_tree": |
| 15 | parts.append(f"<file_tree>\n{value}\n</file_tree>") |
| 16 | elif key == "readme": |
| 17 | parts.append(f"<readme>\n{value}\n</readme>") |
| 18 | elif key == "explanation": |
| 19 | parts.append(f"<explanation>\n{value}\n</explanation>") |
| 20 | elif key == "component_mapping": |
| 21 | parts.append(f"<component_mapping>\n{value}\n</component_mapping>") |
| 22 | elif key == "instructions": |
| 23 | parts.append(f"<instructions>\n{value}\n</instructions>") |
| 24 | elif key == "diagram": |
| 25 | parts.append(f"<diagram>\n{value}\n</diagram>") |
| 26 | |
| 27 | return "\n\n".join(parts) |
no outgoing calls
no test coverage detected