exa-py 1.0.1__py3-none-any.whl → 1.0.2__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
@@ -115,10 +115,10 @@ class TextContentsOptions(TypedDict, total=False):
115
115
  """A class representing the options that you can specify when requesting text
116
116
 
117
117
  Attributes:
118
- max_length (int): The maximum number of characters to return. Default: None (no limit).
118
+ max_characters (int): The maximum number of characters to return. Default: None (no limit).
119
119
  include_html_tags (bool): If true, include HTML tags in the returned text. Default false.
120
120
  """
121
- max_length: int
121
+ max_characters: int
122
122
  include_html_tags: bool
123
123
 
124
124
 
@@ -290,7 +290,7 @@ def nest_fields(original_dict: Dict, fields_to_nest: List[str], new_key: str):
290
290
  class Exa:
291
291
  """A client for interacting with Exa API."""
292
292
 
293
- def __init__(self, api_key: Optional[str], base_url: str = "https://api.exa.ai"):
293
+ def __init__(self, api_key: Optional[str], base_url: str = "https://api.exa.ai", user_agent: str = "metaphor-python 1.0.2"):
294
294
  """Initialize the Exa client with the provided API key and optional base URL and user agent.
295
295
 
296
296
  Args:
@@ -306,7 +306,7 @@ class Exa:
306
306
  "API key must be provided as argument or in EXA_API_KEY environment variable"
307
307
  )
308
308
  self.base_url = base_url
309
- self.headers = {"x-api-key": api_key}
309
+ self.headers = {"x-api-key": api_key, "User-Agent": user_agent}
310
310
 
311
311
  def request(self, endpoint: str, data):
312
312
  res = requests.post(self.base_url + endpoint, json=data, headers=self.headers)
@@ -0,0 +1,114 @@
1
+ Metadata-Version: 2.1
2
+ Name: exa-py
3
+ Version: 1.0.2
4
+ Summary: Python SDK for Exa API.
5
+ Home-page: https://github.com/exa-labs/exa-py
6
+ Author: Exa
7
+ Author-email: hello@exa.ai
8
+ Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Typing :: Typed
12
+ Classifier: Programming Language :: Python :: 3.7
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: requests
20
+
21
+ # Exa
22
+
23
+ Exa API in Python
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install exa_py
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Import the package and initialize the Exa client with your API key:
34
+
35
+ ```python
36
+ from exa_py import Exa
37
+
38
+ exa = Exa(api_key="your-api-key")
39
+ ```
40
+
41
+ ## Search Request
42
+
43
+ ```python
44
+
45
+ response = exa.search("funny article about silicon valley tech culture",
46
+ num_results=5,
47
+ include_domains=["nytimes.com", "wsj.com"],
48
+ start_published_date="2023-06-12"
49
+ )
50
+
51
+ for result in response.results:
52
+ print(result.title, result.url)
53
+ ```
54
+
55
+ ## Find Similar
56
+
57
+ ```python
58
+ response = exa.find_similar("https://waitbutwhy.com/2014/05/fermi-paradox.html", num_results=5)
59
+
60
+ for result in response.results:
61
+ print(result.title, result.url)
62
+ ```
63
+
64
+ ## Retrieve Document Contents
65
+
66
+ ```python
67
+ ids = ["8U71IlQ5DUTdsZFherhhYA", "X3wd0PbJmAvhu_DQjDKA7A"]
68
+ response = exa.get_contents(ids)
69
+
70
+ for content in response.contents:
71
+ print(content.title, content.url)
72
+ ```
73
+
74
+ ## Reference
75
+
76
+ ### `exa.search()`
77
+
78
+ This function performs a search on the Exa API.
79
+
80
+ #### Args
81
+
82
+ - query (str): The search query.
83
+ - **options**: Additional search options. Valid options are:
84
+ - `num_results` (int): The number of search results to return.
85
+ - `include_domains` (list): A list of domains to include in the search.
86
+ - `exclude_domains` (list): A list of domains to exclude from the search.
87
+ - `start_crawl_date` (str): The start date for the crawl (in YYYY-MM-DD format).
88
+ - `end_crawl_date` (str): The end date for the crawl (in YYYY-MM-DD format).
89
+ - `start_published_date` (str): The start date for when the document was published (in YYYY-MM-DD format).
90
+ - `end_published_date` (str): The end date for when the document was published (in YYYY-MM-DD format).
91
+ - `use_autoprompt` (bool): Whether to use autoprompt for the search.
92
+ - `type` (str): The type of search, 'keyword' or 'neural'. Default: neural
93
+
94
+ #### Returns
95
+ `SearchResponse`: A dataclass containing the search results.
96
+
97
+ ### `exa.find_similar()`
98
+
99
+ #### Args:
100
+ - url (str): The base url to find similar links with.
101
+ - **options**: Additional search options. Valid options are:
102
+ - `num_results` (int): The number of search results to return.
103
+ - `include_domains` (list): A list of domains to include in the search.
104
+ - `exclude_domains` (list): A list of domains to exclude from the search.
105
+ - `start_crawl_date` (str): The start date for the crawl (in YYYY-MM-DD format).
106
+ - `end_crawl_date` (str): The end date for the crawl (in YYYY-MM-DD format).
107
+ - `start_published_date` (str): The start date for when the document was published (in YYYY-MM-DD format).
108
+ - `end_published_date` (str): The end date for when the document was published (in YYYY-MM-DD format).
109
+
110
+ #### Returns
111
+ `SearchResponse`: A dataclass containing the search results.
112
+
113
+ # Contribution
114
+ Contributions to exa-py are very welcome! Feel free to submit pull requests or raise issues.
@@ -0,0 +1,6 @@
1
+ exa_py/__init__.py,sha256=aVF1zB_UV3dagJ5Vn2WrdcInzibdIW61M89sjwRCU_g,29
2
+ exa_py/api.py,sha256=o_QmsTVYeiht_vsvUvG_YwfIOPSgHfDQK2HJaeue92A,22669
3
+ exa_py-1.0.2.dist-info/METADATA,sha256=rY0HDDusSvHSCkIka87KcE5uefEUfNsYPEZTukkxmpM,3578
4
+ exa_py-1.0.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
5
+ exa_py-1.0.2.dist-info/top_level.txt,sha256=Mfkmscdw9HWR1PtVhU1gAiVo6DHu_tyiVdb89gfZBVI,7
6
+ exa_py-1.0.2.dist-info/RECORD,,
@@ -1,15 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: exa-py
3
- Version: 1.0.1
4
- Summary: Python SDK for Exa API.
5
- Home-page: https://github.com/exa-labs/exa-py
6
- Author: Exa
7
- Author-email: hello@exa.ai
8
- Classifier: Development Status :: 5 - Production/Stable
9
- Classifier: Intended Audience :: Developers
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Typing :: Typed
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
- Requires-Dist: requests
15
-
@@ -1,6 +0,0 @@
1
- exa_py/__init__.py,sha256=aVF1zB_UV3dagJ5Vn2WrdcInzibdIW61M89sjwRCU_g,29
2
- exa_py/api.py,sha256=X0s29uY-E1SJEDwE3FWwFKJSyvIx0sEV038XXJVTc-k,22592
3
- exa_py-1.0.1.dist-info/METADATA,sha256=MDa_cqeZclIhnDOsdgTuz3x9qcappM9hTTq3_6OTLiM,472
4
- exa_py-1.0.1.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
5
- exa_py-1.0.1.dist-info/top_level.txt,sha256=Mfkmscdw9HWR1PtVhU1gAiVo6DHu_tyiVdb89gfZBVI,7
6
- exa_py-1.0.1.dist-info/RECORD,,
File without changes