|
38 | 38 | ResponseUsage, |
39 | 39 | Tool, |
40 | 40 | ) |
| 41 | +from openai.types.responses.response_custom_tool_call_output_param import ( |
| 42 | + ResponseCustomToolCallOutputParam, |
| 43 | +) |
41 | 44 | from openai.types.responses.response_function_web_search_param import ActionSearch |
42 | 45 | from openai.types.responses.response_input_item_param import ( |
43 | 46 | ComputerCallOutput, |
|
265 | 268 | }, |
266 | 269 | id="item_reference", |
267 | 270 | ), |
| 271 | + pytest.param( |
| 272 | + [ |
| 273 | + ResponseCustomToolCallOutputParam( |
| 274 | + type="custom_tool_call_output", |
| 275 | + call_id="custom-123", |
| 276 | + output="simple result", |
| 277 | + ) |
| 278 | + ], |
| 279 | + { |
| 280 | + "llm.input_messages.1.message.content": "simple result", |
| 281 | + "llm.input_messages.1.message.role": "tool", |
| 282 | + "llm.input_messages.1.message.tool_call_id": "custom-123", |
| 283 | + }, |
| 284 | + id="custom_tool_call_output_string", |
| 285 | + ), |
| 286 | + pytest.param( |
| 287 | + [ |
| 288 | + ResponseCustomToolCallOutputParam( |
| 289 | + type="custom_tool_call_output", |
| 290 | + call_id="custom-123", |
| 291 | + output=[{"type": "text", "text": "complex result"}], # type: ignore[typeddict-item] |
| 292 | + ) |
| 293 | + ], |
| 294 | + { |
| 295 | + "llm.input_messages.1.message.content": ( |
| 296 | + '[{"type": "text", "text": "complex result"}]' |
| 297 | + ), |
| 298 | + "llm.input_messages.1.message.role": "tool", |
| 299 | + "llm.input_messages.1.message.tool_call_id": "custom-123", |
| 300 | + }, |
| 301 | + id="custom_tool_call_output_list", |
| 302 | + ), |
| 303 | + pytest.param( |
| 304 | + [ |
| 305 | + ResponseCustomToolCallOutputParam( |
| 306 | + type="custom_tool_call_output", |
| 307 | + call_id="custom-123", |
| 308 | + output={"status": "success", "data": 42}, # type: ignore[dict-item] |
| 309 | + ) |
| 310 | + ], |
| 311 | + { |
| 312 | + "llm.input_messages.1.message.content": '{"status": "success", "data": 42}', |
| 313 | + "llm.input_messages.1.message.role": "tool", |
| 314 | + "llm.input_messages.1.message.tool_call_id": "custom-123", |
| 315 | + }, |
| 316 | + id="custom_tool_call_output_dict", |
| 317 | + ), |
268 | 318 | ], |
269 | 319 | ) |
270 | 320 | def test_get_attributes_from_input( |
@@ -427,6 +477,30 @@ def test_get_attributes_from_response_function_tool_call_param( |
427 | 477 | }, |
428 | 478 | id="none_output", |
429 | 479 | ), |
| 480 | + pytest.param( |
| 481 | + { |
| 482 | + "call_id": "123", |
| 483 | + "output": [{"type": "text", "text": "result"}], |
| 484 | + }, |
| 485 | + { |
| 486 | + "message.content": '[{"type": "text", "text": "result"}]', |
| 487 | + "message.role": "tool", |
| 488 | + "message.tool_call_id": "123", |
| 489 | + }, |
| 490 | + id="list_output", |
| 491 | + ), |
| 492 | + pytest.param( |
| 493 | + { |
| 494 | + "call_id": "123", |
| 495 | + "output": {"result": "success", "value": 42}, |
| 496 | + }, |
| 497 | + { |
| 498 | + "message.content": '{"result": "success", "value": 42}', |
| 499 | + "message.role": "tool", |
| 500 | + "message.tool_call_id": "123", |
| 501 | + }, |
| 502 | + id="dict_output", |
| 503 | + ), |
430 | 504 | ], |
431 | 505 | ) |
432 | 506 | def test_get_attributes_from_function_call_output( |
|
0 commit comments