exa-py 1.13.0__py3-none-any.whl → 1.13.1__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 +42 -31
- exa_py/websets/_generator/pydantic/BaseModel.jinja2 +42 -0
- {exa_py-1.13.0.dist-info → exa_py-1.13.1.dist-info}/METADATA +18 -13
- {exa_py-1.13.0.dist-info → exa_py-1.13.1.dist-info}/RECORD +6 -6
- {exa_py-1.13.0.dist-info → exa_py-1.13.1.dist-info}/WHEEL +1 -2
- exa_py-1.13.0.dist-info/top_level.txt +0 -1
exa_py/api.py
CHANGED
|
@@ -56,7 +56,7 @@ def snake_to_camel(snake_str: str) -> str:
|
|
|
56
56
|
return "$schema"
|
|
57
57
|
if snake_str == "not_":
|
|
58
58
|
return "not"
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
components = snake_str.split("_")
|
|
61
61
|
return components[0] + "".join(x.title() for x in components[1:])
|
|
62
62
|
|
|
@@ -261,6 +261,7 @@ class JSONSchema(TypedDict, total=False):
|
|
|
261
261
|
"""Represents a JSON Schema definition used for structured summary output.
|
|
262
262
|
To learn more visit https://json-schema.org/overview/what-is-jsonschema.
|
|
263
263
|
"""
|
|
264
|
+
|
|
264
265
|
schema_: str # This will be converted to "$schema" in JSON
|
|
265
266
|
title: str
|
|
266
267
|
description: str
|
|
@@ -288,7 +289,7 @@ class SummaryContentsOptions(TypedDict, total=False):
|
|
|
288
289
|
|
|
289
290
|
query: str
|
|
290
291
|
schema: JSONSchema
|
|
291
|
-
|
|
292
|
+
|
|
292
293
|
|
|
293
294
|
class ExtrasOptions(TypedDict, total=False):
|
|
294
295
|
"""A class representing additional extraction fields (e.g. links, images)"""
|
|
@@ -669,7 +670,7 @@ class AnswerResponse:
|
|
|
669
670
|
citations (List[AnswerResult]): A list of citations used to generate the answer.
|
|
670
671
|
"""
|
|
671
672
|
|
|
672
|
-
answer: str
|
|
673
|
+
answer: Union[str, dict[str, Any]]
|
|
673
674
|
citations: List[AnswerResult]
|
|
674
675
|
|
|
675
676
|
def __str__(self):
|
|
@@ -765,9 +766,9 @@ class AsyncStreamAnswerResponse:
|
|
|
765
766
|
content = chunk["choices"][0]["delta"].get("content")
|
|
766
767
|
|
|
767
768
|
if (
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
769
|
+
"citations" in chunk
|
|
770
|
+
and chunk["citations"]
|
|
771
|
+
and chunk["citations"] != "null"
|
|
771
772
|
):
|
|
772
773
|
citations = [
|
|
773
774
|
AnswerResult(**to_snake_case(s)) for s in chunk["citations"]
|
|
@@ -776,6 +777,7 @@ class AsyncStreamAnswerResponse:
|
|
|
776
777
|
stream_chunk = StreamChunk(content=content, citations=citations)
|
|
777
778
|
if stream_chunk.has_data():
|
|
778
779
|
yield stream_chunk
|
|
780
|
+
|
|
779
781
|
return generator()
|
|
780
782
|
|
|
781
783
|
def close(self) -> None:
|
|
@@ -834,6 +836,7 @@ def nest_fields(original_dict: Dict, fields_to_nest: List[str], new_key: str):
|
|
|
834
836
|
|
|
835
837
|
return original_dict
|
|
836
838
|
|
|
839
|
+
|
|
837
840
|
@dataclass
|
|
838
841
|
class ResearchTaskResponse:
|
|
839
842
|
"""A class representing the response for a research task.
|
|
@@ -889,10 +892,20 @@ class Exa:
|
|
|
889
892
|
"API key must be provided as an argument or in EXA_API_KEY environment variable"
|
|
890
893
|
)
|
|
891
894
|
self.base_url = base_url
|
|
892
|
-
self.headers = {
|
|
895
|
+
self.headers = {
|
|
896
|
+
"x-api-key": api_key,
|
|
897
|
+
"User-Agent": user_agent,
|
|
898
|
+
"Content-Type": "application/json",
|
|
899
|
+
}
|
|
893
900
|
self.websets = WebsetsClient(self)
|
|
894
901
|
|
|
895
|
-
def request(
|
|
902
|
+
def request(
|
|
903
|
+
self,
|
|
904
|
+
endpoint: str,
|
|
905
|
+
data: Optional[Union[Dict[str, Any], str]] = None,
|
|
906
|
+
method: str = "POST",
|
|
907
|
+
params: Optional[Dict[str, Any]] = None,
|
|
908
|
+
) -> Union[Dict[str, Any], requests.Response]:
|
|
896
909
|
"""Send a request to the Exa API, optionally streaming if data['stream'] is True.
|
|
897
910
|
|
|
898
911
|
Args:
|
|
@@ -915,13 +928,13 @@ class Exa:
|
|
|
915
928
|
else:
|
|
916
929
|
# Otherwise, serialize the dictionary to JSON if it exists
|
|
917
930
|
json_data = json.dumps(data, cls=ExaJSONEncoder) if data else None
|
|
918
|
-
|
|
931
|
+
|
|
919
932
|
if data and data.get("stream"):
|
|
920
933
|
res = requests.post(
|
|
921
|
-
self.base_url + endpoint,
|
|
934
|
+
self.base_url + endpoint,
|
|
922
935
|
data=json_data,
|
|
923
|
-
headers=self.headers,
|
|
924
|
-
stream=True
|
|
936
|
+
headers=self.headers,
|
|
937
|
+
stream=True,
|
|
925
938
|
)
|
|
926
939
|
return res
|
|
927
940
|
|
|
@@ -931,20 +944,14 @@ class Exa:
|
|
|
931
944
|
)
|
|
932
945
|
elif method.upper() == "POST":
|
|
933
946
|
res = requests.post(
|
|
934
|
-
self.base_url + endpoint,
|
|
935
|
-
data=json_data,
|
|
936
|
-
headers=self.headers
|
|
947
|
+
self.base_url + endpoint, data=json_data, headers=self.headers
|
|
937
948
|
)
|
|
938
949
|
elif method.upper() == "PATCH":
|
|
939
950
|
res = requests.patch(
|
|
940
|
-
self.base_url + endpoint,
|
|
941
|
-
data=json_data,
|
|
942
|
-
headers=self.headers
|
|
951
|
+
self.base_url + endpoint, data=json_data, headers=self.headers
|
|
943
952
|
)
|
|
944
953
|
elif method.upper() == "DELETE":
|
|
945
|
-
res = requests.delete(
|
|
946
|
-
self.base_url + endpoint, headers=self.headers
|
|
947
|
-
)
|
|
954
|
+
res = requests.delete(self.base_url + endpoint, headers=self.headers)
|
|
948
955
|
else:
|
|
949
956
|
raise ValueError(f"Unsupported HTTP method: {method}")
|
|
950
957
|
|
|
@@ -1875,6 +1882,7 @@ class Exa:
|
|
|
1875
1882
|
text: Optional[bool] = False,
|
|
1876
1883
|
system_prompt: Optional[str] = None,
|
|
1877
1884
|
model: Optional[Literal["exa", "exa-pro"]] = None,
|
|
1885
|
+
output_schema: Optional[dict[str, Any]] = None,
|
|
1878
1886
|
) -> Union[AnswerResponse, StreamAnswerResponse]: ...
|
|
1879
1887
|
|
|
1880
1888
|
def answer(
|
|
@@ -1885,6 +1893,7 @@ class Exa:
|
|
|
1885
1893
|
text: Optional[bool] = False,
|
|
1886
1894
|
system_prompt: Optional[str] = None,
|
|
1887
1895
|
model: Optional[Literal["exa", "exa-pro"]] = None,
|
|
1896
|
+
output_schema: Optional[dict[str, Any]] = None,
|
|
1888
1897
|
) -> Union[AnswerResponse, StreamAnswerResponse]:
|
|
1889
1898
|
"""Generate an answer to a query using Exa's search and LLM capabilities.
|
|
1890
1899
|
|
|
@@ -1893,6 +1902,7 @@ class Exa:
|
|
|
1893
1902
|
text (bool, optional): Whether to include full text in the results. Defaults to False.
|
|
1894
1903
|
system_prompt (str, optional): A system prompt to guide the LLM's behavior when generating the answer.
|
|
1895
1904
|
model (str, optional): The model to use for answering. Either "exa" or "exa-pro". Defaults to None.
|
|
1905
|
+
output_schema (dict[str, Any], optional): JSON schema describing the desired answer structure.
|
|
1896
1906
|
|
|
1897
1907
|
Returns:
|
|
1898
1908
|
AnswerResponse: An object containing the answer and citations.
|
|
@@ -1922,6 +1932,7 @@ class Exa:
|
|
|
1922
1932
|
text: bool = False,
|
|
1923
1933
|
system_prompt: Optional[str] = None,
|
|
1924
1934
|
model: Optional[Literal["exa", "exa-pro"]] = None,
|
|
1935
|
+
output_schema: Optional[dict[str, Any]] = None,
|
|
1925
1936
|
) -> StreamAnswerResponse:
|
|
1926
1937
|
"""Generate a streaming answer response.
|
|
1927
1938
|
|
|
@@ -1930,7 +1941,7 @@ class Exa:
|
|
|
1930
1941
|
text (bool): Whether to include full text in the results. Defaults to False.
|
|
1931
1942
|
system_prompt (str, optional): A system prompt to guide the LLM's behavior when generating the answer.
|
|
1932
1943
|
model (str, optional): The model to use for answering. Either "exa" or "exa-pro". Defaults to None.
|
|
1933
|
-
|
|
1944
|
+
output_schema (dict[str, Any], optional): JSON schema describing the desired answer structure.
|
|
1934
1945
|
Returns:
|
|
1935
1946
|
StreamAnswerResponse: An object that can be iterated over to retrieve (partial text, partial citations).
|
|
1936
1947
|
Each iteration yields a tuple of (Optional[str], Optional[List[AnswerResult]]).
|
|
@@ -1982,9 +1993,7 @@ class AsyncExa(Exa):
|
|
|
1982
1993
|
# this may only be a
|
|
1983
1994
|
if self._client is None:
|
|
1984
1995
|
self._client = httpx.AsyncClient(
|
|
1985
|
-
base_url=self.base_url,
|
|
1986
|
-
headers=self.headers,
|
|
1987
|
-
timeout=60
|
|
1996
|
+
base_url=self.base_url, headers=self.headers, timeout=60
|
|
1988
1997
|
)
|
|
1989
1998
|
return self._client
|
|
1990
1999
|
|
|
@@ -2004,15 +2013,14 @@ class AsyncExa(Exa):
|
|
|
2004
2013
|
"""
|
|
2005
2014
|
if data.get("stream"):
|
|
2006
2015
|
request = httpx.Request(
|
|
2007
|
-
|
|
2008
|
-
self.base_url + endpoint,
|
|
2009
|
-
json=data,
|
|
2010
|
-
headers=self.headers
|
|
2016
|
+
"POST", self.base_url + endpoint, json=data, headers=self.headers
|
|
2011
2017
|
)
|
|
2012
2018
|
res = await self.client.send(request, stream=True)
|
|
2013
2019
|
return res
|
|
2014
2020
|
|
|
2015
|
-
res = await self.client.post(
|
|
2021
|
+
res = await self.client.post(
|
|
2022
|
+
self.base_url + endpoint, json=data, headers=self.headers
|
|
2023
|
+
)
|
|
2016
2024
|
if res.status_code != 200:
|
|
2017
2025
|
raise ValueError(
|
|
2018
2026
|
f"Request failed with status code {res.status_code}: {res.text}"
|
|
@@ -2250,6 +2258,7 @@ class AsyncExa(Exa):
|
|
|
2250
2258
|
text: Optional[bool] = False,
|
|
2251
2259
|
system_prompt: Optional[str] = None,
|
|
2252
2260
|
model: Optional[Literal["exa", "exa-pro"]] = None,
|
|
2261
|
+
output_schema: Optional[dict[str, Any]] = None,
|
|
2253
2262
|
) -> Union[AnswerResponse, StreamAnswerResponse]:
|
|
2254
2263
|
"""Generate an answer to a query using Exa's search and LLM capabilities.
|
|
2255
2264
|
|
|
@@ -2258,6 +2267,7 @@ class AsyncExa(Exa):
|
|
|
2258
2267
|
text (bool, optional): Whether to include full text in the results. Defaults to False.
|
|
2259
2268
|
system_prompt (str, optional): A system prompt to guide the LLM's behavior when generating the answer.
|
|
2260
2269
|
model (str, optional): The model to use for answering. Either "exa" or "exa-pro". Defaults to None.
|
|
2270
|
+
output_schema (dict[str, Any], optional): JSON schema describing the desired answer structure.
|
|
2261
2271
|
|
|
2262
2272
|
Returns:
|
|
2263
2273
|
AnswerResponse: An object containing the answer and citations.
|
|
@@ -2287,6 +2297,7 @@ class AsyncExa(Exa):
|
|
|
2287
2297
|
text: bool = False,
|
|
2288
2298
|
system_prompt: Optional[str] = None,
|
|
2289
2299
|
model: Optional[Literal["exa", "exa-pro"]] = None,
|
|
2300
|
+
output_schema: Optional[dict[str, Any]] = None,
|
|
2290
2301
|
) -> AsyncStreamAnswerResponse:
|
|
2291
2302
|
"""Generate a streaming answer response.
|
|
2292
2303
|
|
|
@@ -2295,7 +2306,7 @@ class AsyncExa(Exa):
|
|
|
2295
2306
|
text (bool): Whether to include full text in the results. Defaults to False.
|
|
2296
2307
|
system_prompt (str, optional): A system prompt to guide the LLM's behavior when generating the answer.
|
|
2297
2308
|
model (str, optional): The model to use for answering. Either "exa" or "exa-pro". Defaults to None.
|
|
2298
|
-
|
|
2309
|
+
output_schema (dict[str, Any], optional): JSON schema describing the desired answer structure.
|
|
2299
2310
|
Returns:
|
|
2300
2311
|
AsyncStreamAnswerResponse: An object that can be iterated over to retrieve (partial text, partial citations).
|
|
2301
2312
|
Each iteration yields a tuple of (Optional[str], Optional[List[AnswerResult]]).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{% for decorator in decorators -%}
|
|
2
|
+
{{ decorator }}
|
|
3
|
+
{% endfor -%}
|
|
4
|
+
class {{ class_name }}({{ base_class }}):{% if comment is defined %} # {{ comment }}{% endif %}
|
|
5
|
+
{%- if description %}
|
|
6
|
+
"""
|
|
7
|
+
{{ description | indent(4) }}
|
|
8
|
+
"""
|
|
9
|
+
{%- endif %}
|
|
10
|
+
{%- if not fields and not description %}
|
|
11
|
+
pass
|
|
12
|
+
{%- endif %}
|
|
13
|
+
{%- if config %}
|
|
14
|
+
{%- filter indent(4) %}
|
|
15
|
+
{%- endfilter %}
|
|
16
|
+
{%- endif %}
|
|
17
|
+
{%- for field in fields -%}
|
|
18
|
+
{%- if field.name == "type" and field.field %}
|
|
19
|
+
type: Literal['{{ field.default }}']
|
|
20
|
+
{%- elif field.name == "object" and field.field %}
|
|
21
|
+
object: Literal['{{ field.default }}']
|
|
22
|
+
{%- elif not field.annotated and field.field %}
|
|
23
|
+
{{ field.name }}: {{ field.type_hint }} = {{ field.field }}
|
|
24
|
+
{%- else %}
|
|
25
|
+
{%- if field.annotated %}
|
|
26
|
+
{{ field.name }}: {{ field.annotated }}
|
|
27
|
+
{%- else %}
|
|
28
|
+
{{ field.name }}: {{ field.type_hint }}
|
|
29
|
+
{%- endif %}
|
|
30
|
+
{%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none)) or field.data_type.is_optional
|
|
31
|
+
%} = {{ field.represented_default }}
|
|
32
|
+
{%- endif -%}
|
|
33
|
+
{%- endif %}
|
|
34
|
+
{%- if field.docstring %}
|
|
35
|
+
"""
|
|
36
|
+
{{ field.docstring | indent(4) }}
|
|
37
|
+
"""
|
|
38
|
+
{%- endif %}
|
|
39
|
+
{%- for method in methods -%}
|
|
40
|
+
{{ method }}
|
|
41
|
+
{%- endfor -%}
|
|
42
|
+
{%- endfor -%}
|
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: exa-py
|
|
3
|
-
Version: 1.13.
|
|
3
|
+
Version: 1.13.1
|
|
4
4
|
Summary: Python SDK for Exa API.
|
|
5
|
-
Home-page: https://github.com/exa-labs/exa-py
|
|
6
|
-
Author: Exa
|
|
7
|
-
Author-email: Exa AI <hello@exa.ai>
|
|
8
5
|
License: MIT
|
|
6
|
+
Author: Exa AI
|
|
7
|
+
Author-email: hello@exa.ai
|
|
9
8
|
Requires-Python: >=3.9
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Requires-Dist: httpx (>=0.28.1)
|
|
17
|
+
Requires-Dist: openai (>=1.48)
|
|
18
|
+
Requires-Dist: pydantic (>=2.10.6)
|
|
19
|
+
Requires-Dist: pytest-mock (>=3.14.0)
|
|
20
|
+
Requires-Dist: requests (>=2.32.3)
|
|
21
|
+
Requires-Dist: typing-extensions (>=4.12.2)
|
|
10
22
|
Description-Content-Type: text/markdown
|
|
11
|
-
Requires-Dist: requests>=2.32.3
|
|
12
|
-
Requires-Dist: typing-extensions>=4.12.2
|
|
13
|
-
Requires-Dist: openai>=1.48
|
|
14
|
-
Requires-Dist: pydantic>=2.10.6
|
|
15
|
-
Requires-Dist: pytest-mock>=3.14.0
|
|
16
|
-
Requires-Dist: httpx>=0.28.1
|
|
17
|
-
Dynamic: author
|
|
18
|
-
Dynamic: home-page
|
|
19
23
|
|
|
20
24
|
# Exa
|
|
21
25
|
|
|
@@ -93,3 +97,4 @@ exa = Exa(api_key="your-api-key")
|
|
|
93
97
|
|
|
94
98
|
```
|
|
95
99
|
|
|
100
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
exa_py/__init__.py,sha256=M2GC9oSdoV6m2msboW0vMWWl8wrth4o6gmEV4MYLGG8,66
|
|
2
|
-
exa_py/api.py,sha256=
|
|
2
|
+
exa_py/api.py,sha256=nxaMnP7wFAElJtO6UzxQoEr-gOAiuUdYkn9sNGOWP9I,87782
|
|
3
3
|
exa_py/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
exa_py/utils.py,sha256=Rc1FJjoR9LQ7L_OJM91Sd1GNkbHjcLyEvJENhRix6gc,2405
|
|
5
5
|
exa_py/websets/__init__.py,sha256=uOBAb9VrIHrPKoddGOp2ai2KgWlyUVCLMZqfbGOlboA,70
|
|
6
|
+
exa_py/websets/_generator/pydantic/BaseModel.jinja2,sha256=RUDCmPZVamoVx1WudylscYFfDhGoNNtRYlpTvKjAiuA,1276
|
|
6
7
|
exa_py/websets/client.py,sha256=GWHebkvfiGY46sIuksAhYE1RLJrHQVS2PGhlA3xbxhE,4757
|
|
7
|
-
exa_py/websets/types.py,sha256=jKnJFAHTFN55EzsusgDce-yux71zVbdSJ1m8utR4EjU,28096
|
|
8
8
|
exa_py/websets/core/__init__.py,sha256=xOyrFaqtBocMUu321Jpbk7IzIQRNZufSIGJXrKoG-Bg,323
|
|
9
9
|
exa_py/websets/core/base.py,sha256=2vCkPLEKI2K2U7d-76kqVL7qyye007iDdp15GseJN1c,3936
|
|
10
10
|
exa_py/websets/enrichments/__init__.py,sha256=5dJIEKKceUost3RnI6PpCSB3VjUCBzxseEsIXu-ZY-Y,83
|
|
@@ -13,9 +13,9 @@ exa_py/websets/items/__init__.py,sha256=DCWZJVtRmUjnMEkKdb5gW1LT9cHcb-J8lENMnyyB
|
|
|
13
13
|
exa_py/websets/items/client.py,sha256=oZoYr52WrE76Ox6GyoS9rMn7bTrIpno0FKgIWFtb57U,2796
|
|
14
14
|
exa_py/websets/searches/__init__.py,sha256=_0Zx8ES5fFTEL3T8mhLxq_xK2t0JONx6ad6AtbvClsE,77
|
|
15
15
|
exa_py/websets/searches/client.py,sha256=X3f7axWGfecmxf-2tBTX0Yf_--xToz1X8ZHbbudEzy0,1790
|
|
16
|
+
exa_py/websets/types.py,sha256=jKnJFAHTFN55EzsusgDce-yux71zVbdSJ1m8utR4EjU,28096
|
|
16
17
|
exa_py/websets/webhooks/__init__.py,sha256=iTPBCxFd73z4RifLQMX6iRECx_6pwlI5qscLNjMOUHE,77
|
|
17
18
|
exa_py/websets/webhooks/client.py,sha256=zsIRMTeJU65yj-zo7Zz-gG02Prtzgcx6utGFSoY4HQQ,4222
|
|
18
|
-
exa_py-1.13.
|
|
19
|
-
exa_py-1.13.
|
|
20
|
-
exa_py-1.13.
|
|
21
|
-
exa_py-1.13.0.dist-info/RECORD,,
|
|
19
|
+
exa_py-1.13.1.dist-info/METADATA,sha256=4Zq8keMdOoAIdBBzqqRPqVbbh6GVSJRM6d0C6gTidPo,3011
|
|
20
|
+
exa_py-1.13.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
21
|
+
exa_py-1.13.1.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
exa_py
|