1
1
"""Tool for the Exa Search API."""
2
2
3
- from typing import Any , Optional , Union
3
+ from typing import Any , Literal , Optional , Union
4
4
5
5
from exa_py import Exa # type: ignore[untyped-import]
6
6
from exa_py .api import (
@@ -74,8 +74,10 @@ def validate_environment(cls, values: dict) -> Any:
74
74
def _run (
75
75
self ,
76
76
query : str ,
77
- num_results : int ,
78
- text_contents_options : Optional [Union [TextContentsOptions , bool ]] = None ,
77
+ num_results : int = 10 ,
78
+ text_contents_options : Optional [
79
+ Union [TextContentsOptions , dict [str , Any ], bool ]
80
+ ] = None ,
79
81
highlights : Optional [Union [HighlightsContentsOptions , bool ]] = None ,
80
82
include_domains : Optional [list [str ]] = None ,
81
83
exclude_domains : Optional [list [str ]] = None ,
@@ -84,9 +86,30 @@ def _run(
84
86
start_published_date : Optional [str ] = None ,
85
87
end_published_date : Optional [str ] = None ,
86
88
use_autoprompt : Optional [bool ] = None ,
89
+ livecrawl : Optional [Literal ["always" , "fallback" , "never" ]] = None ,
90
+ summary : Optional [Union [bool , dict [str , str ]]] = None ,
91
+ type : Optional [Literal ["neural" , "keyword" , "auto" ]] = None ,
87
92
run_manager : Optional [CallbackManagerForToolRun ] = None ,
88
93
) -> Union [list [dict ], str ]:
89
- """Use the tool."""
94
+ """Use the tool.
95
+
96
+ Args:
97
+ query: The search query.
98
+ num_results: The number of search results to return (1 to 100). Default: 10
99
+ text_contents_options: How to set the page content of the results. Can be True or a dict with options like max_characters.
100
+ highlights: Whether to include highlights in the results.
101
+ include_domains: A list of domains to include in the search.
102
+ exclude_domains: A list of domains to exclude from the search.
103
+ start_crawl_date: The start date for the crawl (in YYYY-MM-DD format).
104
+ end_crawl_date: The end date for the crawl (in YYYY-MM-DD format).
105
+ start_published_date: The start date for when the document was published (in YYYY-MM-DD format).
106
+ end_published_date: The end date for when the document was published (in YYYY-MM-DD format).
107
+ use_autoprompt: Whether to use autoprompt for the search.
108
+ livecrawl: Option to crawl live webpages if content is not in the index. Options: "always", "fallback", "never"
109
+ summary: Whether to include a summary of the content. Can be a boolean or a dict with a custom query.
110
+ type: The type of search, 'keyword', 'neural', or 'auto'.
111
+ run_manager: The run manager for callbacks.
112
+ """ # noqa: E501
90
113
try :
91
114
return self .client .search_and_contents (
92
115
query ,
@@ -100,6 +123,9 @@ def _run(
100
123
start_published_date = start_published_date ,
101
124
end_published_date = end_published_date ,
102
125
use_autoprompt = use_autoprompt ,
126
+ livecrawl = livecrawl ,
127
+ summary = summary ,
128
+ type = type ,
103
129
) # type: ignore
104
130
except Exception as e :
105
131
return repr (e )
@@ -128,8 +154,10 @@ def validate_environment(cls, values: dict) -> Any:
128
154
def _run (
129
155
self ,
130
156
url : str ,
131
- num_results : int ,
132
- text_contents_options : Optional [Union [TextContentsOptions , bool ]] = None ,
157
+ num_results : int = 10 ,
158
+ text_contents_options : Optional [
159
+ Union [TextContentsOptions , dict [str , Any ], bool ]
160
+ ] = None ,
133
161
highlights : Optional [Union [HighlightsContentsOptions , bool ]] = None ,
134
162
include_domains : Optional [list [str ]] = None ,
135
163
exclude_domains : Optional [list [str ]] = None ,
@@ -139,9 +167,29 @@ def _run(
139
167
end_published_date : Optional [str ] = None ,
140
168
exclude_source_domain : Optional [bool ] = None ,
141
169
category : Optional [str ] = None ,
170
+ livecrawl : Optional [Literal ["always" , "fallback" , "never" ]] = None ,
171
+ summary : Optional [Union [bool , dict [str , str ]]] = None ,
142
172
run_manager : Optional [CallbackManagerForToolRun ] = None ,
143
173
) -> Union [list [dict ], str ]:
144
- """Use the tool."""
174
+ """Use the tool.
175
+
176
+ Args:
177
+ url: The URL to find similar pages for.
178
+ num_results: The number of search results to return (1 to 100). Default: 10
179
+ text_contents_options: How to set the page content of the results. Can be True or a dict with options like max_characters.
180
+ highlights: Whether to include highlights in the results.
181
+ include_domains: A list of domains to include in the search.
182
+ exclude_domains: A list of domains to exclude from the search.
183
+ start_crawl_date: The start date for the crawl (in YYYY-MM-DD format).
184
+ end_crawl_date: The end date for the crawl (in YYYY-MM-DD format).
185
+ start_published_date: The start date for when the document was published (in YYYY-MM-DD format).
186
+ end_published_date: The end date for when the document was published (in YYYY-MM-DD format).
187
+ exclude_source_domain: If True, exclude pages from the same domain as the source URL.
188
+ category: Filter for similar pages by category.
189
+ livecrawl: Option to crawl live webpages if content is not in the index. Options: "always", "fallback", "never"
190
+ summary: Whether to include a summary of the content. Can be a boolean or a dict with a custom query.
191
+ run_manager: The run manager for callbacks.
192
+ """ # noqa: E501
145
193
try :
146
194
return self .client .find_similar_and_contents (
147
195
url ,
@@ -156,6 +204,8 @@ def _run(
156
204
end_published_date = end_published_date ,
157
205
exclude_source_domain = exclude_source_domain ,
158
206
category = category ,
207
+ livecrawl = livecrawl ,
208
+ summary = summary ,
159
209
) # type: ignore
160
210
except Exception as e :
161
211
return repr (e )
0 commit comments