(self)
| 198 | assert result.error == "secret error message" |
| 199 | |
| 200 | async def test_function_style_api(self): |
| 201 | class Params(BaseModel): |
| 202 | value: str |
| 203 | |
| 204 | tool = define_tool( |
| 205 | "my_tool", |
| 206 | description="My tool", |
| 207 | handler=lambda params, inv: params.value.upper(), |
| 208 | params_type=Params, |
| 209 | ) |
| 210 | |
| 211 | assert tool.name == "my_tool" |
| 212 | assert tool.description == "My tool" |
| 213 | |
| 214 | result = await tool.handler( |
| 215 | ToolInvocation( |
| 216 | session_id="s", |
| 217 | tool_call_id="c", |
| 218 | tool_name="my_tool", |
| 219 | arguments={"value": "hello"}, |
| 220 | ) |
| 221 | ) |
| 222 | assert result.text_result_for_llm == "HELLO" |
| 223 | |
| 224 | def test_function_style_can_create_declaration_only_tool(self): |
| 225 | class Params(BaseModel): |
nothing calls this directly
no test coverage detected