exa-py 1.0.16__tar.gz → 1.0.18__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.
- {exa_py-1.0.16 → exa_py-1.0.18}/PKG-INFO +1 -1
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py/api.py +24 -9
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py.egg-info/PKG-INFO +1 -1
- {exa_py-1.0.16 → exa_py-1.0.18}/setup.py +1 -1
- {exa_py-1.0.16 → exa_py-1.0.18}/README.md +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py/__init__.py +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py/py.typed +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py/utils.py +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py.egg-info/SOURCES.txt +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py.egg-info/dependency_links.txt +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py.egg-info/requires.txt +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/exa_py.egg-info/top_level.txt +0 -0
- {exa_py-1.0.16 → exa_py-1.0.18}/setup.cfg +0 -0
|
@@ -41,9 +41,9 @@ def snake_to_camel(snake_str: str) -> str:
|
|
|
41
41
|
components = snake_str.split("_")
|
|
42
42
|
return components[0] + "".join(x.title() for x in components[1:])
|
|
43
43
|
|
|
44
|
-
|
|
45
44
|
def to_camel_case(data: dict) -> dict:
|
|
46
|
-
"""
|
|
45
|
+
"""
|
|
46
|
+
Convert keys in a dictionary from snake_case to camelCase recursively.
|
|
47
47
|
|
|
48
48
|
Args:
|
|
49
49
|
data (dict): The dictionary with keys in snake_case format.
|
|
@@ -51,8 +51,11 @@ def to_camel_case(data: dict) -> dict:
|
|
|
51
51
|
Returns:
|
|
52
52
|
dict: The dictionary with keys converted to camelCase format.
|
|
53
53
|
"""
|
|
54
|
-
return {
|
|
55
|
-
|
|
54
|
+
return {
|
|
55
|
+
snake_to_camel(k): to_camel_case(v) if isinstance(v, dict) else v
|
|
56
|
+
for k, v in data.items()
|
|
57
|
+
if v is not None
|
|
58
|
+
}
|
|
56
59
|
|
|
57
60
|
def camel_to_snake(camel_str: str) -> str:
|
|
58
61
|
"""Convert camelCase string to snake_case.
|
|
@@ -66,9 +69,9 @@ def camel_to_snake(camel_str: str) -> str:
|
|
|
66
69
|
snake_str = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", camel_str)
|
|
67
70
|
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", snake_str).lower()
|
|
68
71
|
|
|
69
|
-
|
|
70
72
|
def to_snake_case(data: dict) -> dict:
|
|
71
|
-
"""
|
|
73
|
+
"""
|
|
74
|
+
Convert keys in a dictionary from camelCase to snake_case recursively.
|
|
72
75
|
|
|
73
76
|
Args:
|
|
74
77
|
data (dict): The dictionary with keys in camelCase format.
|
|
@@ -76,8 +79,10 @@ def to_snake_case(data: dict) -> dict:
|
|
|
76
79
|
Returns:
|
|
77
80
|
dict: The dictionary with keys converted to snake_case format.
|
|
78
81
|
"""
|
|
79
|
-
return {
|
|
80
|
-
|
|
82
|
+
return {
|
|
83
|
+
camel_to_snake(k): to_snake_case(v) if isinstance(v, dict) else v
|
|
84
|
+
for k, v in data.items()
|
|
85
|
+
}
|
|
81
86
|
|
|
82
87
|
SEARCH_OPTIONS_TYPES = {
|
|
83
88
|
"query": [str], # The query string.
|
|
@@ -394,15 +399,20 @@ class SearchResponse(Generic[T]):
|
|
|
394
399
|
Attributes:
|
|
395
400
|
results (List[Result]): A list of search results.
|
|
396
401
|
autoprompt_string (str, optional): The Exa query created by the autoprompt functionality.
|
|
402
|
+
resolved_search_type (str, optional): What "auto" search resolved to. "neural" or "keyword".
|
|
397
403
|
"""
|
|
398
404
|
|
|
399
405
|
results: List[T]
|
|
400
406
|
autoprompt_string: Optional[str]
|
|
407
|
+
resolved_search_type: Optional[str]
|
|
401
408
|
|
|
402
409
|
def __str__(self):
|
|
403
410
|
output = "\n\n".join(str(result) for result in self.results)
|
|
404
411
|
if self.autoprompt_string:
|
|
405
412
|
output += f"\n\nAutoprompt String: {self.autoprompt_string}"
|
|
413
|
+
if self.resolved_search_type:
|
|
414
|
+
output += f"\nResolved Search Type: {self.resolved_search_type}"
|
|
415
|
+
|
|
406
416
|
return output
|
|
407
417
|
|
|
408
418
|
|
|
@@ -430,7 +440,7 @@ class Exa:
|
|
|
430
440
|
self,
|
|
431
441
|
api_key: Optional[str],
|
|
432
442
|
base_url: str = "https://api.exa.ai",
|
|
433
|
-
user_agent: str = "exa-py 1.0.
|
|
443
|
+
user_agent: str = "exa-py 1.0.18",
|
|
434
444
|
):
|
|
435
445
|
"""Initialize the Exa client with the provided API key and optional base URL and user agent.
|
|
436
446
|
|
|
@@ -500,6 +510,7 @@ class Exa:
|
|
|
500
510
|
return SearchResponse(
|
|
501
511
|
[Result(**to_snake_case(result)) for result in data["results"]],
|
|
502
512
|
data["autopromptString"] if "autopromptString" in data else None,
|
|
513
|
+
data["resolvedSearchType"] if "resolvedSearchType" in data else None,
|
|
503
514
|
)
|
|
504
515
|
|
|
505
516
|
@overload
|
|
@@ -691,6 +702,7 @@ class Exa:
|
|
|
691
702
|
return SearchResponse(
|
|
692
703
|
[Result(**to_snake_case(result)) for result in data["results"]],
|
|
693
704
|
data["autopromptString"] if "autopromptString" in data else None,
|
|
705
|
+
data["resolvedSearchType"] if "resolvedSearchType" in data else None,
|
|
694
706
|
)
|
|
695
707
|
|
|
696
708
|
@overload
|
|
@@ -782,6 +794,7 @@ class Exa:
|
|
|
782
794
|
return SearchResponse(
|
|
783
795
|
[Result(**to_snake_case(result)) for result in data["results"]],
|
|
784
796
|
data["autopromptString"] if "autopromptString" in data else None,
|
|
797
|
+
data["resolvedSearchType"] if "resolvedSearchType" in data else None,
|
|
785
798
|
)
|
|
786
799
|
|
|
787
800
|
def find_similar(
|
|
@@ -807,6 +820,7 @@ class Exa:
|
|
|
807
820
|
return SearchResponse(
|
|
808
821
|
[Result(**to_snake_case(result)) for result in data["results"]],
|
|
809
822
|
data["autopromptString"] if "autopromptString" in data else None,
|
|
823
|
+
data["resolvedSearchType"] if "resolvedSearchType" in data else None,
|
|
810
824
|
)
|
|
811
825
|
|
|
812
826
|
@overload
|
|
@@ -990,6 +1004,7 @@ class Exa:
|
|
|
990
1004
|
return SearchResponse(
|
|
991
1005
|
[Result(**to_snake_case(result)) for result in data["results"]],
|
|
992
1006
|
data["autopromptString"] if "autopromptString" in data else None,
|
|
1007
|
+
data["resolvedSearchType"] if "resolvedSearchType" in data else None,
|
|
993
1008
|
)
|
|
994
1009
|
|
|
995
1010
|
def wrap(self, client: OpenAI):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|