exa-py 2.22.0__tar.gz → 2.22.2__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.
- {exa_py-2.22.0 → exa_py-2.22.2}/PKG-INFO +8 -7
- {exa_py-2.22.0 → exa_py-2.22.2}/README.md +6 -6
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/__init__.py +16 -14
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/monitors/__init__.py +16 -14
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/monitors/async_client.py +73 -98
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/monitors/client.py +75 -100
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/monitors/types.py +30 -22
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/api.py +45 -11
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/types.py +5 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/pyproject.toml +2 -2
- {exa_py-2.22.0 → exa_py-2.22.2}/LICENSE +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/async_base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/async_client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/betas.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/monitors/async_base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/monitors/base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/types.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/agent/utils.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/monitors/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/monitors/async_base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/monitors/async_client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/monitors/base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/monitors/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/monitors/types.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/py.typed +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/research/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/research/async_client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/research/base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/research/models.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/research/sync_client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/research/utils.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/tools.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/utils.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/_generator/pydantic/BaseModel.jinja2 +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/async_client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/core/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/core/async_base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/core/base.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/enrichments/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/enrichments/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/events/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/events/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/imports/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/imports/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/items/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/items/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/monitors/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/monitors/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/monitors/runs/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/monitors/runs/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/searches/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/searches/client.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/webhooks/__init__.py +0 -0
- {exa_py-2.22.0 → exa_py-2.22.2}/exa_py/websets/webhooks/client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: exa-py
|
|
3
|
-
Version: 2.22.
|
|
3
|
+
Version: 2.22.2
|
|
4
4
|
Summary: Python SDK for Exa API.
|
|
5
5
|
License: MIT
|
|
6
6
|
License-File: LICENSE
|
|
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.13
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
18
19
|
Requires-Dist: httpcore (>=1.0.9)
|
|
19
20
|
Requires-Dist: httpx (>=0.28.1)
|
|
20
21
|
Requires-Dist: openai (>=1.48)
|
|
@@ -298,15 +299,15 @@ changes = exa.beta.agent.monitors.changes.list(
|
|
|
298
299
|
since="2026-01-01T00:00:00Z",
|
|
299
300
|
)
|
|
300
301
|
|
|
301
|
-
# One-shot
|
|
302
|
-
|
|
302
|
+
# One-shot backtest of a past news window — no monitor persists.
|
|
303
|
+
backtest = exa.beta.agent.monitors.backtests.create_and_wait(
|
|
303
304
|
betas=betas,
|
|
304
305
|
entities=[{"name": "Acme Corp", "domain": "acme.com"}],
|
|
305
|
-
fields=[{"name": "funding", "description": "New funding rounds"}],
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
fields=[{"name": "funding", "description": "New funding rounds"}],
|
|
307
|
+
start_time="2026-01-01T00:00:00Z",
|
|
308
|
+
end_time="2026-01-08T00:00:00Z",
|
|
308
309
|
)
|
|
309
|
-
print(
|
|
310
|
+
print(backtest.data)
|
|
310
311
|
|
|
311
312
|
# Add entities, inspect refresh progress, clean up.
|
|
312
313
|
exa.beta.agent.monitors.entities.add(
|
|
@@ -272,15 +272,15 @@ changes = exa.beta.agent.monitors.changes.list(
|
|
|
272
272
|
since="2026-01-01T00:00:00Z",
|
|
273
273
|
)
|
|
274
274
|
|
|
275
|
-
# One-shot
|
|
276
|
-
|
|
275
|
+
# One-shot backtest of a past news window — no monitor persists.
|
|
276
|
+
backtest = exa.beta.agent.monitors.backtests.create_and_wait(
|
|
277
277
|
betas=betas,
|
|
278
278
|
entities=[{"name": "Acme Corp", "domain": "acme.com"}],
|
|
279
|
-
fields=[{"name": "funding", "description": "New funding rounds"}],
|
|
280
|
-
|
|
281
|
-
|
|
279
|
+
fields=[{"name": "funding", "description": "New funding rounds"}],
|
|
280
|
+
start_time="2026-01-01T00:00:00Z",
|
|
281
|
+
end_time="2026-01-08T00:00:00Z",
|
|
282
282
|
)
|
|
283
|
-
print(
|
|
283
|
+
print(backtest.data)
|
|
284
284
|
|
|
285
285
|
# Add entities, inspect refresh progress, clean up.
|
|
286
286
|
exa.beta.agent.monitors.entities.add(
|
|
@@ -34,18 +34,19 @@ from .monitors import (
|
|
|
34
34
|
AgentMonitorFieldType,
|
|
35
35
|
AgentMonitorFieldValueType,
|
|
36
36
|
AgentMonitorRefresh,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
AgentMonitorBacktest,
|
|
38
|
+
AgentMonitorBacktestContent,
|
|
39
|
+
AgentMonitorBacktestEntity,
|
|
40
|
+
AgentMonitorBacktestFailedEntity,
|
|
41
|
+
AgentMonitorBacktestFailedError,
|
|
42
|
+
AgentMonitorBacktestsClient,
|
|
43
|
+
AgentMonitorBacktestStatus,
|
|
43
44
|
AgentMonitorStatus,
|
|
44
45
|
AgentMonitorsClient,
|
|
45
46
|
AgentMonitorUsage,
|
|
46
47
|
AsyncAgentMonitorChangesClient,
|
|
47
48
|
AsyncAgentMonitorEntitiesClient,
|
|
48
|
-
|
|
49
|
+
AsyncAgentMonitorBacktestsClient,
|
|
49
50
|
AsyncAgentMonitorsClient,
|
|
50
51
|
DeletedAgentMonitor,
|
|
51
52
|
ListAgentMonitorChangesResponse,
|
|
@@ -131,18 +132,19 @@ __all__ = [
|
|
|
131
132
|
"AgentMonitorFieldType",
|
|
132
133
|
"AgentMonitorFieldValueType",
|
|
133
134
|
"AgentMonitorRefresh",
|
|
134
|
-
"
|
|
135
|
-
"
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
135
|
+
"AgentMonitorBacktest",
|
|
136
|
+
"AgentMonitorBacktestContent",
|
|
137
|
+
"AgentMonitorBacktestEntity",
|
|
138
|
+
"AgentMonitorBacktestFailedEntity",
|
|
139
|
+
"AgentMonitorBacktestFailedError",
|
|
140
|
+
"AgentMonitorBacktestsClient",
|
|
141
|
+
"AgentMonitorBacktestStatus",
|
|
140
142
|
"AgentMonitorStatus",
|
|
141
143
|
"AgentMonitorsClient",
|
|
142
144
|
"AgentMonitorUsage",
|
|
143
145
|
"AsyncAgentMonitorChangesClient",
|
|
144
146
|
"AsyncAgentMonitorEntitiesClient",
|
|
145
|
-
"
|
|
147
|
+
"AsyncAgentMonitorBacktestsClient",
|
|
146
148
|
"AsyncAgentMonitorsClient",
|
|
147
149
|
"DeletedAgentMonitor",
|
|
148
150
|
"ListAgentMonitorChangesResponse",
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
from .client import (
|
|
4
4
|
AgentMonitorChangesClient,
|
|
5
5
|
AgentMonitorEntitiesClient,
|
|
6
|
-
|
|
6
|
+
AgentMonitorBacktestsClient,
|
|
7
7
|
AgentMonitorsClient,
|
|
8
8
|
)
|
|
9
9
|
from .async_client import (
|
|
10
10
|
AsyncAgentMonitorChangesClient,
|
|
11
11
|
AsyncAgentMonitorEntitiesClient,
|
|
12
|
-
|
|
12
|
+
AsyncAgentMonitorBacktestsClient,
|
|
13
13
|
AsyncAgentMonitorsClient,
|
|
14
14
|
)
|
|
15
15
|
from .types import (
|
|
@@ -30,11 +30,12 @@ from .types import (
|
|
|
30
30
|
AgentMonitorFieldType,
|
|
31
31
|
AgentMonitorFieldValueType,
|
|
32
32
|
AgentMonitorRefresh,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
AgentMonitorBacktest,
|
|
34
|
+
AgentMonitorBacktestContent,
|
|
35
|
+
AgentMonitorBacktestEntity,
|
|
36
|
+
AgentMonitorBacktestFailedEntity,
|
|
37
|
+
AgentMonitorBacktestFailedError,
|
|
38
|
+
AgentMonitorBacktestStatus,
|
|
38
39
|
AgentMonitorStatus,
|
|
39
40
|
AgentMonitorUsage,
|
|
40
41
|
DeletedAgentMonitor,
|
|
@@ -48,11 +49,11 @@ __all__ = [
|
|
|
48
49
|
"AgentMonitorsClient",
|
|
49
50
|
"AgentMonitorEntitiesClient",
|
|
50
51
|
"AgentMonitorChangesClient",
|
|
51
|
-
"
|
|
52
|
+
"AgentMonitorBacktestsClient",
|
|
52
53
|
"AsyncAgentMonitorsClient",
|
|
53
54
|
"AsyncAgentMonitorEntitiesClient",
|
|
54
55
|
"AsyncAgentMonitorChangesClient",
|
|
55
|
-
"
|
|
56
|
+
"AsyncAgentMonitorBacktestsClient",
|
|
56
57
|
"AgentMonitor",
|
|
57
58
|
"AgentMonitorChange",
|
|
58
59
|
"AgentMonitorChangeEntity",
|
|
@@ -69,11 +70,12 @@ __all__ = [
|
|
|
69
70
|
"AgentMonitorFieldType",
|
|
70
71
|
"AgentMonitorFieldValueType",
|
|
71
72
|
"AgentMonitorRefresh",
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
73
|
+
"AgentMonitorBacktest",
|
|
74
|
+
"AgentMonitorBacktestContent",
|
|
75
|
+
"AgentMonitorBacktestEntity",
|
|
76
|
+
"AgentMonitorBacktestFailedEntity",
|
|
77
|
+
"AgentMonitorBacktestFailedError",
|
|
78
|
+
"AgentMonitorBacktestStatus",
|
|
77
79
|
"AgentMonitorStatus",
|
|
78
80
|
"AgentMonitorUsage",
|
|
79
81
|
"DeletedAgentMonitor",
|
|
@@ -10,7 +10,7 @@ from .async_base import AsyncAgentMonitorsBaseClient
|
|
|
10
10
|
from .client import (
|
|
11
11
|
EntityInput,
|
|
12
12
|
FieldInput,
|
|
13
|
-
|
|
13
|
+
_ensure_completed_backtest,
|
|
14
14
|
_serialize_entities,
|
|
15
15
|
_serialize_fields,
|
|
16
16
|
)
|
|
@@ -18,15 +18,15 @@ from .types import (
|
|
|
18
18
|
AgentMonitor,
|
|
19
19
|
AgentMonitorChange,
|
|
20
20
|
AgentMonitorEntityView,
|
|
21
|
-
|
|
21
|
+
AgentMonitorBacktest,
|
|
22
22
|
DeletedAgentMonitor,
|
|
23
23
|
ListAgentMonitorChangesResponse,
|
|
24
24
|
ListAgentMonitorEntitiesResponse,
|
|
25
25
|
ListAgentMonitorsResponse,
|
|
26
26
|
)
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
_DEFAULT_BACKTEST_POLL_INTERVAL_MS = 2000
|
|
29
|
+
_DEFAULT_BACKTEST_POLL_TIMEOUT_MS = 3600000
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
class AsyncAgentMonitorEntitiesClient(AsyncAgentMonitorsBaseClient):
|
|
@@ -327,8 +327,8 @@ class AsyncAgentMonitorChangesClient(AsyncAgentMonitorsBaseClient):
|
|
|
327
327
|
]
|
|
328
328
|
|
|
329
329
|
|
|
330
|
-
class
|
|
331
|
-
"""Asynchronous client for
|
|
330
|
+
class AsyncAgentMonitorBacktestsClient(AsyncAgentMonitorsBaseClient):
|
|
331
|
+
"""Asynchronous client for one-shot Agent Monitor backtest jobs."""
|
|
332
332
|
|
|
333
333
|
async def create(
|
|
334
334
|
self,
|
|
@@ -336,32 +336,23 @@ class AsyncAgentMonitorSnapshotsClient(AsyncAgentMonitorsBaseClient):
|
|
|
336
336
|
betas: Sequence[str],
|
|
337
337
|
entities: Sequence[EntityInput],
|
|
338
338
|
fields: Sequence[FieldInput],
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
) -> AgentMonitorSnapshot:
|
|
344
|
-
"""Start an async, stateless snapshot of entities x fields over a past news window.
|
|
339
|
+
start_time: str,
|
|
340
|
+
end_time: str,
|
|
341
|
+
) -> AgentMonitorBacktest:
|
|
342
|
+
"""Start an async backtest of entities x fields over a past news window.
|
|
345
343
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
result carries a warning when static fields are included.
|
|
344
|
+
The backtest runs one ordinary monitor refresh over the requested
|
|
345
|
+
window, then tears down its temporary monitor.
|
|
349
346
|
|
|
350
347
|
Args:
|
|
351
348
|
betas: Beta feature identifiers to enable for this request.
|
|
352
|
-
entities: Entities to
|
|
353
|
-
fields: Fields to populate
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
start_date: Start of the news window, `YYYY-MM-DD` (UTC).
|
|
357
|
-
end_date: End of the news window, `YYYY-MM-DD` (UTC).
|
|
358
|
-
start_hour: Hour of start_date the window starts at, 0-23 UTC;
|
|
359
|
-
omitted means midnight.
|
|
360
|
-
end_hour: Hour of end_date the window ends at, 0-23 UTC; omitted
|
|
361
|
-
means midnight.
|
|
349
|
+
entities: Entities to backtest, each with a name and a unique domain.
|
|
350
|
+
fields: Fields to populate from news over the window.
|
|
351
|
+
start_time: Start of the news window as an ISO-8601 UTC timestamp.
|
|
352
|
+
end_time: End of the news window as an ISO-8601 UTC timestamp.
|
|
362
353
|
|
|
363
354
|
Returns:
|
|
364
|
-
The running
|
|
355
|
+
The running backtest job; poll it with `get` or use `create_and_wait`.
|
|
365
356
|
|
|
366
357
|
Examples:
|
|
367
358
|
from exa_py import AsyncExa
|
|
@@ -369,49 +360,44 @@ class AsyncAgentMonitorSnapshotsClient(AsyncAgentMonitorsBaseClient):
|
|
|
369
360
|
|
|
370
361
|
exa = AsyncExa("EXA_API_KEY")
|
|
371
362
|
|
|
372
|
-
|
|
363
|
+
backtest = await exa.beta.agent.monitors.backtests.create(
|
|
373
364
|
betas=[AGENT_MONITORS_BETA_HEADER],
|
|
374
365
|
entities=[{"name": "Acme Corp", "domain": "acme.com"}],
|
|
375
366
|
fields=[
|
|
376
367
|
{
|
|
377
368
|
"name": "funding",
|
|
378
369
|
"description": "New funding rounds",
|
|
379
|
-
"mode": "dynamic",
|
|
380
370
|
}
|
|
381
371
|
],
|
|
382
|
-
|
|
383
|
-
|
|
372
|
+
start_time="2026-01-01T00:00:00Z",
|
|
373
|
+
end_time="2026-01-08T00:00:00Z",
|
|
384
374
|
)
|
|
385
|
-
print(
|
|
375
|
+
print(backtest.id, backtest.status)
|
|
386
376
|
"""
|
|
387
377
|
payload: Dict[str, Any] = {
|
|
388
378
|
"entities": _serialize_entities(entities),
|
|
389
379
|
"fields": _serialize_fields(fields),
|
|
390
|
-
"
|
|
391
|
-
"
|
|
380
|
+
"startTime": start_time,
|
|
381
|
+
"endTime": end_time,
|
|
392
382
|
}
|
|
393
|
-
if start_hour is not None:
|
|
394
|
-
payload["startHour"] = start_hour
|
|
395
|
-
if end_hour is not None:
|
|
396
|
-
payload["endHour"] = end_hour
|
|
397
383
|
response = await self.request(
|
|
398
|
-
"/
|
|
384
|
+
"/backtest", betas=betas, method="POST", data=payload
|
|
399
385
|
)
|
|
400
|
-
return
|
|
386
|
+
return AgentMonitorBacktest.model_validate(response)
|
|
401
387
|
|
|
402
388
|
async def get(
|
|
403
|
-
self,
|
|
404
|
-
) ->
|
|
405
|
-
"""Poll a
|
|
389
|
+
self, backtest_id: str, *, betas: Sequence[str]
|
|
390
|
+
) -> AgentMonitorBacktest:
|
|
391
|
+
"""Poll a backtest job for its status and, once completed, its result.
|
|
406
392
|
|
|
407
393
|
Jobs expire and read as 404 after `expires_at`.
|
|
408
394
|
|
|
409
395
|
Args:
|
|
410
396
|
betas: Beta feature identifiers to enable for this request.
|
|
411
|
-
|
|
397
|
+
backtest_id: The ID of the backtest job.
|
|
412
398
|
|
|
413
399
|
Returns:
|
|
414
|
-
The
|
|
400
|
+
The backtest job, with result data once completed.
|
|
415
401
|
|
|
416
402
|
Examples:
|
|
417
403
|
from exa_py import AsyncExa
|
|
@@ -419,32 +405,32 @@ class AsyncAgentMonitorSnapshotsClient(AsyncAgentMonitorsBaseClient):
|
|
|
419
405
|
|
|
420
406
|
exa = AsyncExa("EXA_API_KEY")
|
|
421
407
|
|
|
422
|
-
|
|
423
|
-
print(
|
|
408
|
+
backtest = await exa.beta.agent.monitors.backtests.get("agentbacktest_123", betas=[AGENT_MONITORS_BETA_HEADER])
|
|
409
|
+
print(backtest.status)
|
|
424
410
|
"""
|
|
425
411
|
response = await self.request(
|
|
426
|
-
f"/
|
|
412
|
+
f"/backtest/{backtest_id}", betas=betas, method="GET"
|
|
427
413
|
)
|
|
428
|
-
return
|
|
414
|
+
return AgentMonitorBacktest.model_validate(response)
|
|
429
415
|
|
|
430
416
|
async def poll_until_finished(
|
|
431
417
|
self,
|
|
432
|
-
|
|
418
|
+
backtest_id: str,
|
|
433
419
|
*,
|
|
434
420
|
betas: Sequence[str],
|
|
435
|
-
poll_interval: int =
|
|
436
|
-
timeout_ms: int =
|
|
437
|
-
) ->
|
|
438
|
-
"""Poll a
|
|
421
|
+
poll_interval: int = _DEFAULT_BACKTEST_POLL_INTERVAL_MS,
|
|
422
|
+
timeout_ms: int = _DEFAULT_BACKTEST_POLL_TIMEOUT_MS,
|
|
423
|
+
) -> AgentMonitorBacktest:
|
|
424
|
+
"""Poll a backtest job until it reaches a terminal status.
|
|
439
425
|
|
|
440
426
|
Args:
|
|
441
427
|
betas: Beta feature identifiers to enable for this request.
|
|
442
|
-
|
|
428
|
+
backtest_id: The ID of the backtest job.
|
|
443
429
|
poll_interval: Delay between polls in milliseconds.
|
|
444
430
|
timeout_ms: Maximum time to wait in milliseconds.
|
|
445
431
|
|
|
446
432
|
Returns:
|
|
447
|
-
The terminal
|
|
433
|
+
The terminal backtest job (completed or failed).
|
|
448
434
|
|
|
449
435
|
Examples:
|
|
450
436
|
from exa_py import AsyncExa
|
|
@@ -452,22 +438,22 @@ class AsyncAgentMonitorSnapshotsClient(AsyncAgentMonitorsBaseClient):
|
|
|
452
438
|
|
|
453
439
|
exa = AsyncExa("EXA_API_KEY")
|
|
454
440
|
|
|
455
|
-
|
|
456
|
-
"
|
|
441
|
+
backtest = await exa.beta.agent.monitors.backtests.poll_until_finished(
|
|
442
|
+
"agentbacktest_123", betas=[AGENT_MONITORS_BETA_HEADER]
|
|
457
443
|
)
|
|
458
|
-
print(
|
|
444
|
+
print(backtest.status)
|
|
459
445
|
"""
|
|
460
446
|
start_time = time.monotonic()
|
|
461
447
|
poll_interval_sec = poll_interval / 1000
|
|
462
448
|
|
|
463
449
|
while True:
|
|
464
|
-
|
|
465
|
-
if
|
|
466
|
-
return
|
|
450
|
+
backtest = await self.get(backtest_id, betas=betas)
|
|
451
|
+
if backtest.status != "running":
|
|
452
|
+
return backtest
|
|
467
453
|
|
|
468
454
|
if (time.monotonic() - start_time) * 1000 > timeout_ms:
|
|
469
455
|
raise TimeoutError(
|
|
470
|
-
f"Agent monitor
|
|
456
|
+
f"Agent monitor backtest {backtest_id} did not complete within {timeout_ms}ms"
|
|
471
457
|
)
|
|
472
458
|
|
|
473
459
|
await asyncio.sleep(poll_interval_sec)
|
|
@@ -478,35 +464,27 @@ class AsyncAgentMonitorSnapshotsClient(AsyncAgentMonitorsBaseClient):
|
|
|
478
464
|
betas: Sequence[str],
|
|
479
465
|
entities: Sequence[EntityInput],
|
|
480
466
|
fields: Sequence[FieldInput],
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
) -> AgentMonitorSnapshot:
|
|
488
|
-
"""Start a snapshot and wait for its result.
|
|
467
|
+
start_time: str,
|
|
468
|
+
end_time: str,
|
|
469
|
+
poll_interval: int = _DEFAULT_BACKTEST_POLL_INTERVAL_MS,
|
|
470
|
+
timeout_ms: int = _DEFAULT_BACKTEST_POLL_TIMEOUT_MS,
|
|
471
|
+
) -> AgentMonitorBacktest:
|
|
472
|
+
"""Start a backtest and wait for its result.
|
|
489
473
|
|
|
490
474
|
Args:
|
|
491
475
|
betas: Beta feature identifiers to enable for this request.
|
|
492
|
-
entities: Entities to
|
|
493
|
-
fields: Fields to populate
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
start_date: Start of the news window, `YYYY-MM-DD` (UTC).
|
|
497
|
-
end_date: End of the news window, `YYYY-MM-DD` (UTC).
|
|
498
|
-
start_hour: Hour of start_date the window starts at, 0-23 UTC;
|
|
499
|
-
omitted means midnight.
|
|
500
|
-
end_hour: Hour of end_date the window ends at, 0-23 UTC; omitted
|
|
501
|
-
means midnight.
|
|
476
|
+
entities: Entities to backtest, each with a name and a unique domain.
|
|
477
|
+
fields: Fields to populate from news over the window.
|
|
478
|
+
start_time: Start of the news window as an ISO-8601 UTC timestamp.
|
|
479
|
+
end_time: End of the news window as an ISO-8601 UTC timestamp.
|
|
502
480
|
poll_interval: Delay between polls in milliseconds.
|
|
503
481
|
timeout_ms: Maximum time to wait in milliseconds.
|
|
504
482
|
|
|
505
483
|
Returns:
|
|
506
|
-
The completed
|
|
484
|
+
The completed backtest job.
|
|
507
485
|
|
|
508
486
|
Raises:
|
|
509
|
-
|
|
487
|
+
AgentMonitorBacktestFailedError: If the backtest job fails.
|
|
510
488
|
|
|
511
489
|
Examples:
|
|
512
490
|
from exa_py import AsyncExa
|
|
@@ -514,38 +492,35 @@ class AsyncAgentMonitorSnapshotsClient(AsyncAgentMonitorsBaseClient):
|
|
|
514
492
|
|
|
515
493
|
exa = AsyncExa("EXA_API_KEY")
|
|
516
494
|
|
|
517
|
-
|
|
495
|
+
backtest = await exa.beta.agent.monitors.backtests.create_and_wait(
|
|
518
496
|
betas=[AGENT_MONITORS_BETA_HEADER],
|
|
519
497
|
entities=[{"name": "Acme Corp", "domain": "acme.com"}],
|
|
520
498
|
fields=[
|
|
521
499
|
{
|
|
522
500
|
"name": "funding",
|
|
523
501
|
"description": "New funding rounds",
|
|
524
|
-
"mode": "dynamic",
|
|
525
502
|
}
|
|
526
503
|
],
|
|
527
|
-
|
|
528
|
-
|
|
504
|
+
start_time="2026-01-01T00:00:00Z",
|
|
505
|
+
end_time="2026-01-08T00:00:00Z",
|
|
529
506
|
)
|
|
530
|
-
print(
|
|
507
|
+
print(backtest.data)
|
|
531
508
|
"""
|
|
532
|
-
|
|
509
|
+
backtest = await self.create(
|
|
533
510
|
betas=betas,
|
|
534
511
|
entities=entities,
|
|
535
512
|
fields=fields,
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
start_hour=start_hour,
|
|
539
|
-
end_hour=end_hour,
|
|
513
|
+
start_time=start_time,
|
|
514
|
+
end_time=end_time,
|
|
540
515
|
)
|
|
541
|
-
if
|
|
542
|
-
|
|
543
|
-
|
|
516
|
+
if backtest.status == "running":
|
|
517
|
+
backtest = await self.poll_until_finished(
|
|
518
|
+
backtest.id,
|
|
544
519
|
betas=betas,
|
|
545
520
|
poll_interval=poll_interval,
|
|
546
521
|
timeout_ms=timeout_ms,
|
|
547
522
|
)
|
|
548
|
-
return
|
|
523
|
+
return _ensure_completed_backtest(backtest)
|
|
549
524
|
|
|
550
525
|
|
|
551
526
|
class AsyncAgentMonitorsClient(AsyncAgentMonitorsBaseClient):
|
|
@@ -553,13 +528,13 @@ class AsyncAgentMonitorsClient(AsyncAgentMonitorsBaseClient):
|
|
|
553
528
|
|
|
554
529
|
entities: AsyncAgentMonitorEntitiesClient
|
|
555
530
|
changes: AsyncAgentMonitorChangesClient
|
|
556
|
-
|
|
531
|
+
backtests: AsyncAgentMonitorBacktestsClient
|
|
557
532
|
|
|
558
533
|
def __init__(self, client: Any):
|
|
559
534
|
super().__init__(client)
|
|
560
535
|
self.entities = AsyncAgentMonitorEntitiesClient(client)
|
|
561
536
|
self.changes = AsyncAgentMonitorChangesClient(client)
|
|
562
|
-
self.
|
|
537
|
+
self.backtests = AsyncAgentMonitorBacktestsClient(client)
|
|
563
538
|
|
|
564
539
|
async def create(
|
|
565
540
|
self,
|