Commit 6a7557b
Add tool/function call structure extraction
Automatically extracts and captures full tool call structure from LLM responses:
**What's Captured:**
OpenAI Format:
- gen_ai.tool_calls.count - Number of tool calls
- gen_ai.tool.name - First tool name (for filtering)
- Events for each tool call with full structure:
- tool_call.id (e.g., "call_abc123")
- tool_call.type ("function")
- tool_call.function.name ("get_weather")
- tool_call.function.arguments (JSON string)
Anthropic Format:
- gen_ai.tool_calls.count - Number of tool uses
- gen_ai.tool.name - First tool name
- Events for each tool use:
- tool_call.id
- tool_call.name
- tool_call.input
**Usage:**
```python
@observe()
def chat_with_tools(prompt: str):
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}],
tools=[{
"type": "function",
"function": {
"name": "get_weather",
"parameters": {...}
}
}]
)
return response # Tool calls automatically extracted!
```
**Result in Last9:**
- Attribute: gen_ai.tool_calls.count = 2
- Attribute: gen_ai.tool.name = "get_weather"
- Event: gen_ai.tool.call with full tool call structure
- Queryable: Filter by tool name, see all tool call details
This completes tool call observability matching Langfuse capabilities!
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 71ed949 commit 6a7557b
1 file changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
456 | 456 | | |
457 | 457 | | |
458 | 458 | | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
459 | 462 | | |
460 | 463 | | |
461 | 464 | | |
| |||
569 | 572 | | |
570 | 573 | | |
571 | 574 | | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
0 commit comments