Skip to content

Commit 7d703b9

Browse files
authored
Merge pull request #140 from tavily-ai/feat/tavily-python-7f634c
Add usage parameter to api
2 parents 1dd4915 + 71d636c commit 7d703b9

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setup(
77
name='tavily-python',
8-
version='0.7.14',
8+
version='0.7.15',
99
url='https://github.com/tavily-ai/tavily-python',
1010
author='Tavily AI',
1111
author_email='[email protected]',

tavily/async_tavily.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ async def _search(
7070
country: str = None,
7171
auto_parameters: bool = None,
7272
include_favicon: bool = None,
73+
include_usage: bool = None,
7374
**kwargs,
7475
) -> dict:
7576
"""
@@ -92,6 +93,7 @@ async def _search(
9293
"country": country,
9394
"auto_parameters": auto_parameters,
9495
"include_favicon": include_favicon,
96+
"include_usage": include_usage,
9597
}
9698

9799
data = {k: v for k, v in data.items() if v is not None}
@@ -145,6 +147,7 @@ async def search(self,
145147
country: str = None,
146148
auto_parameters: bool = None,
147149
include_favicon: bool = None,
150+
include_usage: bool = None,
148151
**kwargs, # Accept custom arguments
149152
) -> dict:
150153
"""
@@ -168,6 +171,7 @@ async def search(self,
168171
country=country,
169172
auto_parameters=auto_parameters,
170173
include_favicon=include_favicon,
174+
include_usage=include_usage,
171175
**kwargs,
172176
)
173177

@@ -185,6 +189,7 @@ async def _extract(
185189
format: Literal["markdown", "text"] = None,
186190
timeout: float = 30,
187191
include_favicon: bool = None,
192+
include_usage: bool = None,
188193
**kwargs
189194
) -> dict:
190195
"""
@@ -198,6 +203,7 @@ async def _extract(
198203
"format": format,
199204
"timeout": timeout,
200205
"include_favicon": include_favicon,
206+
"include_usage": include_usage,
201207
}
202208

203209
data = {k: v for k, v in data.items() if v is not None}
@@ -239,6 +245,7 @@ async def extract(self,
239245
format: Literal["markdown", "text"] = None,
240246
timeout: float = 30,
241247
include_favicon: bool = None,
248+
include_usage: bool = None,
242249
**kwargs, # Accept custom arguments
243250
) -> dict:
244251
"""
@@ -251,6 +258,7 @@ async def extract(self,
251258
format,
252259
timeout,
253260
include_favicon=include_favicon,
261+
include_usage=include_usage,
254262
**kwargs,
255263
)
256264

@@ -278,6 +286,7 @@ async def _crawl(self,
278286
format: Literal["markdown", "text"] = None,
279287
timeout: float = 150,
280288
include_favicon: bool = None,
289+
include_usage: bool = None,
281290
**kwargs
282291
) -> dict:
283292
"""
@@ -299,6 +308,7 @@ async def _crawl(self,
299308
"format": format,
300309
"timeout": timeout,
301310
"include_favicon": include_favicon,
311+
"include_usage": include_usage,
302312
}
303313

304314
if kwargs:
@@ -348,6 +358,7 @@ async def crawl(self,
348358
format: Literal["markdown", "text"] = None,
349359
timeout: float = 150,
350360
include_favicon: bool = None,
361+
include_usage: bool = None,
351362
**kwargs
352363
) -> dict:
353364
"""
@@ -369,6 +380,7 @@ async def crawl(self,
369380
format=format,
370381
timeout=timeout,
371382
include_favicon=include_favicon,
383+
include_usage=include_usage,
372384
**kwargs)
373385

374386
return response_dict
@@ -386,6 +398,7 @@ async def _map(self,
386398
allow_external: bool = None,
387399
include_images: bool = None,
388400
timeout: float = 150,
401+
include_usage: bool = None,
389402
**kwargs
390403
) -> dict:
391404
"""
@@ -404,6 +417,7 @@ async def _map(self,
404417
"allow_external": allow_external,
405418
"include_images": include_images,
406419
"timeout": timeout,
420+
"include_usage": include_usage,
407421
}
408422

409423
if kwargs:
@@ -450,6 +464,7 @@ async def map(self,
450464
allow_external: bool = None,
451465
include_images: bool = None,
452466
timeout: float = 150,
467+
include_usage: bool = None,
453468
**kwargs
454469
) -> dict:
455470
"""
@@ -468,6 +483,7 @@ async def map(self,
468483
allow_external=allow_external,
469484
include_images=include_images,
470485
timeout=timeout,
486+
include_usage=include_usage,
471487
**kwargs)
472488

473489
return response_dict

tavily/tavily.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def _search(self,
5353
country: str = None,
5454
auto_parameters: bool = None,
5555
include_favicon: bool = None,
56+
include_usage: bool = None,
5657
**kwargs
5758
) -> dict:
5859
"""
@@ -76,6 +77,7 @@ def _search(self,
7677
"country": country,
7778
"auto_parameters": auto_parameters,
7879
"include_favicon": include_favicon,
80+
"include_usage": include_usage,
7981
}
8082

8183
data = {k: v for k, v in data.items() if v is not None}
@@ -130,6 +132,7 @@ def search(self,
130132
country: str = None,
131133
auto_parameters: bool = None,
132134
include_favicon: bool = None,
135+
include_usage: bool = None,
133136
**kwargs, # Accept custom arguments
134137
) -> dict:
135138
"""
@@ -153,6 +156,7 @@ def search(self,
153156
country=country,
154157
auto_parameters=auto_parameters,
155158
include_favicon=include_favicon,
159+
include_usage=include_usage,
156160
**kwargs,
157161
)
158162

@@ -169,6 +173,7 @@ def _extract(self,
169173
format: Literal["markdown", "text"] = None,
170174
timeout: float = 30,
171175
include_favicon: bool = None,
176+
include_usage: bool = None,
172177
**kwargs
173178
) -> dict:
174179
"""
@@ -181,6 +186,7 @@ def _extract(self,
181186
"format": format,
182187
"timeout": timeout,
183188
"include_favicon": include_favicon,
189+
"include_usage": include_usage,
184190
}
185191

186192
data = {k: v for k, v in data.items() if v is not None}
@@ -220,6 +226,7 @@ def extract(self,
220226
format: Literal["markdown", "text"] = None,
221227
timeout: float = 30,
222228
include_favicon: bool = None,
229+
include_usage: bool = None,
223230
**kwargs, # Accept custom arguments
224231
) -> dict:
225232
"""
@@ -231,6 +238,7 @@ def extract(self,
231238
format,
232239
timeout,
233240
include_favicon=include_favicon,
241+
include_usage=include_usage,
234242
**kwargs)
235243

236244
tavily_results = response_dict.get("results", [])
@@ -257,6 +265,7 @@ def _crawl(self,
257265
format: Literal["markdown", "text"] = None,
258266
timeout: float = 150,
259267
include_favicon: bool = None,
268+
include_usage: bool = None,
260269
**kwargs
261270
) -> dict:
262271
"""
@@ -279,6 +288,7 @@ def _crawl(self,
279288
"format": format,
280289
"timeout": timeout,
281290
"include_favicon": include_favicon,
291+
"include_usage": include_usage,
282292
}
283293

284294
if kwargs:
@@ -328,6 +338,7 @@ def crawl(self,
328338
format: Literal["markdown", "text"] = None,
329339
timeout: float = 150,
330340
include_favicon: bool = None,
341+
include_usage: bool = None,
331342
**kwargs
332343
) -> dict:
333344
"""
@@ -349,6 +360,7 @@ def crawl(self,
349360
format=format,
350361
timeout=timeout,
351362
include_favicon=include_favicon,
363+
include_usage=include_usage,
352364
**kwargs)
353365

354366
return response_dict
@@ -366,6 +378,7 @@ def _map(self,
366378
allow_external: bool = None,
367379
include_images: bool = None,
368380
timeout: float = 150,
381+
include_usage: bool = None,
369382
**kwargs
370383
) -> dict:
371384
"""
@@ -384,6 +397,7 @@ def _map(self,
384397
"allow_external": allow_external,
385398
"include_images": include_images,
386399
"timeout": timeout,
400+
"include_usage": include_usage,
387401
}
388402

389403
if kwargs:
@@ -430,6 +444,7 @@ def map(self,
430444
allow_external: bool = None,
431445
include_images: bool = None,
432446
timeout: float = 150,
447+
include_usage: bool = None,
433448
**kwargs
434449
) -> dict:
435450
"""
@@ -448,6 +463,7 @@ def map(self,
448463
allow_external=allow_external,
449464
include_images=include_images,
450465
timeout=timeout,
466+
include_usage=include_usage,
451467
**kwargs)
452468

453469
return response_dict

0 commit comments

Comments
 (0)