exa-py 1.1.5__py3-none-any.whl → 1.1.7__py3-none-any.whl
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.
exa_py/api.py
CHANGED
|
@@ -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
|
|
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
|
|
173
|
+
f"Invalid value for option '{key}': {value}. Expected one of {expected_types}"
|
|
169
174
|
)
|
|
170
175
|
|
|
171
|
-
def
|
|
172
|
-
if
|
|
173
|
-
return
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
exa_py/__init__.py,sha256=aVF1zB_UV3dagJ5Vn2WrdcInzibdIW61M89sjwRCU_g,29
|
|
2
|
+
exa_py/api.py,sha256=Ew0bqFsCVC5NyD7BJ9fVT292v3z3Axz7cbi_ci-om1k,46645
|
|
3
|
+
exa_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
exa_py/utils.py,sha256=Rc1FJjoR9LQ7L_OJM91Sd1GNkbHjcLyEvJENhRix6gc,2405
|
|
5
|
+
exa_py-1.1.7.dist-info/METADATA,sha256=FCuU11OAguAvMwWQEbEOtWvRDx3cn93aS9QFeZS1MNg,3069
|
|
6
|
+
exa_py-1.1.7.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
7
|
+
exa_py-1.1.7.dist-info/top_level.txt,sha256=Mfkmscdw9HWR1PtVhU1gAiVo6DHu_tyiVdb89gfZBVI,7
|
|
8
|
+
exa_py-1.1.7.dist-info/RECORD,,
|
exa_py-1.1.5.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
exa_py/__init__.py,sha256=aVF1zB_UV3dagJ5Vn2WrdcInzibdIW61M89sjwRCU_g,29
|
|
2
|
-
exa_py/api.py,sha256=kUE28BRwe25a1nDQlsgunkXZujB57L3BlkSEKQMhpww,47105
|
|
3
|
-
exa_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
exa_py/utils.py,sha256=Rc1FJjoR9LQ7L_OJM91Sd1GNkbHjcLyEvJENhRix6gc,2405
|
|
5
|
-
exa_py-1.1.5.dist-info/METADATA,sha256=FQl2zDgFLlgMZRKDTrJo8BwUhJYfTIsjOd5VZsBWp1s,3069
|
|
6
|
-
exa_py-1.1.5.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
7
|
-
exa_py-1.1.5.dist-info/top_level.txt,sha256=Mfkmscdw9HWR1PtVhU1gAiVo6DHu_tyiVdb89gfZBVI,7
|
|
8
|
-
exa_py-1.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|