Test creating from dict.
(self)
| 104 | assert d["function"]["name"] == "sqrt" |
| 105 | |
| 106 | def test_from_dict(self): |
| 107 | """Test creating from dict.""" |
| 108 | data = { |
| 109 | "id": "call_123", |
| 110 | "type": "function", |
| 111 | "index": 0, |
| 112 | "function": { |
| 113 | "name": "sqrt", |
| 114 | "arguments": '{"x": 18}', |
| 115 | }, |
| 116 | } |
| 117 | tc = ToolCallData.from_dict(data) |
| 118 | assert tc.id == "call_123" |
| 119 | assert tc.function.name == "sqrt" |
| 120 | |
| 121 | def test_from_dict_defaults(self): |
| 122 | """Test from_dict with missing fields.""" |