exa-py 1.4.0__tar.gz → 1.5.0__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.

Potentially problematic release.


This version of exa-py might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: exa_py
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: Python SDK for Exa API.
5
5
  Home-page: https://github.com/exa-labs/exa-py
6
6
  Author: Exa
@@ -146,6 +146,11 @@ CONTENTS_OPTIONS_TYPES = {
146
146
  "filter_empty_results": [bool],
147
147
  }
148
148
 
149
+ CONTENTS_ENDPOINT_OPTIONS_TYPES = {
150
+ "subpages": [int],
151
+ "extras": [dict],
152
+ }
153
+
149
154
  # FOR BETA OPTIONS
150
155
  # if is_beta:
151
156
 
@@ -214,6 +219,15 @@ class SummaryContentsOptions(TypedDict, total=False):
214
219
 
215
220
  query: str
216
221
 
222
+ class ExtrasOptions(TypedDict, total=False):
223
+ """A class representing the options that you can specify when requesting summary
224
+
225
+ Attributes:
226
+ query (str): The query string for the summary. Summary will bias towards answering the query.
227
+ """
228
+
229
+ links: int
230
+
217
231
  @dataclass
218
232
  class _Result:
219
233
  """A class representing the base fields of a search result.
@@ -225,6 +239,9 @@ class _Result:
225
239
  score (float, optional): A number from 0 to 1 representing similarity between the query/url and the result.
226
240
  published_date (str, optional): An estimate of the creation date, from parsing HTML content.
227
241
  author (str, optional): If available, the author of the content.
242
+ image (str, optional): If available, a URL to an image associated with the content.
243
+ subpages (List[_Result], optional): If available, a list of Exa contents results for a page's subpages (e.g. tesla.com --subpage--> shop.tesla.com)
244
+ extras (Dict, optional): Additional metadata associated with the result; currently supports returning links in the text content
228
245
  """
229
246
 
230
247
  url: str
@@ -234,6 +251,8 @@ class _Result:
234
251
  published_date: Optional[str] = None
235
252
  author: Optional[str] = None
236
253
  image: Optional[str] = None
254
+ subpages: Optional[List[_Result]] = None
255
+ extras: Optional[Dict] = None
237
256
 
238
257
  def __init__(self, **kwargs):
239
258
  self.url = kwargs['url']
@@ -243,6 +262,8 @@ class _Result:
243
262
  self.published_date = kwargs.get('published_date')
244
263
  self.author = kwargs.get('author')
245
264
  self.image = kwargs.get('image')
265
+ self.subpages = kwargs.get('subpages')
266
+ self.extras = kwargs.get("extras")
246
267
 
247
268
  def __str__(self):
248
269
  return (
@@ -253,6 +274,8 @@ class _Result:
253
274
  f"Published Date: {self.published_date}\n"
254
275
  f"Author: {self.author}\n"
255
276
  f"Image: {self.image}\n"
277
+ f"Extras {self.extras}\n"
278
+ f"Subpages: {self.subpages}\n"
256
279
  )
257
280
 
258
281
 
@@ -273,6 +296,13 @@ class Result(_Result):
273
296
  highlight_scores: Optional[List[float]] = None
274
297
  summary: Optional[str] = None
275
298
 
299
+ def __init__(self, **kwargs):
300
+ super().__init__(**kwargs)
301
+ self.text = kwargs.get('text')
302
+ self.highlights = kwargs.get('highlights')
303
+ self.highlight_scores = kwargs.get('highlight_scores')
304
+ self.summary = kwargs.get('summary')
305
+
276
306
  def __str__(self):
277
307
  base_str = super().__str__()
278
308
  return base_str + (
@@ -294,6 +324,10 @@ class ResultWithText(_Result):
294
324
 
295
325
  text: str = dataclasses.field(default_factory=str)
296
326
 
327
+ def __init__(self, **kwargs):
328
+ super().__init__(**kwargs)
329
+ self.text = kwargs['text']
330
+
297
331
  def __str__(self):
298
332
  base_str = super().__str__()
299
333
  return base_str + f"Text: {self.text}\n"
@@ -312,6 +346,12 @@ class ResultWithHighlights(_Result):
312
346
  highlights: List[str] = dataclasses.field(default_factory=list)
313
347
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
314
348
 
349
+ def __init__(self, **kwargs):
350
+ super().__init__(**kwargs)
351
+ self.highlights = kwargs['highlights']
352
+ self.highlight_scores = kwargs['highlight_scores']
353
+
354
+
315
355
  def __str__(self):
316
356
  base_str = super().__str__()
317
357
  return base_str + (
@@ -335,6 +375,12 @@ class ResultWithTextAndHighlights(_Result):
335
375
  highlights: List[str] = dataclasses.field(default_factory=list)
336
376
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
337
377
 
378
+ def __init__(self, **kwargs):
379
+ super.__init__(**kwargs)
380
+ self.text = kwargs['text']
381
+ self.highlights = kwargs['highlights']
382
+ self.highlight_scores = kwargs['highlight_scores']
383
+
338
384
  def __str__(self):
339
385
  base_str = super().__str__()
340
386
  return base_str + (
@@ -354,6 +400,10 @@ class ResultWithSummary(_Result):
354
400
 
355
401
  summary: str = dataclasses.field(default_factory=str)
356
402
 
403
+ def __init__(self, **kwargs):
404
+ super().__init__(**kwargs)
405
+ self.summary = kwargs['summary']
406
+
357
407
  def __str__(self):
358
408
  base_str = super().__str__()
359
409
  return base_str + f"Summary: {self.summary}\n"
@@ -371,6 +421,11 @@ class ResultWithTextAndSummary(_Result):
371
421
  text: str = dataclasses.field(default_factory=str)
372
422
  summary: str = dataclasses.field(default_factory=str)
373
423
 
424
+ def __init__(self, **kwargs):
425
+ super().__init__(**kwargs)
426
+ self.text = kwargs['text']
427
+ self.summary = kwargs['summary']
428
+
374
429
  def __str__(self):
375
430
  base_str = super().__str__()
376
431
  return base_str + f"Text: {self.text}\n" + f"Summary: {self.summary}\n"
@@ -390,6 +445,12 @@ class ResultWithHighlightsAndSummary(_Result):
390
445
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
391
446
  summary: str = dataclasses.field(default_factory=str)
392
447
 
448
+ def __init__(self, **kwargs):
449
+ super().__init__(**kwargs)
450
+ self.highlights = kwargs['highlights']
451
+ self.highlight_scores = kwargs['highlight_scores']
452
+ self.summary = kwargs['summary']
453
+
393
454
  def __str__(self):
394
455
  base_str = super().__str__()
395
456
  return base_str + (
@@ -415,6 +476,13 @@ class ResultWithTextAndHighlightsAndSummary(_Result):
415
476
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
416
477
  summary: str = dataclasses.field(default_factory=str)
417
478
 
479
+ def __init__(self, **kwargs):
480
+ super().__init__(**kwargs)
481
+ self.text = kwargs['text']
482
+ self.highlights = kwargs['highlights']
483
+ self.highlight_scores = kwargs['highlight_scores']
484
+ self.summary = kwargs['summary']
485
+
418
486
  def __str__(self):
419
487
  base_str = super().__str__()
420
488
  return base_str + (
@@ -477,7 +545,7 @@ class Exa:
477
545
  self,
478
546
  api_key: Optional[str],
479
547
  base_url: str = "https://api.exa.ai",
480
- user_agent: str = "exa-py 1.4.0",
548
+ user_agent: str = "exa-py 1.5.0",
481
549
  ):
482
550
  """Initialize the Exa client with the provided API key and optional base URL and user agent.
483
551
 
@@ -571,6 +639,8 @@ class Exa:
571
639
  livecrawl_timeout: Optional[int] = None,
572
640
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
573
641
  filter_empty_results: Optional[bool] = None,
642
+ subpages: Optional[int] = None,
643
+ extras: Optional[ExtrasOptions] = None,
574
644
  ) -> SearchResponse[ResultWithText]:
575
645
  ...
576
646
 
@@ -592,9 +662,11 @@ class Exa:
592
662
  use_autoprompt: Optional[bool] = None,
593
663
  type: Optional[str] = None,
594
664
  category: Optional[str] = None,
665
+ subpages: Optional[int] = None,
595
666
  livecrawl_timeout: Optional[int] = None,
596
667
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
597
668
  filter_empty_results: Optional[bool] = None,
669
+ extras: Optional[ExtrasOptions] = None,
598
670
  ) -> SearchResponse[ResultWithText]:
599
671
  ...
600
672
 
@@ -617,8 +689,10 @@ class Exa:
617
689
  type: Optional[str] = None,
618
690
  category: Optional[str] = None,
619
691
  livecrawl_timeout: Optional[int] = None,
692
+ subpages: Optional[int] = None,
620
693
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
621
694
  filter_empty_results: Optional[bool] = None,
695
+ extras: Optional[ExtrasOptions] = None,
622
696
  ) -> SearchResponse[ResultWithHighlights]:
623
697
  ...
624
698
 
@@ -642,8 +716,10 @@ class Exa:
642
716
  type: Optional[str] = None,
643
717
  category: Optional[str] = None,
644
718
  livecrawl_timeout: Optional[int] = None,
719
+ subpages: Optional[int] = None,
645
720
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
646
721
  filter_empty_results: Optional[bool] = None,
722
+ extras: Optional[ExtrasOptions] = None,
647
723
  ) -> SearchResponse[ResultWithTextAndHighlights]:
648
724
  ...
649
725
 
@@ -666,8 +742,10 @@ class Exa:
666
742
  type: Optional[str] = None,
667
743
  category: Optional[str] = None,
668
744
  livecrawl_timeout: Optional[int] = None,
745
+ subpages: Optional[int] = None,
669
746
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
670
747
  filter_empty_results: Optional[bool] = None,
748
+ extras: Optional[ExtrasOptions] = None,
671
749
  ) -> SearchResponse[ResultWithSummary]:
672
750
  ...
673
751
 
@@ -690,9 +768,11 @@ class Exa:
690
768
  use_autoprompt: Optional[bool] = None,
691
769
  type: Optional[str] = None,
692
770
  category: Optional[str] = None,
771
+ subpages: Optional[int] = None,
693
772
  livecrawl_timeout: Optional[int] = None,
694
773
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
695
774
  filter_empty_results: Optional[bool] = None,
775
+ extras: Optional[ExtrasOptions] = None,
696
776
  ) -> SearchResponse[ResultWithTextAndSummary]:
697
777
  ...
698
778
 
@@ -716,8 +796,10 @@ class Exa:
716
796
  type: Optional[str] = None,
717
797
  category: Optional[str] = None,
718
798
  livecrawl_timeout: Optional[int] = None,
799
+ subpages: Optional[int] = None,
719
800
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
720
801
  filter_empty_results: Optional[bool] = None,
802
+ extras: Optional[ExtrasOptions] = None,
721
803
  ) -> SearchResponse[ResultWithHighlightsAndSummary]:
722
804
  ...
723
805
 
@@ -743,7 +825,9 @@ class Exa:
743
825
  category: Optional[str] = None,
744
826
  livecrawl_timeout: Optional[int] = None,
745
827
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
828
+ subpages: Optional[int] = None,
746
829
  filter_empty_results: Optional[bool] = None,
830
+ extras: Optional[ExtrasOptions] = None,
747
831
  ) -> SearchResponse[ResultWithTextAndHighlightsAndSummary]:
748
832
  ...
749
833
 
@@ -753,12 +837,12 @@ class Exa:
753
837
  for k, v in {"query": query, **kwargs}.items()
754
838
  if k != "self" and v is not None
755
839
  }
756
- if "text" not in options and "highlights" not in options and "summary" not in options:
840
+ if "text" not in options and "highlights" not in options and "summary" not in options and "subpages" not in options and "extras" not in options:
757
841
  options["text"] = True
758
842
  validate_search_options(
759
- options, {**SEARCH_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES}
843
+ options, {**SEARCH_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES, **CONTENTS_ENDPOINT_OPTIONS_TYPES}
760
844
  )
761
- options = nest_fields(options, ["text", "highlights", "summary"], "contents")
845
+ options = nest_fields(options, ["text", "highlights", "summary", "subpages", "livecrawl", "livecrawl_timeout", "extras"], "contents")
762
846
  options = to_camel_case(options)
763
847
  data = self.request("/search", options)
764
848
  return SearchResponse(
@@ -775,6 +859,8 @@ class Exa:
775
859
  livecrawl_timeout: Optional[int] = None,
776
860
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
777
861
  filter_empty_results: Optional[bool] = None,
862
+ subpages: Optional[int] = None,
863
+ extras: Optional[ExtrasOptions] = None,
778
864
  ) -> SearchResponse[ResultWithText]:
779
865
  ...
780
866
 
@@ -787,6 +873,8 @@ class Exa:
787
873
  livecrawl_timeout: Optional[int] = None,
788
874
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
789
875
  filter_empty_results: Optional[bool] = None,
876
+ subpages: Optional[int] = None,
877
+ extras: Optional[ExtrasOptions] = None,
790
878
  ) -> SearchResponse[ResultWithText]:
791
879
  ...
792
880
 
@@ -799,6 +887,8 @@ class Exa:
799
887
  livecrawl_timeout: Optional[int] = None,
800
888
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
801
889
  filter_empty_results: Optional[bool] = None,
890
+ subpages: Optional[int] = None,
891
+ extras: Optional[ExtrasOptions] = None,
802
892
  ) -> SearchResponse[ResultWithHighlights]:
803
893
  ...
804
894
 
@@ -812,6 +902,8 @@ class Exa:
812
902
  livecrawl_timeout: Optional[int] = None,
813
903
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
814
904
  filter_empty_results: Optional[bool] = None,
905
+ subpages: Optional[int] = None,
906
+ extras: Optional[ExtrasOptions] = None,
815
907
  ) -> SearchResponse[ResultWithTextAndHighlights]:
816
908
  ...
817
909
 
@@ -824,6 +916,8 @@ class Exa:
824
916
  livecrawl_timeout: Optional[int] = None,
825
917
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
826
918
  filter_empty_results: Optional[bool] = None,
919
+ subpages: Optional[int] = None,
920
+ extras: Optional[ExtrasOptions] = None,
827
921
  ) -> SearchResponse[ResultWithSummary]:
828
922
  ...
829
923
 
@@ -837,6 +931,8 @@ class Exa:
837
931
  livecrawl_timeout: Optional[int] = None,
838
932
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
839
933
  filter_empty_results: Optional[bool] = None,
934
+ subpages: Optional[int] = None,
935
+ extras: Optional[ExtrasOptions] = None,
840
936
  ) -> SearchResponse[ResultWithTextAndSummary]:
841
937
  ...
842
938
 
@@ -850,6 +946,8 @@ class Exa:
850
946
  livecrawl_timeout: Optional[int] = None,
851
947
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
852
948
  filter_empty_results: Optional[bool] = None,
949
+ subpages: Optional[int] = None,
950
+ extras: Optional[ExtrasOptions] = None,
853
951
  ) -> SearchResponse[ResultWithHighlightsAndSummary]:
854
952
  ...
855
953
 
@@ -864,6 +962,8 @@ class Exa:
864
962
  livecrawl_timeout: Optional[int] = None,
865
963
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
866
964
  filter_empty_results: Optional[bool] = None,
965
+ subpages: Optional[int] = None,
966
+ extras: Optional[ExtrasOptions] = None,
867
967
  ) -> SearchResponse[ResultWithTextAndHighlightsAndSummary]:
868
968
  ...
869
969
 
@@ -873,9 +973,9 @@ class Exa:
873
973
  for k, v in {"ids": ids, **kwargs}.items()
874
974
  if k != "self" and v is not None
875
975
  }
876
- if "text" not in options and "highlights" not in options and "summary" not in options:
976
+ if "text" not in options and "highlights" not in options and "summary" not in options and "extras" not in options and "subpages" not in options:
877
977
  options["text"] = True
878
- validate_search_options(options, {**CONTENTS_OPTIONS_TYPES})
978
+ validate_search_options(options, {**CONTENTS_OPTIONS_TYPES, **CONTENTS_ENDPOINT_OPTIONS_TYPES})
879
979
  options = to_camel_case(options)
880
980
  data = self.request("/contents", options)
881
981
  return SearchResponse(
@@ -929,8 +1029,10 @@ class Exa:
929
1029
  exclude_source_domain: Optional[bool] = None,
930
1030
  category: Optional[str] = None,
931
1031
  livecrawl_timeout: Optional[int] = None,
1032
+ subpages: Optional[int] = None,
932
1033
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
933
1034
  filter_empty_results: Optional[bool] = None,
1035
+ extras: Optional[ExtrasOptions] = None,
934
1036
  ) -> SearchResponse[ResultWithText]:
935
1037
  ...
936
1038
 
@@ -952,8 +1054,10 @@ class Exa:
952
1054
  exclude_source_domain: Optional[bool] = None,
953
1055
  category: Optional[str] = None,
954
1056
  livecrawl_timeout: Optional[int] = None,
1057
+ subpages: Optional[int] = None,
955
1058
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
956
1059
  filter_empty_results: Optional[bool] = None,
1060
+ extras: Optional[ExtrasOptions] = None,
957
1061
  ) -> SearchResponse[ResultWithText]:
958
1062
  ...
959
1063
 
@@ -974,9 +1078,11 @@ class Exa:
974
1078
  exclude_text: Optional[List[str]] = None,
975
1079
  exclude_source_domain: Optional[bool] = None,
976
1080
  category: Optional[str] = None,
1081
+ subpages: Optional[int] = None,
977
1082
  livecrawl_timeout: Optional[int] = None,
978
1083
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
979
1084
  filter_empty_results: Optional[bool] = None,
1085
+ extras: Optional[ExtrasOptions] = None,
980
1086
  ) -> SearchResponse[ResultWithHighlights]:
981
1087
  ...
982
1088
 
@@ -999,8 +1105,10 @@ class Exa:
999
1105
  exclude_source_domain: Optional[bool] = None,
1000
1106
  category: Optional[str] = None,
1001
1107
  livecrawl_timeout: Optional[int] = None,
1108
+ subpages: Optional[int] = None,
1002
1109
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1003
1110
  filter_empty_results: Optional[bool] = None,
1111
+ extras: Optional[ExtrasOptions] = None,
1004
1112
  ) -> SearchResponse[ResultWithTextAndHighlights]:
1005
1113
  ...
1006
1114
 
@@ -1023,7 +1131,9 @@ class Exa:
1023
1131
  category: Optional[str] = None,
1024
1132
  livecrawl_timeout: Optional[int] = None,
1025
1133
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1134
+ subpages: Optional[int] = None,
1026
1135
  filter_empty_results: Optional[bool] = None,
1136
+ extras: Optional[ExtrasOptions] = None,
1027
1137
  ) -> SearchResponse[ResultWithSummary]:
1028
1138
  ...
1029
1139
 
@@ -1047,7 +1157,9 @@ class Exa:
1047
1157
  category: Optional[str] = None,
1048
1158
  livecrawl_timeout: Optional[int] = None,
1049
1159
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1160
+ subpages: Optional[int] = None,
1050
1161
  filter_empty_results: Optional[bool] = None,
1162
+ extras: Optional[ExtrasOptions] = None,
1051
1163
  ) -> SearchResponse[ResultWithTextAndSummary]:
1052
1164
  ...
1053
1165
 
@@ -1071,7 +1183,9 @@ class Exa:
1071
1183
  category: Optional[str] = None,
1072
1184
  livecrawl_timeout: Optional[int] = None,
1073
1185
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1186
+ subpages: Optional[int] = None,
1074
1187
  filter_empty_results: Optional[bool] = None,
1188
+ extras: Optional[ExtrasOptions] = None,
1075
1189
  ) -> SearchResponse[ResultWithHighlightsAndSummary]:
1076
1190
  ...
1077
1191
 
@@ -1096,7 +1210,9 @@ class Exa:
1096
1210
  category: Optional[str] = None,
1097
1211
  livecrawl_timeout: Optional[int] = None,
1098
1212
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1213
+ subpages: Optional[int] = None,
1099
1214
  filter_empty_results: Optional[bool] = None,
1215
+ extras: Optional[ExtrasOptions] = None,
1100
1216
  ) -> SearchResponse[ResultWithTextAndHighlightsAndSummary]:
1101
1217
  ...
1102
1218
 
@@ -1106,13 +1222,13 @@ class Exa:
1106
1222
  for k, v in {"url": url, **kwargs}.items()
1107
1223
  if k != "self" and v is not None
1108
1224
  }
1109
- if "text" not in options and "highlights" not in options:
1225
+ if "text" not in options and "highlights" not in options and "summary" not in options and "extras" not in options and "subpages" not in options:
1110
1226
  options["text"] = True
1111
1227
  validate_search_options(
1112
- options, {**FIND_SIMILAR_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES}
1228
+ options, {**FIND_SIMILAR_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES, **CONTENTS_ENDPOINT_OPTIONS_TYPES}
1113
1229
  )
1114
1230
  options = to_camel_case(options)
1115
- options = nest_fields(options, ["text", "highlights", "summary"], "contents")
1231
+ options = nest_fields(options, ["text", "highlights", "summary", "subpages", "livecrawl", "livecrawl_timeout", "extras"], "contents")
1116
1232
  data = self.request("/findSimilar", options)
1117
1233
  return SearchResponse(
1118
1234
  [Result(**to_snake_case(result)) for result in data["results"]],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: exa_py
3
- Version: 1.4.0
3
+ Version: 1.5.0
4
4
  Summary: Python SDK for Exa API.
5
5
  Home-page: https://github.com/exa-labs/exa-py
6
6
  Author: Exa
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="exa_py",
5
- version="1.4.0",
5
+ version="1.5.0",
6
6
  description="Python SDK for Exa API.",
7
7
  long_description_content_type="text/markdown",
8
8
  long_description=open("README.md").read(),
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes