exa-py 1.1.5__tar.gz → 1.1.7__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.1.5
3
+ Version: 1.1.7
4
4
  Summary: Python SDK for Exa API.
5
5
  Home-page: https://github.com/exa-labs/exa-py
6
6
  Author: Exa
@@ -15,6 +15,8 @@ from typing import (
15
15
  overload,
16
16
  Union,
17
17
  Literal,
18
+ get_origin,
19
+ get_args
18
20
  )
19
21
  from typing_extensions import TypedDict
20
22
 
@@ -130,6 +132,9 @@ FIND_SIMILAR_OPTIONS_TYPES = {
130
132
  "category": [str],
131
133
  }
132
134
 
135
+ # the livecrawl options
136
+ LIVECRAWL_OPTIONS = Literal["always", "fallback", "never"]
137
+
133
138
  CONTENTS_OPTIONS_TYPES = {
134
139
  "ids": [list],
135
140
  "text": [dict, bool],
@@ -141,9 +146,6 @@ CONTENTS_OPTIONS_TYPES = {
141
146
  "filter_empty_results": [bool],
142
147
  }
143
148
 
144
- # the livecrawl options
145
- LIVECRAWL_OPTIONS = Literal["always", "fallback", "never"]
146
-
147
149
  # FOR BETA OPTIONS
148
150
  # if is_beta:
149
151
 
@@ -163,30 +165,20 @@ def validate_search_options(
163
165
  for key, value in options.items():
164
166
  if key not in expected:
165
167
  raise ValueError(f"Invalid option: '{key}'")
166
- if not any(isinstance(value, t) for t in expected[key]):
168
+ if value is None:
169
+ continue
170
+ expected_types = expected[key]
171
+ if not any(is_valid_type(value, t) for t in expected_types):
167
172
  raise ValueError(
168
- f"Invalid type for option '{key}': Expected one of {expected[key]}, got {type(value)}"
173
+ f"Invalid value for option '{key}': {value}. Expected one of {expected_types}"
169
174
  )
170
175
 
171
- def is_instance_or_subclass(obj, class_or_tuple):
172
- if isinstance(class_or_tuple, tuple):
173
- return any(is_instance_or_subclass(obj, cls) for cls in class_or_tuple)
174
-
175
- if get_origin(class_or_tuple) is Literal:
176
- return obj in get_args(class_or_tuple)
177
-
178
- if get_origin(class_or_tuple) is not None:
179
- # Handle subscripted generics
180
- origin = get_origin(class_or_tuple)
181
- args = get_args(class_or_tuple)
182
-
183
- if origin is list:
184
- return isinstance(obj, list) and all(isinstance(item, args[0]) for item in obj)
185
- elif origin is dict:
186
- return isinstance(obj, dict) and all(isinstance(k, args[0]) and isinstance(v, args[1]) for k, v in obj.items())
187
- # Add more cases for other generic types as needed
188
-
189
- return isinstance(obj, class_or_tuple)
176
+ def is_valid_type(value, expected_type):
177
+ if get_origin(expected_type) is Literal:
178
+ return value in get_args(expected_type)
179
+ if isinstance(expected_type, type):
180
+ return isinstance(value, expected_type)
181
+ return False # For any other case
190
182
 
191
183
  class TextContentsOptions(TypedDict, total=False):
192
184
  """A class representing the options that you can specify when requesting text
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: exa-py
3
- Version: 1.1.5
3
+ Version: 1.1.7
4
4
  Summary: Python SDK for Exa API.
5
5
  Home-page: https://github.com/exa-labs/exa-py
6
6
  Author: Exa
@@ -9,4 +9,5 @@ exa_py.egg-info/PKG-INFO
9
9
  exa_py.egg-info/SOURCES.txt
10
10
  exa_py.egg-info/dependency_links.txt
11
11
  exa_py.egg-info/requires.txt
12
- exa_py.egg-info/top_level.txt
12
+ exa_py.egg-info/top_level.txt
13
+ test/test.py
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="exa_py",
5
- version="1.1.5",
5
+ version="1.1.7",
6
6
  description="Python SDK for Exa API.",
7
7
  long_description_content_type="text/markdown",
8
8
  long_description=open("README.md").read(),
@@ -0,0 +1,12 @@
1
+ from exa_py import Exa
2
+
3
+ exa = Exa("a4e1fa44-f6a3-432b-9725-03677ee13e2e");
4
+
5
+ result = exa.get_contents(
6
+ ["quizlet.com"],
7
+ text=True,
8
+ livecrawl="never",
9
+ filter_empty_results=False
10
+ )
11
+
12
+ print(result)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes