Repository navigation
Commit 1eb6226
fix(tools-serpex): send only valid params, typed responses, clear errors
Checked against the current Serpex API (backend code and live responses).
- search() sends only q (plus include_content / content_results when
page content is on). It used to send engine, category=web, num and
time_range, none of which the API reads (engine also triggers a
Deprecation response header). engine and time_range stay accepted for
backward compatibility, emit a DeprecationWarning and are not sent;
they are kept out of the tool schema the agent sees, so the LLM only
gets search(query, num_results). num_results caps results client-side
(1-10; the API returns at most 10).
- New include_content / content_results (5 or 10) constructor options:
page markdown for the top results, content_error in metadata when a
page could not be fetched.
- Responses typed with TypedDicts. Errors raise SerpexAPIError (a
requests.HTTPError subclass, so existing except clauses still work)
with one sentence per HTTP status: 400, 401, 402 with the balance,
429 with the wait and plan limit, 5xx not charged.
- Timeout 60 s (100 s with page content) instead of 30 s, which was
shorter than the server's own budget. User-Agent header added.
- Example no longer calls methods that do not exist
(search_with_location, gl/hl); README updated.
- Tests use sanitized responses recorded from the API on 2026-10-23
(personal data replaced with placeholders). Formatted with the
repo's pre-commit hooks (ruff-format, blacken-docs, prettier).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>1 parent 10935a6 commit 1eb6226
17 files changed
Lines changed: 1170 additions & 314 deletions
File tree
- llama-index-integrations/tools/llama-index-tools-serpex
- examples
- llama_index/tools/serpex
- tests
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
14 | 18 | | |
15 | | - | |
16 | 19 | | |
17 | | - | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 33 | + | |
37 | 34 | | |
38 | 35 | | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
42 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
43 | 83 | | |
44 | 84 | | |
45 | 85 | | |
| |||
51 | 91 | | |
52 | 92 | | |
53 | 93 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | 94 | | |
62 | 95 | | |
63 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | 7 | | |
10 | | - | |
11 | | - | |
12 | | - | |
| 8 | + | |
| 9 | + | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | | - | |
18 | 14 | | |
19 | | - | |
20 | | - | |
21 | 15 | | |
22 | 16 | | |
23 | 17 | | |
24 | 18 | | |
25 | 19 | | |
26 | 20 | | |
27 | 21 | | |
28 | | - | |
29 | | - | |
| 22 | + | |
| 23 | + | |
30 | 24 | | |
31 | | - | |
| 25 | + | |
32 | 26 | | |
33 | 27 | | |
34 | | - | |
35 | 28 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 29 | + | |
| 30 | + | |
41 | 31 | | |
42 | 32 | | |
43 | | - | |
| 33 | + | |
44 | 34 | | |
45 | 35 | | |
46 | 36 | | |
47 | | - | |
48 | | - | |
| 37 | + | |
| 38 | + | |
49 | 39 | | |
50 | | - | |
| 40 | + | |
51 | 41 | | |
52 | 42 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
| 43 | + | |
| 44 | + | |
63 | 45 | | |
64 | 46 | | |
65 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
66 | 51 | | |
67 | 52 | | |
68 | 53 | | |
69 | | - | |
70 | | - | |
| 54 | + | |
| 55 | + | |
71 | 56 | | |
72 | 57 | | |
73 | 58 | | |
74 | 59 | | |
75 | 60 | | |
76 | | - | |
| 61 | + | |
77 | 62 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | 63 | | |
93 | 64 | | |
94 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
95 | 78 | | |
96 | 79 | | |
97 | 80 | | |
98 | | - | |
| 81 | + | |
99 | 82 | | |
100 | | - | |
101 | 83 | | |
102 | 84 | | |
103 | 85 | | |
104 | 86 | | |
105 | 87 | | |
106 | | - | |
107 | 88 | | |
108 | | - | |
109 | | - | |
| 89 | + | |
| 90 | + | |
110 | 91 | | |
111 | 92 | | |
112 | 93 | | |
| |||
0 commit comments