tavily-python 0.7.8__tar.gz → 0.7.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tavily_python-0.7.8 → tavily_python-0.7.9}/PKG-INFO +1 -1
- {tavily_python-0.7.8 → tavily_python-0.7.9}/setup.py +1 -1
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/async_tavily.py +23 -3
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/tavily.py +22 -5
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily_python.egg-info/PKG-INFO +1 -1
- {tavily_python-0.7.8 → tavily_python-0.7.9}/LICENSE +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/README.md +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/setup.cfg +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/__init__.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/config.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/errors.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/hybrid_rag/__init__.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/hybrid_rag/hybrid_rag.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily/utils.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily_python.egg-info/SOURCES.txt +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily_python.egg-info/dependency_links.txt +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily_python.egg-info/requires.txt +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tavily_python.egg-info/top_level.txt +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tests/test_async_search.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tests/test_crawl.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tests/test_errors.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tests/test_map.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tests/test_search.py +0 -0
- {tavily_python-0.7.8 → tavily_python-0.7.9}/tests/test_sync_search.py +0 -0
|
@@ -17,7 +17,8 @@ class AsyncTavilyClient:
|
|
|
17
17
|
|
|
18
18
|
def __init__(self, api_key: Optional[str] = None,
|
|
19
19
|
company_info_tags: Sequence[str] = ("news", "general", "finance"),
|
|
20
|
-
proxies: Optional[dict[str, str]] = None
|
|
20
|
+
proxies: Optional[dict[str, str]] = None,
|
|
21
|
+
api_base_url: Optional[str] = None):
|
|
21
22
|
if api_key is None:
|
|
22
23
|
api_key = os.getenv("TAVILY_API_KEY")
|
|
23
24
|
|
|
@@ -39,13 +40,14 @@ class AsyncTavilyClient:
|
|
|
39
40
|
else None
|
|
40
41
|
)
|
|
41
42
|
|
|
43
|
+
self._api_base_url = api_base_url or "https://api.tavily.com"
|
|
42
44
|
self._client_creator = lambda: httpx.AsyncClient(
|
|
43
45
|
headers={
|
|
44
46
|
"Content-Type": "application/json",
|
|
45
47
|
"Authorization": f"Bearer {api_key}",
|
|
46
48
|
"X-Client-Source": "tavily-python"
|
|
47
49
|
},
|
|
48
|
-
base_url=
|
|
50
|
+
base_url=self._api_base_url,
|
|
49
51
|
mounts=proxy_mounts
|
|
50
52
|
)
|
|
51
53
|
self._company_info_tags = company_info_tags
|
|
@@ -66,6 +68,7 @@ class AsyncTavilyClient:
|
|
|
66
68
|
timeout: int = 60,
|
|
67
69
|
country: str = None,
|
|
68
70
|
auto_parameters: bool = None,
|
|
71
|
+
include_favicon: bool = None,
|
|
69
72
|
**kwargs,
|
|
70
73
|
) -> dict:
|
|
71
74
|
"""
|
|
@@ -85,6 +88,7 @@ class AsyncTavilyClient:
|
|
|
85
88
|
"include_images": include_images,
|
|
86
89
|
"country": country,
|
|
87
90
|
"auto_parameters": auto_parameters,
|
|
91
|
+
"include_favicon": include_favicon,
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
data = {k: v for k, v in data.items() if v is not None}
|
|
@@ -135,6 +139,7 @@ class AsyncTavilyClient:
|
|
|
135
139
|
timeout: int = 60,
|
|
136
140
|
country: str = None,
|
|
137
141
|
auto_parameters: bool = None,
|
|
142
|
+
include_favicon: bool = None,
|
|
138
143
|
**kwargs, # Accept custom arguments
|
|
139
144
|
) -> dict:
|
|
140
145
|
"""
|
|
@@ -155,6 +160,7 @@ class AsyncTavilyClient:
|
|
|
155
160
|
timeout=timeout,
|
|
156
161
|
country=country,
|
|
157
162
|
auto_parameters=auto_parameters,
|
|
163
|
+
include_favicon=include_favicon,
|
|
158
164
|
**kwargs,
|
|
159
165
|
)
|
|
160
166
|
|
|
@@ -171,16 +177,19 @@ class AsyncTavilyClient:
|
|
|
171
177
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
172
178
|
format: Literal["markdown", "text"] = None,
|
|
173
179
|
timeout: int = 60,
|
|
180
|
+
include_favicon: bool = None,
|
|
174
181
|
**kwargs
|
|
175
182
|
) -> dict:
|
|
176
183
|
"""
|
|
177
184
|
Internal extract method to send the request to the API.
|
|
185
|
+
include_favicon: If True, include the favicon in the extraction results.
|
|
178
186
|
"""
|
|
179
187
|
data = {
|
|
180
188
|
"urls": urls,
|
|
181
189
|
"include_images": include_images,
|
|
182
190
|
"extract_depth": extract_depth,
|
|
183
191
|
"format": format,
|
|
192
|
+
"include_favicon": include_favicon,
|
|
184
193
|
}
|
|
185
194
|
|
|
186
195
|
data = {k: v for k, v in data.items() if v is not None}
|
|
@@ -223,10 +232,12 @@ class AsyncTavilyClient:
|
|
|
223
232
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
224
233
|
format: Literal["markdown", "text"] = None,
|
|
225
234
|
timeout: int = 60,
|
|
235
|
+
include_favicon: bool = None,
|
|
226
236
|
**kwargs, # Accept custom arguments
|
|
227
237
|
) -> dict:
|
|
228
238
|
"""
|
|
229
239
|
Combined extract method.
|
|
240
|
+
include_favicon: If True, include the favicon in the extraction results.
|
|
230
241
|
"""
|
|
231
242
|
timeout = min(timeout, 120)
|
|
232
243
|
response_dict = await self._extract(urls,
|
|
@@ -234,6 +245,7 @@ class AsyncTavilyClient:
|
|
|
234
245
|
extract_depth,
|
|
235
246
|
format,
|
|
236
247
|
timeout,
|
|
248
|
+
include_favicon=include_favicon,
|
|
237
249
|
**kwargs,
|
|
238
250
|
)
|
|
239
251
|
|
|
@@ -261,6 +273,7 @@ class AsyncTavilyClient:
|
|
|
261
273
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
262
274
|
format: Literal["markdown", "text"] = None,
|
|
263
275
|
timeout: int = 60,
|
|
276
|
+
include_favicon: bool = None,
|
|
264
277
|
**kwargs
|
|
265
278
|
) -> dict:
|
|
266
279
|
"""
|
|
@@ -280,7 +293,8 @@ class AsyncTavilyClient:
|
|
|
280
293
|
"categories": categories,
|
|
281
294
|
"include_images": include_images,
|
|
282
295
|
"extract_depth": extract_depth,
|
|
283
|
-
"format": format
|
|
296
|
+
"format": format,
|
|
297
|
+
"include_favicon": include_favicon,
|
|
284
298
|
}
|
|
285
299
|
|
|
286
300
|
if kwargs:
|
|
@@ -332,6 +346,7 @@ class AsyncTavilyClient:
|
|
|
332
346
|
include_images: bool = None,
|
|
333
347
|
format: Literal["markdown", "text"] = None,
|
|
334
348
|
timeout: int = 60,
|
|
349
|
+
include_favicon: bool = None,
|
|
335
350
|
**kwargs
|
|
336
351
|
) -> dict:
|
|
337
352
|
"""
|
|
@@ -354,6 +369,7 @@ class AsyncTavilyClient:
|
|
|
354
369
|
include_images=include_images,
|
|
355
370
|
format=format,
|
|
356
371
|
timeout=timeout,
|
|
372
|
+
include_favicon=include_favicon,
|
|
357
373
|
**kwargs)
|
|
358
374
|
|
|
359
375
|
return response_dict
|
|
@@ -474,6 +490,7 @@ class AsyncTavilyClient:
|
|
|
474
490
|
max_tokens: int = 4000,
|
|
475
491
|
timeout: int = 60,
|
|
476
492
|
country: str = None,
|
|
493
|
+
include_favicon: bool = None,
|
|
477
494
|
**kwargs, # Accept custom arguments
|
|
478
495
|
) -> str:
|
|
479
496
|
"""
|
|
@@ -497,6 +514,7 @@ class AsyncTavilyClient:
|
|
|
497
514
|
include_images=False,
|
|
498
515
|
timeout = timeout,
|
|
499
516
|
country=country,
|
|
517
|
+
include_favicon=include_favicon,
|
|
500
518
|
**kwargs,
|
|
501
519
|
)
|
|
502
520
|
sources = response_dict.get("results", [])
|
|
@@ -513,6 +531,7 @@ class AsyncTavilyClient:
|
|
|
513
531
|
exclude_domains: Sequence[str] = None,
|
|
514
532
|
timeout: int = 60,
|
|
515
533
|
country: str = None,
|
|
534
|
+
include_favicon: bool = None,
|
|
516
535
|
**kwargs, # Accept custom arguments
|
|
517
536
|
) -> str:
|
|
518
537
|
"""
|
|
@@ -531,6 +550,7 @@ class AsyncTavilyClient:
|
|
|
531
550
|
include_answer=True,
|
|
532
551
|
timeout = timeout,
|
|
533
552
|
country=country,
|
|
553
|
+
include_favicon=include_favicon,
|
|
534
554
|
**kwargs,
|
|
535
555
|
)
|
|
536
556
|
return response_dict.get("answer", "")
|
|
@@ -13,7 +13,7 @@ class TavilyClient:
|
|
|
13
13
|
Tavily API client class.
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
|
-
def __init__(self, api_key: Optional[str] = None, proxies: Optional[dict[str, str]] = None):
|
|
16
|
+
def __init__(self, api_key: Optional[str] = None, proxies: Optional[dict[str, str]] = None, api_base_url: Optional[str] = None):
|
|
17
17
|
if api_key is None:
|
|
18
18
|
api_key = os.getenv("TAVILY_API_KEY")
|
|
19
19
|
|
|
@@ -27,7 +27,7 @@ class TavilyClient:
|
|
|
27
27
|
|
|
28
28
|
resolved_proxies = {k: v for k, v in resolved_proxies.items() if v} or None
|
|
29
29
|
|
|
30
|
-
self.base_url = "https://api.tavily.com"
|
|
30
|
+
self.base_url = api_base_url or "https://api.tavily.com"
|
|
31
31
|
self.api_key = api_key
|
|
32
32
|
self.proxies = resolved_proxies
|
|
33
33
|
self.headers = {
|
|
@@ -51,6 +51,7 @@ class TavilyClient:
|
|
|
51
51
|
timeout: int = 60,
|
|
52
52
|
country: str = None,
|
|
53
53
|
auto_parameters: bool = None,
|
|
54
|
+
include_favicon: bool = None,
|
|
54
55
|
**kwargs
|
|
55
56
|
) -> dict:
|
|
56
57
|
"""
|
|
@@ -71,6 +72,7 @@ class TavilyClient:
|
|
|
71
72
|
"include_images": include_images,
|
|
72
73
|
"country": country,
|
|
73
74
|
"auto_parameters": auto_parameters,
|
|
75
|
+
"include_favicon": include_favicon,
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
data = {k: v for k, v in data.items() if v is not None}
|
|
@@ -122,6 +124,7 @@ class TavilyClient:
|
|
|
122
124
|
timeout: int = 60,
|
|
123
125
|
country: str = None,
|
|
124
126
|
auto_parameters: bool = None,
|
|
127
|
+
include_favicon: bool = None,
|
|
125
128
|
**kwargs, # Accept custom arguments
|
|
126
129
|
) -> dict:
|
|
127
130
|
"""
|
|
@@ -142,6 +145,7 @@ class TavilyClient:
|
|
|
142
145
|
timeout=timeout,
|
|
143
146
|
country=country,
|
|
144
147
|
auto_parameters=auto_parameters,
|
|
148
|
+
include_favicon=include_favicon,
|
|
145
149
|
**kwargs,
|
|
146
150
|
)
|
|
147
151
|
|
|
@@ -157,16 +161,18 @@ class TavilyClient:
|
|
|
157
161
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
158
162
|
format: Literal["markdown", "text"] = None,
|
|
159
163
|
timeout: int = 60,
|
|
164
|
+
include_favicon: bool = None,
|
|
160
165
|
**kwargs
|
|
161
166
|
) -> dict:
|
|
162
167
|
"""
|
|
163
|
-
Internal extract method to send the request to the API.
|
|
168
|
+
Internal extract method to send the request to the API.
|
|
164
169
|
"""
|
|
165
170
|
data = {
|
|
166
171
|
"urls": urls,
|
|
167
172
|
"include_images": include_images,
|
|
168
173
|
"extract_depth": extract_depth,
|
|
169
174
|
"format": format,
|
|
175
|
+
"include_favicon": include_favicon,
|
|
170
176
|
}
|
|
171
177
|
|
|
172
178
|
data = {k: v for k, v in data.items() if v is not None}
|
|
@@ -207,6 +213,7 @@ class TavilyClient:
|
|
|
207
213
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
208
214
|
format: Literal["markdown", "text"] = None,
|
|
209
215
|
timeout: int = 60,
|
|
216
|
+
include_favicon: bool = None,
|
|
210
217
|
**kwargs, # Accept custom arguments
|
|
211
218
|
) -> dict:
|
|
212
219
|
"""
|
|
@@ -218,6 +225,7 @@ class TavilyClient:
|
|
|
218
225
|
extract_depth,
|
|
219
226
|
format,
|
|
220
227
|
timeout,
|
|
228
|
+
include_favicon=include_favicon,
|
|
221
229
|
**kwargs)
|
|
222
230
|
|
|
223
231
|
tavily_results = response_dict.get("results", [])
|
|
@@ -244,10 +252,12 @@ class TavilyClient:
|
|
|
244
252
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
245
253
|
format: Literal["markdown", "text"] = None,
|
|
246
254
|
timeout: int = 60,
|
|
255
|
+
include_favicon: bool = None,
|
|
247
256
|
**kwargs
|
|
248
257
|
) -> dict:
|
|
249
258
|
"""
|
|
250
259
|
Internal crawl method to send the request to the API.
|
|
260
|
+
include_favicon: If True, include the favicon in the crawl results.
|
|
251
261
|
"""
|
|
252
262
|
data = {
|
|
253
263
|
"url": url,
|
|
@@ -263,7 +273,8 @@ class TavilyClient:
|
|
|
263
273
|
"include_images": include_images,
|
|
264
274
|
"categories": categories,
|
|
265
275
|
"extract_depth": extract_depth,
|
|
266
|
-
"format": format
|
|
276
|
+
"format": format,
|
|
277
|
+
"include_favicon": include_favicon,
|
|
267
278
|
}
|
|
268
279
|
|
|
269
280
|
if kwargs:
|
|
@@ -315,11 +326,12 @@ class TavilyClient:
|
|
|
315
326
|
extract_depth: Literal["basic", "advanced"] = None,
|
|
316
327
|
format: Literal["markdown", "text"] = None,
|
|
317
328
|
timeout: int = 60,
|
|
329
|
+
include_favicon: bool = None,
|
|
318
330
|
**kwargs
|
|
319
331
|
) -> dict:
|
|
320
332
|
"""
|
|
321
333
|
Combined crawl method.
|
|
322
|
-
|
|
334
|
+
include_favicon: If True, include the favicon in the crawl results.
|
|
323
335
|
"""
|
|
324
336
|
timeout = min(timeout, 120)
|
|
325
337
|
response_dict = self._crawl(url,
|
|
@@ -337,6 +349,7 @@ class TavilyClient:
|
|
|
337
349
|
extract_depth=extract_depth,
|
|
338
350
|
format=format,
|
|
339
351
|
timeout=timeout,
|
|
352
|
+
include_favicon=include_favicon,
|
|
340
353
|
**kwargs)
|
|
341
354
|
|
|
342
355
|
return response_dict
|
|
@@ -457,6 +470,7 @@ class TavilyClient:
|
|
|
457
470
|
max_tokens: int = 4000,
|
|
458
471
|
timeout: int = 60,
|
|
459
472
|
country: str = None,
|
|
473
|
+
include_favicon: bool = None,
|
|
460
474
|
**kwargs, # Accept custom arguments
|
|
461
475
|
) -> str:
|
|
462
476
|
"""
|
|
@@ -480,6 +494,7 @@ class TavilyClient:
|
|
|
480
494
|
include_images=False,
|
|
481
495
|
timeout=timeout,
|
|
482
496
|
country=country,
|
|
497
|
+
include_favicon=include_favicon,
|
|
483
498
|
**kwargs,
|
|
484
499
|
)
|
|
485
500
|
sources = response_dict.get("results", [])
|
|
@@ -497,6 +512,7 @@ class TavilyClient:
|
|
|
497
512
|
exclude_domains: Sequence[str] = None,
|
|
498
513
|
timeout: int = 60,
|
|
499
514
|
country: str = None,
|
|
515
|
+
include_favicon: bool = None,
|
|
500
516
|
**kwargs, # Accept custom arguments
|
|
501
517
|
) -> str:
|
|
502
518
|
"""
|
|
@@ -515,6 +531,7 @@ class TavilyClient:
|
|
|
515
531
|
include_answer=True,
|
|
516
532
|
timeout=timeout,
|
|
517
533
|
country=country,
|
|
534
|
+
include_favicon=include_favicon,
|
|
518
535
|
**kwargs,
|
|
519
536
|
)
|
|
520
537
|
return response_dict.get("answer", "")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|