MCPcopy Create free account
hub / github.com/VGabriel45/SolidityVisualizer / format_user_message

Function format_user_message

backend/app/utils/format_message.py:1–27  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

1def 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)

Callers 7

call_o3_apiMethod · 0.90
call_o3_api_streamMethod · 0.90
call_o3_apiMethod · 0.90
call_o3_api_streamMethod · 0.90
call_o1_apiMethod · 0.90
call_o1_api_streamMethod · 0.90
call_claude_apiMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected