MCPcopy Create free account
hub / github.com/IBM/mcp-cli / FunctionCallData

Class FunctionCallData

src/mcp_cli/chat/models.py:45–69  ·  view source on GitHub ↗

Function call within a tool call (OpenAI format). Mutable counterpart to chuk_llm.core.models.FunctionCall (frozen). Must remain mutable because ToolCallData.merge_chunk() accumulates streaming chunks by mutating name/arguments in place.

Source from the content-addressed store, hash-verified

43
44
45class FunctionCallData(BaseModel):
46 """Function call within a tool call (OpenAI format).
47
48 Mutable counterpart to chuk_llm.core.models.FunctionCall (frozen).
49 Must remain mutable because ToolCallData.merge_chunk() accumulates
50 streaming chunks by mutating name/arguments in place.
51 """
52
53 name: str = Field(description="Function/tool name")
54 arguments: str = Field(description="JSON string of arguments")
55
56 model_config = {"frozen": False}
57
58 def get_arguments_dict(self) -> dict[str, Any]:
59 """Parse arguments JSON string to dict."""
60 try:
61 result = json.loads(self.arguments)
62 return dict(result) if isinstance(result, dict) else {}
63 except json.JSONDecodeError:
64 return {}
65
66 @classmethod
67 def from_dict_args(cls, name: str, arguments: dict[str, Any]) -> "FunctionCallData":
68 """Create FunctionCallData from dict arguments."""
69 return cls(name=name, arguments=json.dumps(arguments))
70
71
72class ToolCallData(BaseModel):

Callers 10

test_createMethod · 0.90
test_createMethod · 0.90
test_to_dictMethod · 0.90
test_merge_chunk_nameMethod · 0.90
test_with_tool_callsMethod · 0.90
from_dictMethod · 0.85

Calls

no outgoing calls

Tested by 9

test_createMethod · 0.72
test_createMethod · 0.72
test_to_dictMethod · 0.72
test_merge_chunk_nameMethod · 0.72
test_with_tool_callsMethod · 0.72