exa-py 1.9.0__py3-none-any.whl → 1.10.0__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.

@@ -0,0 +1,41 @@
1
+
2
+ from __future__ import annotations
3
+
4
+ from pydantic import ConfigDict
5
+
6
+ from typing import Any, Dict, Optional
7
+
8
+ from pydantic import BaseModel
9
+
10
+ class ExaBaseModel(BaseModel):
11
+ """Base model for all Exa models with common configuration."""
12
+ model_config = ConfigDict(populate_by_name=True)
13
+
14
+ class WebsetsBaseClient:
15
+ base_url: str
16
+
17
+ """Base client for Exa API resources."""
18
+
19
+ def __init__(self, client):
20
+ """Initialize the client.
21
+
22
+ Args:
23
+ client: The parent Exa client.
24
+ """
25
+ self._client = client
26
+
27
+ def request(self, endpoint: str, data: Optional[Dict[str, Any]] = None,
28
+ method: str = "POST", params: Optional[Dict[str, Any]] = None) -> Dict[str, Any]:
29
+ """Make a request to the Exa API.
30
+
31
+ Args:
32
+ endpoint (str): The API endpoint to request.
33
+ data (Dict[str, Any], optional): The request data. Defaults to None.
34
+ method (str, optional): The HTTP method. Defaults to "POST".
35
+ params (Dict[str, Any], optional): The query parameters. Defaults to None.
36
+
37
+ Returns:
38
+ Dict[str, Any]: The API response.
39
+ """
40
+ return self._client.request("/websets/" + endpoint, data=data, method=method, params=params)
41
+
@@ -0,0 +1,3 @@
1
+ from .client import WebsetEnrichmentsClient
2
+
3
+ __all__ = ["WebsetEnrichmentsClient"]
@@ -0,0 +1,65 @@
1
+ from __future__ import annotations
2
+
3
+ from ..types import (
4
+ CreateEnrichmentParameters,
5
+ WebsetEnrichment,
6
+ )
7
+ from ..core.base import WebsetsBaseClient
8
+
9
+ class WebsetEnrichmentsClient(WebsetsBaseClient):
10
+ """Client for managing Webset Enrichments."""
11
+
12
+ def __init__(self, client):
13
+ super().__init__(client)
14
+
15
+ def create(self, webset_id: str, params: CreateEnrichmentParameters) -> WebsetEnrichment:
16
+ """Create an Enrichment for a Webset.
17
+
18
+ Args:
19
+ webset_id (str): The id of the Webset.
20
+ params (CreateEnrichmentParameters): The parameters for creating an enrichment.
21
+
22
+ Returns:
23
+ WebsetEnrichment: The created enrichment.
24
+ """
25
+ response = self.request(f"/v0/websets/{webset_id}/enrichments", data=params.model_dump(by_alias=True, exclude_none=True))
26
+ return WebsetEnrichment.model_validate(response)
27
+
28
+ def get(self, webset_id: str, id: str) -> WebsetEnrichment:
29
+ """Get an Enrichment by ID.
30
+
31
+ Args:
32
+ webset_id (str): The id of the Webset.
33
+ id (str): The id of the Enrichment.
34
+
35
+ Returns:
36
+ WebsetEnrichment: The retrieved enrichment.
37
+ """
38
+ response = self.request(f"/v0/websets/{webset_id}/enrichments/{id}", method="GET")
39
+ return WebsetEnrichment.model_validate(response)
40
+
41
+ def delete(self, webset_id: str, id: str) -> WebsetEnrichment:
42
+ """Delete an Enrichment.
43
+
44
+ Args:
45
+ webset_id (str): The id of the Webset.
46
+ id (str): The id of the Enrichment.
47
+
48
+ Returns:
49
+ WebsetEnrichment: The deleted enrichment.
50
+ """
51
+ response = self.request(f"/v0/websets/{webset_id}/enrichments/{id}", method="DELETE")
52
+ return WebsetEnrichment.model_validate(response)
53
+
54
+ def cancel(self, webset_id: str, id: str) -> WebsetEnrichment:
55
+ """Cancel a running Enrichment.
56
+
57
+ Args:
58
+ webset_id (str): The id of the Webset.
59
+ id (str): The id of the Enrichment.
60
+
61
+ Returns:
62
+ WebsetEnrichment: The canceled enrichment.
63
+ """
64
+ response = self.request(f"/v0/websets/{webset_id}/enrichments/{id}/cancel", method="POST")
65
+ return WebsetEnrichment.model_validate(response)
@@ -0,0 +1,3 @@
1
+ from .client import WebsetItemsClient
2
+
3
+ __all__ = ["WebsetItemsClient"]
@@ -0,0 +1,78 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional, Iterator
4
+
5
+ from ..types import (
6
+ WebsetItem,
7
+ ListWebsetItemResponse,
8
+ )
9
+ from ..core.base import WebsetsBaseClient
10
+
11
+ class WebsetItemsClient(WebsetsBaseClient):
12
+ """Client for managing Webset Items."""
13
+
14
+ def __init__(self, client):
15
+ super().__init__(client)
16
+
17
+ def list(self, webset_id: str, *, cursor: Optional[str] = None,
18
+ limit: Optional[int] = None) -> ListWebsetItemResponse:
19
+ """List all Items for a Webset.
20
+
21
+ Args:
22
+ webset_id (str): The id or externalId of the Webset.
23
+ cursor (str, optional): The cursor to paginate through the results.
24
+ limit (int, optional): The number of results to return (max 200).
25
+
26
+ Returns:
27
+ ListWebsetItemResponse: List of webset items.
28
+ """
29
+ params = {k: v for k, v in {"cursor": cursor, "limit": limit}.items() if v is not None}
30
+ response = self.request(f"/v0/websets/{webset_id}/items", params=params, method="GET")
31
+ return ListWebsetItemResponse.model_validate(response)
32
+
33
+ def list_all(self, webset_id: str, *, limit: Optional[int] = None) -> Iterator[WebsetItem]:
34
+ """Iterate through all Items in a Webset, handling pagination automatically.
35
+
36
+ Args:
37
+ webset_id (str): The id or externalId of the Webset.
38
+ limit (int, optional): The number of results to return per page (max 200).
39
+
40
+ Yields:
41
+ WebsetItem: Each item in the webset.
42
+ """
43
+ cursor = None
44
+ while True:
45
+ response = self.list(webset_id, cursor=cursor, limit=limit)
46
+ for item in response.data:
47
+ yield item
48
+
49
+ if not response.has_more or not response.next_cursor:
50
+ break
51
+
52
+ cursor = response.next_cursor
53
+
54
+ def get(self, webset_id: str, id: str) -> WebsetItem:
55
+ """Get an Item by ID.
56
+
57
+ Args:
58
+ webset_id (str): The id or externalId of the Webset.
59
+ id (str): The id of the Webset item.
60
+
61
+ Returns:
62
+ WebsetItem: The retrieved item.
63
+ """
64
+ response = self.request(f"/v0/websets/{webset_id}/items/{id}", method="GET")
65
+ return WebsetItem.model_validate(response)
66
+
67
+ def delete(self, webset_id: str, id: str) -> WebsetItem:
68
+ """Delete an Item.
69
+
70
+ Args:
71
+ webset_id (str): The id or externalId of the Webset.
72
+ id (str): The id of the Webset item.
73
+
74
+ Returns:
75
+ WebsetItem: The deleted item.
76
+ """
77
+ response = self.request(f"/v0/websets/{webset_id}/items/{id}", method="DELETE")
78
+ return WebsetItem.model_validate(response)
@@ -0,0 +1,3 @@
1
+ from .client import WebsetSearchesClient
2
+
3
+ __all__ = ["WebsetSearchesClient"]
@@ -0,0 +1,52 @@
1
+ from __future__ import annotations
2
+
3
+ from ..types import (
4
+ CreateWebsetSearchParameters,
5
+ WebsetSearch,
6
+ )
7
+ from ..core.base import WebsetsBaseClient
8
+
9
+ class WebsetSearchesClient(WebsetsBaseClient):
10
+ """Client for managing Webset Searches."""
11
+
12
+ def __init__(self, client):
13
+ super().__init__(client)
14
+
15
+ def create(self, webset_id: str, params: CreateWebsetSearchParameters) -> WebsetSearch:
16
+ """Create a new Search for the Webset.
17
+
18
+ Args:
19
+ webset_id (str): The id of the Webset.
20
+ params (CreateWebsetSearchParameters): The parameters for creating a search.
21
+
22
+ Returns:
23
+ WebsetSearch: The created search.
24
+ """
25
+ response = self.request(f"/v0/websets/{webset_id}/searches", data=params.model_dump(by_alias=True, exclude_none=True))
26
+ return WebsetSearch.model_validate(response)
27
+
28
+ def get(self, webset_id: str, id: str) -> WebsetSearch:
29
+ """Get a Search by ID.
30
+
31
+ Args:
32
+ webset_id (str): The id of the Webset.
33
+ id (str): The id of the Search.
34
+
35
+ Returns:
36
+ WebsetSearch: The retrieved search.
37
+ """
38
+ response = self.request(f"/v0/websets/{webset_id}/searches/{id}", method="GET")
39
+ return WebsetSearch.model_validate(response)
40
+
41
+ def cancel(self, webset_id: str, id: str) -> WebsetSearch:
42
+ """Cancel a running Search.
43
+
44
+ Args:
45
+ webset_id (str): The id of the Webset.
46
+ id (str): The id of the Search.
47
+
48
+ Returns:
49
+ WebsetSearch: The canceled search.
50
+ """
51
+ response = self.request(f"/v0/websets/{webset_id}/searches/{id}/cancel", method="POST")
52
+ return WebsetSearch.model_validate(response)