Skip to content

Commit 37a4493

Browse files
bensynapseclaude
andcommitted
docs(crewai-tools): parse the player id from the search response in examples
The search-to-profile examples stored the search response but then used a hardcoded id. Both examples now json-parse the response and pass the numeric id from the first result. Also adds the missing module docstring on the tool package __init__. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 90c8c6e commit 37a4493

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

docs/edge/en/tools/search-research/livetennistool.mdx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,19 @@ reporter = Agent(
5555
## Direct Invocation
5656

5757
```python
58+
import json
59+
5860
from crewai_tools import LiveTennisTool
5961

6062
tool = LiveTennisTool()
6163

6264
# Matches in play right now
6365
print(tool.run(action="live_matches", tour="atp"))
6466

65-
# Find a player, then load their profile
66-
players = tool.run(action="search_players", search="alcaraz")
67-
profile = tool.run(action="player_profile", player_id=12345) # numeric id from the search result
67+
# Find a player, then load their profile using the id from the search result
68+
players = json.loads(tool.run(action="search_players", search="alcaraz"))
69+
player_id = players["data"][0]["id"]
70+
profile = tool.run(action="player_profile", player_id=player_id)
6871
```
6972

7073
## Error Handling

lib/crewai-tools/src/crewai_tools/tools/live_tennis_tool/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,19 @@ Get a free key at [livetennisapi.com](https://livetennisapi.com). Full API docum
3434
## Example Usage
3535

3636
```python
37+
import json
38+
3739
from crewai_tools import LiveTennisTool
3840

3941
tool = LiveTennisTool()
4042

4143
# Matches in play right now
4244
print(tool.run(action="live_matches", tour="atp"))
4345

44-
# Find a player, then load their profile
45-
players = tool.run(action="search_players", search="alcaraz")
46-
profile = tool.run(action="player_profile", player_id=12345) # numeric id from the search result
46+
# Find a player, then load their profile using the id from the search result
47+
players = json.loads(tool.run(action="search_players", search="alcaraz"))
48+
player_id = players["data"][0]["id"]
49+
profile = tool.run(action="player_profile", player_id=player_id)
4750
```
4851

4952
## With an Agent

lib/crewai-tools/src/crewai_tools/tools/live_tennis_tool/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Live Tennis API tool package: live scores, fixtures, players, rankings."""
2+
13
from crewai_tools.tools.live_tennis_tool.live_tennis_tool import LiveTennisTool
24
from crewai_tools.tools.live_tennis_tool.schemas import LiveTennisToolSchema
35

0 commit comments

Comments
 (0)