exa-py 1.4.1b0__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.1b0
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
@@ -147,8 +147,8 @@ CONTENTS_OPTIONS_TYPES = {
147
147
  }
148
148
 
149
149
  CONTENTS_ENDPOINT_OPTIONS_TYPES = {
150
- "subpages": [int], # Number of subpages to get contents for; these will appear as additional content results
151
- "subpage_target": [str, list] # Specific subpage(s) to get contents for
150
+ "subpages": [int],
151
+ "extras": [dict],
152
152
  }
153
153
 
154
154
  # FOR BETA OPTIONS
@@ -219,6 +219,15 @@ class SummaryContentsOptions(TypedDict, total=False):
219
219
 
220
220
  query: str
221
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
+
222
231
  @dataclass
223
232
  class _Result:
224
233
  """A class representing the base fields of a search result.
@@ -230,6 +239,9 @@ class _Result:
230
239
  score (float, optional): A number from 0 to 1 representing similarity between the query/url and the result.
231
240
  published_date (str, optional): An estimate of the creation date, from parsing HTML content.
232
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
233
245
  """
234
246
 
235
247
  url: str
@@ -239,6 +251,8 @@ class _Result:
239
251
  published_date: Optional[str] = None
240
252
  author: Optional[str] = None
241
253
  image: Optional[str] = None
254
+ subpages: Optional[List[_Result]] = None
255
+ extras: Optional[Dict] = None
242
256
 
243
257
  def __init__(self, **kwargs):
244
258
  self.url = kwargs['url']
@@ -248,6 +262,8 @@ class _Result:
248
262
  self.published_date = kwargs.get('published_date')
249
263
  self.author = kwargs.get('author')
250
264
  self.image = kwargs.get('image')
265
+ self.subpages = kwargs.get('subpages')
266
+ self.extras = kwargs.get("extras")
251
267
 
252
268
  def __str__(self):
253
269
  return (
@@ -258,6 +274,8 @@ class _Result:
258
274
  f"Published Date: {self.published_date}\n"
259
275
  f"Author: {self.author}\n"
260
276
  f"Image: {self.image}\n"
277
+ f"Extras {self.extras}\n"
278
+ f"Subpages: {self.subpages}\n"
261
279
  )
262
280
 
263
281
 
@@ -278,6 +296,13 @@ class Result(_Result):
278
296
  highlight_scores: Optional[List[float]] = None
279
297
  summary: Optional[str] = None
280
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
+
281
306
  def __str__(self):
282
307
  base_str = super().__str__()
283
308
  return base_str + (
@@ -299,6 +324,10 @@ class ResultWithText(_Result):
299
324
 
300
325
  text: str = dataclasses.field(default_factory=str)
301
326
 
327
+ def __init__(self, **kwargs):
328
+ super().__init__(**kwargs)
329
+ self.text = kwargs['text']
330
+
302
331
  def __str__(self):
303
332
  base_str = super().__str__()
304
333
  return base_str + f"Text: {self.text}\n"
@@ -317,6 +346,12 @@ class ResultWithHighlights(_Result):
317
346
  highlights: List[str] = dataclasses.field(default_factory=list)
318
347
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
319
348
 
349
+ def __init__(self, **kwargs):
350
+ super().__init__(**kwargs)
351
+ self.highlights = kwargs['highlights']
352
+ self.highlight_scores = kwargs['highlight_scores']
353
+
354
+
320
355
  def __str__(self):
321
356
  base_str = super().__str__()
322
357
  return base_str + (
@@ -340,6 +375,12 @@ class ResultWithTextAndHighlights(_Result):
340
375
  highlights: List[str] = dataclasses.field(default_factory=list)
341
376
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
342
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
+
343
384
  def __str__(self):
344
385
  base_str = super().__str__()
345
386
  return base_str + (
@@ -359,6 +400,10 @@ class ResultWithSummary(_Result):
359
400
 
360
401
  summary: str = dataclasses.field(default_factory=str)
361
402
 
403
+ def __init__(self, **kwargs):
404
+ super().__init__(**kwargs)
405
+ self.summary = kwargs['summary']
406
+
362
407
  def __str__(self):
363
408
  base_str = super().__str__()
364
409
  return base_str + f"Summary: {self.summary}\n"
@@ -376,6 +421,11 @@ class ResultWithTextAndSummary(_Result):
376
421
  text: str = dataclasses.field(default_factory=str)
377
422
  summary: str = dataclasses.field(default_factory=str)
378
423
 
424
+ def __init__(self, **kwargs):
425
+ super().__init__(**kwargs)
426
+ self.text = kwargs['text']
427
+ self.summary = kwargs['summary']
428
+
379
429
  def __str__(self):
380
430
  base_str = super().__str__()
381
431
  return base_str + f"Text: {self.text}\n" + f"Summary: {self.summary}\n"
@@ -395,6 +445,12 @@ class ResultWithHighlightsAndSummary(_Result):
395
445
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
396
446
  summary: str = dataclasses.field(default_factory=str)
397
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
+
398
454
  def __str__(self):
399
455
  base_str = super().__str__()
400
456
  return base_str + (
@@ -420,6 +476,13 @@ class ResultWithTextAndHighlightsAndSummary(_Result):
420
476
  highlight_scores: List[float] = dataclasses.field(default_factory=list)
421
477
  summary: str = dataclasses.field(default_factory=str)
422
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
+
423
486
  def __str__(self):
424
487
  base_str = super().__str__()
425
488
  return base_str + (
@@ -482,7 +545,7 @@ class Exa:
482
545
  self,
483
546
  api_key: Optional[str],
484
547
  base_url: str = "https://api.exa.ai",
485
- user_agent: str = "exa-py 1.4.1-beta",
548
+ user_agent: str = "exa-py 1.5.0",
486
549
  ):
487
550
  """Initialize the Exa client with the provided API key and optional base URL and user agent.
488
551
 
@@ -576,6 +639,8 @@ class Exa:
576
639
  livecrawl_timeout: Optional[int] = None,
577
640
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
578
641
  filter_empty_results: Optional[bool] = None,
642
+ subpages: Optional[int] = None,
643
+ extras: Optional[ExtrasOptions] = None,
579
644
  ) -> SearchResponse[ResultWithText]:
580
645
  ...
581
646
 
@@ -597,9 +662,11 @@ class Exa:
597
662
  use_autoprompt: Optional[bool] = None,
598
663
  type: Optional[str] = None,
599
664
  category: Optional[str] = None,
665
+ subpages: Optional[int] = None,
600
666
  livecrawl_timeout: Optional[int] = None,
601
667
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
602
668
  filter_empty_results: Optional[bool] = None,
669
+ extras: Optional[ExtrasOptions] = None,
603
670
  ) -> SearchResponse[ResultWithText]:
604
671
  ...
605
672
 
@@ -622,8 +689,10 @@ class Exa:
622
689
  type: Optional[str] = None,
623
690
  category: Optional[str] = None,
624
691
  livecrawl_timeout: Optional[int] = None,
692
+ subpages: Optional[int] = None,
625
693
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
626
694
  filter_empty_results: Optional[bool] = None,
695
+ extras: Optional[ExtrasOptions] = None,
627
696
  ) -> SearchResponse[ResultWithHighlights]:
628
697
  ...
629
698
 
@@ -647,8 +716,10 @@ class Exa:
647
716
  type: Optional[str] = None,
648
717
  category: Optional[str] = None,
649
718
  livecrawl_timeout: Optional[int] = None,
719
+ subpages: Optional[int] = None,
650
720
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
651
721
  filter_empty_results: Optional[bool] = None,
722
+ extras: Optional[ExtrasOptions] = None,
652
723
  ) -> SearchResponse[ResultWithTextAndHighlights]:
653
724
  ...
654
725
 
@@ -671,8 +742,10 @@ class Exa:
671
742
  type: Optional[str] = None,
672
743
  category: Optional[str] = None,
673
744
  livecrawl_timeout: Optional[int] = None,
745
+ subpages: Optional[int] = None,
674
746
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
675
747
  filter_empty_results: Optional[bool] = None,
748
+ extras: Optional[ExtrasOptions] = None,
676
749
  ) -> SearchResponse[ResultWithSummary]:
677
750
  ...
678
751
 
@@ -695,9 +768,11 @@ class Exa:
695
768
  use_autoprompt: Optional[bool] = None,
696
769
  type: Optional[str] = None,
697
770
  category: Optional[str] = None,
771
+ subpages: Optional[int] = None,
698
772
  livecrawl_timeout: Optional[int] = None,
699
773
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
700
774
  filter_empty_results: Optional[bool] = None,
775
+ extras: Optional[ExtrasOptions] = None,
701
776
  ) -> SearchResponse[ResultWithTextAndSummary]:
702
777
  ...
703
778
 
@@ -721,8 +796,10 @@ class Exa:
721
796
  type: Optional[str] = None,
722
797
  category: Optional[str] = None,
723
798
  livecrawl_timeout: Optional[int] = None,
799
+ subpages: Optional[int] = None,
724
800
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
725
801
  filter_empty_results: Optional[bool] = None,
802
+ extras: Optional[ExtrasOptions] = None,
726
803
  ) -> SearchResponse[ResultWithHighlightsAndSummary]:
727
804
  ...
728
805
 
@@ -748,7 +825,9 @@ class Exa:
748
825
  category: Optional[str] = None,
749
826
  livecrawl_timeout: Optional[int] = None,
750
827
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
828
+ subpages: Optional[int] = None,
751
829
  filter_empty_results: Optional[bool] = None,
830
+ extras: Optional[ExtrasOptions] = None,
752
831
  ) -> SearchResponse[ResultWithTextAndHighlightsAndSummary]:
753
832
  ...
754
833
 
@@ -758,12 +837,12 @@ class Exa:
758
837
  for k, v in {"query": query, **kwargs}.items()
759
838
  if k != "self" and v is not None
760
839
  }
761
- 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:
762
841
  options["text"] = True
763
842
  validate_search_options(
764
- options, {**SEARCH_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES}
843
+ options, {**SEARCH_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES, **CONTENTS_ENDPOINT_OPTIONS_TYPES}
765
844
  )
766
- options = nest_fields(options, ["text", "highlights", "summary"], "contents")
845
+ options = nest_fields(options, ["text", "highlights", "summary", "subpages", "livecrawl", "livecrawl_timeout", "extras"], "contents")
767
846
  options = to_camel_case(options)
768
847
  data = self.request("/search", options)
769
848
  return SearchResponse(
@@ -781,7 +860,7 @@ class Exa:
781
860
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
782
861
  filter_empty_results: Optional[bool] = None,
783
862
  subpages: Optional[int] = None,
784
- subpage_target: Optional[Union[str, List[str]]] = None
863
+ extras: Optional[ExtrasOptions] = None,
785
864
  ) -> SearchResponse[ResultWithText]:
786
865
  ...
787
866
 
@@ -795,7 +874,7 @@ class Exa:
795
874
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
796
875
  filter_empty_results: Optional[bool] = None,
797
876
  subpages: Optional[int] = None,
798
- subpage_target: Optional[Union[str, List[str]]] = None
877
+ extras: Optional[ExtrasOptions] = None,
799
878
  ) -> SearchResponse[ResultWithText]:
800
879
  ...
801
880
 
@@ -809,7 +888,7 @@ class Exa:
809
888
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
810
889
  filter_empty_results: Optional[bool] = None,
811
890
  subpages: Optional[int] = None,
812
- subpage_target: Optional[Union[str, List[str]]] = None
891
+ extras: Optional[ExtrasOptions] = None,
813
892
  ) -> SearchResponse[ResultWithHighlights]:
814
893
  ...
815
894
 
@@ -824,7 +903,7 @@ class Exa:
824
903
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
825
904
  filter_empty_results: Optional[bool] = None,
826
905
  subpages: Optional[int] = None,
827
- subpage_target: Optional[Union[str, List[str]]] = None
906
+ extras: Optional[ExtrasOptions] = None,
828
907
  ) -> SearchResponse[ResultWithTextAndHighlights]:
829
908
  ...
830
909
 
@@ -838,7 +917,7 @@ class Exa:
838
917
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
839
918
  filter_empty_results: Optional[bool] = None,
840
919
  subpages: Optional[int] = None,
841
- subpage_target: Optional[Union[str, List[str]]] = None
920
+ extras: Optional[ExtrasOptions] = None,
842
921
  ) -> SearchResponse[ResultWithSummary]:
843
922
  ...
844
923
 
@@ -853,7 +932,7 @@ class Exa:
853
932
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
854
933
  filter_empty_results: Optional[bool] = None,
855
934
  subpages: Optional[int] = None,
856
- subpage_target: Optional[Union[str, List[str]]] = None
935
+ extras: Optional[ExtrasOptions] = None,
857
936
  ) -> SearchResponse[ResultWithTextAndSummary]:
858
937
  ...
859
938
 
@@ -868,7 +947,7 @@ class Exa:
868
947
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
869
948
  filter_empty_results: Optional[bool] = None,
870
949
  subpages: Optional[int] = None,
871
- subpage_target: Optional[Union[str, List[str]]] = None
950
+ extras: Optional[ExtrasOptions] = None,
872
951
  ) -> SearchResponse[ResultWithHighlightsAndSummary]:
873
952
  ...
874
953
 
@@ -884,7 +963,7 @@ class Exa:
884
963
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
885
964
  filter_empty_results: Optional[bool] = None,
886
965
  subpages: Optional[int] = None,
887
- subpage_target: Optional[Union[str, List[str]]] = None
966
+ extras: Optional[ExtrasOptions] = None,
888
967
  ) -> SearchResponse[ResultWithTextAndHighlightsAndSummary]:
889
968
  ...
890
969
 
@@ -894,7 +973,7 @@ class Exa:
894
973
  for k, v in {"ids": ids, **kwargs}.items()
895
974
  if k != "self" and v is not None
896
975
  }
897
- 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:
898
977
  options["text"] = True
899
978
  validate_search_options(options, {**CONTENTS_OPTIONS_TYPES, **CONTENTS_ENDPOINT_OPTIONS_TYPES})
900
979
  options = to_camel_case(options)
@@ -950,8 +1029,10 @@ class Exa:
950
1029
  exclude_source_domain: Optional[bool] = None,
951
1030
  category: Optional[str] = None,
952
1031
  livecrawl_timeout: Optional[int] = None,
1032
+ subpages: Optional[int] = None,
953
1033
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
954
1034
  filter_empty_results: Optional[bool] = None,
1035
+ extras: Optional[ExtrasOptions] = None,
955
1036
  ) -> SearchResponse[ResultWithText]:
956
1037
  ...
957
1038
 
@@ -973,8 +1054,10 @@ class Exa:
973
1054
  exclude_source_domain: Optional[bool] = None,
974
1055
  category: Optional[str] = None,
975
1056
  livecrawl_timeout: Optional[int] = None,
1057
+ subpages: Optional[int] = None,
976
1058
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
977
1059
  filter_empty_results: Optional[bool] = None,
1060
+ extras: Optional[ExtrasOptions] = None,
978
1061
  ) -> SearchResponse[ResultWithText]:
979
1062
  ...
980
1063
 
@@ -995,9 +1078,11 @@ class Exa:
995
1078
  exclude_text: Optional[List[str]] = None,
996
1079
  exclude_source_domain: Optional[bool] = None,
997
1080
  category: Optional[str] = None,
1081
+ subpages: Optional[int] = None,
998
1082
  livecrawl_timeout: Optional[int] = None,
999
1083
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1000
1084
  filter_empty_results: Optional[bool] = None,
1085
+ extras: Optional[ExtrasOptions] = None,
1001
1086
  ) -> SearchResponse[ResultWithHighlights]:
1002
1087
  ...
1003
1088
 
@@ -1020,8 +1105,10 @@ class Exa:
1020
1105
  exclude_source_domain: Optional[bool] = None,
1021
1106
  category: Optional[str] = None,
1022
1107
  livecrawl_timeout: Optional[int] = None,
1108
+ subpages: Optional[int] = None,
1023
1109
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1024
1110
  filter_empty_results: Optional[bool] = None,
1111
+ extras: Optional[ExtrasOptions] = None,
1025
1112
  ) -> SearchResponse[ResultWithTextAndHighlights]:
1026
1113
  ...
1027
1114
 
@@ -1044,7 +1131,9 @@ class Exa:
1044
1131
  category: Optional[str] = None,
1045
1132
  livecrawl_timeout: Optional[int] = None,
1046
1133
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1134
+ subpages: Optional[int] = None,
1047
1135
  filter_empty_results: Optional[bool] = None,
1136
+ extras: Optional[ExtrasOptions] = None,
1048
1137
  ) -> SearchResponse[ResultWithSummary]:
1049
1138
  ...
1050
1139
 
@@ -1068,7 +1157,9 @@ class Exa:
1068
1157
  category: Optional[str] = None,
1069
1158
  livecrawl_timeout: Optional[int] = None,
1070
1159
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1160
+ subpages: Optional[int] = None,
1071
1161
  filter_empty_results: Optional[bool] = None,
1162
+ extras: Optional[ExtrasOptions] = None,
1072
1163
  ) -> SearchResponse[ResultWithTextAndSummary]:
1073
1164
  ...
1074
1165
 
@@ -1092,7 +1183,9 @@ class Exa:
1092
1183
  category: Optional[str] = None,
1093
1184
  livecrawl_timeout: Optional[int] = None,
1094
1185
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1186
+ subpages: Optional[int] = None,
1095
1187
  filter_empty_results: Optional[bool] = None,
1188
+ extras: Optional[ExtrasOptions] = None,
1096
1189
  ) -> SearchResponse[ResultWithHighlightsAndSummary]:
1097
1190
  ...
1098
1191
 
@@ -1117,7 +1210,9 @@ class Exa:
1117
1210
  category: Optional[str] = None,
1118
1211
  livecrawl_timeout: Optional[int] = None,
1119
1212
  livecrawl: Optional[LIVECRAWL_OPTIONS] = None,
1213
+ subpages: Optional[int] = None,
1120
1214
  filter_empty_results: Optional[bool] = None,
1215
+ extras: Optional[ExtrasOptions] = None,
1121
1216
  ) -> SearchResponse[ResultWithTextAndHighlightsAndSummary]:
1122
1217
  ...
1123
1218
 
@@ -1127,13 +1222,13 @@ class Exa:
1127
1222
  for k, v in {"url": url, **kwargs}.items()
1128
1223
  if k != "self" and v is not None
1129
1224
  }
1130
- 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:
1131
1226
  options["text"] = True
1132
1227
  validate_search_options(
1133
- options, {**FIND_SIMILAR_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES}
1228
+ options, {**FIND_SIMILAR_OPTIONS_TYPES, **CONTENTS_OPTIONS_TYPES, **CONTENTS_ENDPOINT_OPTIONS_TYPES}
1134
1229
  )
1135
1230
  options = to_camel_case(options)
1136
- options = nest_fields(options, ["text", "highlights", "summary"], "contents")
1231
+ options = nest_fields(options, ["text", "highlights", "summary", "subpages", "livecrawl", "livecrawl_timeout", "extras"], "contents")
1137
1232
  data = self.request("/findSimilar", options)
1138
1233
  return SearchResponse(
1139
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.1b0
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.1-beta",
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