MCPcopy Create free account
hub / github.com/Mercury7353/PyBench / message2dict

Function message2dict

llms/utils.py:47–59  ·  view source on GitHub ↗
(
    message: Message,
)

Source from the content-addressed store, hash-verified

45
46
47def message2dict(
48 message: Message,
49) -> Dict[str, Optional[str | list[Dict[str, str]]]]:
50 ret = dict(
51 role=message.role.value,
52 content=message.content,
53 tool_calls=[call.model_dump() for call in message.tool_calls]
54 if message.tool_calls is not None
55 else None,
56 tool_call_id=message.tool_call_id,
57 )
58 ret = {k: v for k, v in ret.items() if v is not None}
59 return ret

Callers 1

generateMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected