parallel-web-tools 0.7.1rc2__tar.gz → 0.8.1__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.
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/PKG-INFO +85 -10
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/README.md +83 -8
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/__init__.py +16 -1
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/cli/commands.py +242 -2
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/__init__.py +23 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/findall.py +13 -0
- parallel_web_tools-0.8.1/parallel_web_tools/core/memory.py +159 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/monitor.py +7 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/research.py +13 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/bigquery/cloud_function/requirements.txt +1 -1
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/pyproject.toml +2 -2
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/.gitignore +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/cli/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/cli/planner.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/cli/skills.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/cli/updater.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/auth.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/batch.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/credentials.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/endpoints.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/polling.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/result.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/runner.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/schema.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/service.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/service_types.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/skills.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/sql_utils.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/user_agent.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/bigquery/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/bigquery/cloud_function/main.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/bigquery/deploy.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/bigquery/sql/create_functions.sql +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/duckdb/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/duckdb/batch.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/duckdb/findall.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/duckdb/udf.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/polars/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/polars/enrich.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/snowflake/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/snowflake/deploy.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/snowflake/sql/01_setup.sql +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/snowflake/sql/02_create_udf.sql +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/snowflake/sql/03_cleanup.sql +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/spark/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/spark/streaming.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/spark/udf.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/utils.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/__init__.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/bigquery.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/csv.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/duckdb.py +0 -0
- {parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/json.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: parallel-web-tools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.8.1
|
|
4
4
|
Summary: Parallel Tools: CLI and Python SDK for AI-powered web intelligence
|
|
5
5
|
Project-URL: Homepage, https://github.com/parallel-web/parallel-web-tools
|
|
6
6
|
Project-URL: Documentation, https://docs.parallel.ai
|
|
@@ -24,7 +24,7 @@ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
|
24
24
|
Requires-Python: >=3.10
|
|
25
25
|
Requires-Dist: click>=8.1.0
|
|
26
26
|
Requires-Dist: httpx>=0.25.0
|
|
27
|
-
Requires-Dist: parallel-web<2,>=1.
|
|
27
|
+
Requires-Dist: parallel-web<2,>=1.2.0
|
|
28
28
|
Requires-Dist: python-dotenv>=1.0.0
|
|
29
29
|
Requires-Dist: rich>=13.0.0
|
|
30
30
|
Provides-Extra: all
|
|
@@ -100,6 +100,7 @@ CLI and data enrichment utilities for the [Parallel API](https://docs.parallel.a
|
|
|
100
100
|
- **Content Extraction** - Extract clean markdown from any URL
|
|
101
101
|
- **Data Enrichment** - Enrich CSV, JSON, DuckDB, and BigQuery data with AI
|
|
102
102
|
- **Follow-up Context** - Chain research and enrichment tasks using `--previous-interaction-id`
|
|
103
|
+
- **Research Memory** - Recall, scope, evict, or clear saved Task, Monitor, and FindAll work
|
|
103
104
|
- **AI-Assisted Planning** - Use natural language to define what data you want
|
|
104
105
|
- **Multiple Integrations** - Polars, DuckDB, Snowflake, BigQuery, Spark
|
|
105
106
|
|
|
@@ -183,14 +184,18 @@ parallel-cli
|
|
|
183
184
|
│ ├── extend # Request additional candidates for a run
|
|
184
185
|
│ ├── schema # Get the schema for a FindAll run
|
|
185
186
|
│ └── cancel # Cancel a running FindAll
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
├── monitor # Continuous web change tracking
|
|
188
|
+
│ ├── create # Create a new web monitor (event_stream or snapshot)
|
|
189
|
+
│ ├── list # List monitors (cursor paginated)
|
|
190
|
+
│ ├── get # Get monitor details
|
|
191
|
+
│ ├── update # Update frequency, webhook, metadata
|
|
192
|
+
│ ├── cancel # Cancel a monitor (irreversible)
|
|
193
|
+
│ ├── events # List events for a monitor
|
|
194
|
+
│ └── trigger # Trigger an immediate one-off run
|
|
195
|
+
└── memory # Saved Task, Monitor, and FindAll entries
|
|
196
|
+
├── retrieve # Search Memory or list recent entries
|
|
197
|
+
├── evict # Remove one entry from Memory
|
|
198
|
+
└── clear # Permanently clear selected Memory
|
|
194
199
|
```
|
|
195
200
|
|
|
196
201
|
## Quick Start
|
|
@@ -275,6 +280,43 @@ parallel-cli enrich run \
|
|
|
275
280
|
parallel-cli enrich deploy --system bigquery --project my-gcp-project
|
|
276
281
|
```
|
|
277
282
|
|
|
283
|
+
### 6. Recall Memory Entries
|
|
284
|
+
|
|
285
|
+
Memory is an explicit recall layer for completed Task, Monitor, and FindAll work.
|
|
286
|
+
Saving is asynchronous, so a newly completed run may take a short time to appear.
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# Retrieve prior work by relevance
|
|
290
|
+
parallel-cli memory retrieve --query "serverless inference vendors" --json
|
|
291
|
+
|
|
292
|
+
# List the most recent saved work
|
|
293
|
+
parallel-cli memory retrieve --query "" --json
|
|
294
|
+
|
|
295
|
+
# Keep application or workspace research in an isolated memory scope
|
|
296
|
+
parallel-cli research run "Compare inference vendors" \
|
|
297
|
+
--memory-scope-key workspace_acme
|
|
298
|
+
parallel-cli findall run "Serverless inference vendors" \
|
|
299
|
+
--memory-scope-key workspace_acme
|
|
300
|
+
parallel-cli monitor create "Track vendor pricing changes" \
|
|
301
|
+
--memory-scope-key workspace_acme
|
|
302
|
+
|
|
303
|
+
# Retrieve from the same memory scope
|
|
304
|
+
parallel-cli memory retrieve \
|
|
305
|
+
--query "inference vendors" \
|
|
306
|
+
--scope-key workspace_acme \
|
|
307
|
+
--json
|
|
308
|
+
|
|
309
|
+
# Remove one Memory entry without deleting the Task itself
|
|
310
|
+
parallel-cli memory evict --kind task --id trun_abc123 --json
|
|
311
|
+
|
|
312
|
+
# Permanently clear a specific memory scope (underlying resources remain)
|
|
313
|
+
parallel-cli memory clear --scope-key workspace_acme --confirm-clear --json
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Omit `--scope-key` / `--memory-scope-key` to use personal Memory when the
|
|
317
|
+
credential and account are eligible. Application credentials require a stable
|
|
318
|
+
scope key containing only letters, digits, underscores, or hyphens.
|
|
319
|
+
|
|
278
320
|
## Non-Interactive Mode (for AI Agents & Scripts)
|
|
279
321
|
|
|
280
322
|
All commands support `--json` output and can be fully controlled via CLI arguments.
|
|
@@ -348,6 +390,9 @@ parallel-cli findall entity-search "AI startups in healthcare" -t companies -n 2
|
|
|
348
390
|
# Monitor: track web changes
|
|
349
391
|
parallel-cli monitor create "Track Tesla SEC filings" --frequency 1d --json
|
|
350
392
|
|
|
393
|
+
# Recall prior Memory entries
|
|
394
|
+
parallel-cli memory retrieve --query "Tesla filings" --json
|
|
395
|
+
|
|
351
396
|
# Plan without prompts (provide all args)
|
|
352
397
|
parallel-cli enrich plan -o config.yaml \
|
|
353
398
|
--source-type csv \
|
|
@@ -495,6 +540,36 @@ monitors = list_monitors()
|
|
|
495
540
|
details = get_monitor(monitor["monitor_id"])
|
|
496
541
|
```
|
|
497
542
|
|
|
543
|
+
### Memory
|
|
544
|
+
|
|
545
|
+
Retrieve and manage Memory entries:
|
|
546
|
+
|
|
547
|
+
```python
|
|
548
|
+
from parallel_web_tools import clear_memory, evict_memory, retrieve_memory
|
|
549
|
+
|
|
550
|
+
# Relevant prior work across Task, Monitor, and FindAll
|
|
551
|
+
memories = retrieve_memory("serverless inference vendors", limit=10)
|
|
552
|
+
|
|
553
|
+
# Retrieve from an isolated memory scope
|
|
554
|
+
scoped = retrieve_memory(
|
|
555
|
+
"inference vendors",
|
|
556
|
+
memory_scope_key="workspace_acme",
|
|
557
|
+
)
|
|
558
|
+
|
|
559
|
+
# Remove one run from Memory; the underlying Task run remains available
|
|
560
|
+
evict_memory(
|
|
561
|
+
"task",
|
|
562
|
+
"trun_abc123",
|
|
563
|
+
memory_scope_key="workspace_acme",
|
|
564
|
+
)
|
|
565
|
+
|
|
566
|
+
# Clear the selected memory; underlying runs remain available
|
|
567
|
+
clear_memory(memory_scope_key="workspace_acme")
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
These functions use the generated `client.beta.memory` resource provided by
|
|
571
|
+
`parallel-web` 1.2.0 or later.
|
|
572
|
+
|
|
498
573
|
## YAML Configuration Format
|
|
499
574
|
|
|
500
575
|
```yaml
|
|
@@ -14,6 +14,7 @@ CLI and data enrichment utilities for the [Parallel API](https://docs.parallel.a
|
|
|
14
14
|
- **Content Extraction** - Extract clean markdown from any URL
|
|
15
15
|
- **Data Enrichment** - Enrich CSV, JSON, DuckDB, and BigQuery data with AI
|
|
16
16
|
- **Follow-up Context** - Chain research and enrichment tasks using `--previous-interaction-id`
|
|
17
|
+
- **Research Memory** - Recall, scope, evict, or clear saved Task, Monitor, and FindAll work
|
|
17
18
|
- **AI-Assisted Planning** - Use natural language to define what data you want
|
|
18
19
|
- **Multiple Integrations** - Polars, DuckDB, Snowflake, BigQuery, Spark
|
|
19
20
|
|
|
@@ -97,14 +98,18 @@ parallel-cli
|
|
|
97
98
|
│ ├── extend # Request additional candidates for a run
|
|
98
99
|
│ ├── schema # Get the schema for a FindAll run
|
|
99
100
|
│ └── cancel # Cancel a running FindAll
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
101
|
+
├── monitor # Continuous web change tracking
|
|
102
|
+
│ ├── create # Create a new web monitor (event_stream or snapshot)
|
|
103
|
+
│ ├── list # List monitors (cursor paginated)
|
|
104
|
+
│ ├── get # Get monitor details
|
|
105
|
+
│ ├── update # Update frequency, webhook, metadata
|
|
106
|
+
│ ├── cancel # Cancel a monitor (irreversible)
|
|
107
|
+
│ ├── events # List events for a monitor
|
|
108
|
+
│ └── trigger # Trigger an immediate one-off run
|
|
109
|
+
└── memory # Saved Task, Monitor, and FindAll entries
|
|
110
|
+
├── retrieve # Search Memory or list recent entries
|
|
111
|
+
├── evict # Remove one entry from Memory
|
|
112
|
+
└── clear # Permanently clear selected Memory
|
|
108
113
|
```
|
|
109
114
|
|
|
110
115
|
## Quick Start
|
|
@@ -189,6 +194,43 @@ parallel-cli enrich run \
|
|
|
189
194
|
parallel-cli enrich deploy --system bigquery --project my-gcp-project
|
|
190
195
|
```
|
|
191
196
|
|
|
197
|
+
### 6. Recall Memory Entries
|
|
198
|
+
|
|
199
|
+
Memory is an explicit recall layer for completed Task, Monitor, and FindAll work.
|
|
200
|
+
Saving is asynchronous, so a newly completed run may take a short time to appear.
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
# Retrieve prior work by relevance
|
|
204
|
+
parallel-cli memory retrieve --query "serverless inference vendors" --json
|
|
205
|
+
|
|
206
|
+
# List the most recent saved work
|
|
207
|
+
parallel-cli memory retrieve --query "" --json
|
|
208
|
+
|
|
209
|
+
# Keep application or workspace research in an isolated memory scope
|
|
210
|
+
parallel-cli research run "Compare inference vendors" \
|
|
211
|
+
--memory-scope-key workspace_acme
|
|
212
|
+
parallel-cli findall run "Serverless inference vendors" \
|
|
213
|
+
--memory-scope-key workspace_acme
|
|
214
|
+
parallel-cli monitor create "Track vendor pricing changes" \
|
|
215
|
+
--memory-scope-key workspace_acme
|
|
216
|
+
|
|
217
|
+
# Retrieve from the same memory scope
|
|
218
|
+
parallel-cli memory retrieve \
|
|
219
|
+
--query "inference vendors" \
|
|
220
|
+
--scope-key workspace_acme \
|
|
221
|
+
--json
|
|
222
|
+
|
|
223
|
+
# Remove one Memory entry without deleting the Task itself
|
|
224
|
+
parallel-cli memory evict --kind task --id trun_abc123 --json
|
|
225
|
+
|
|
226
|
+
# Permanently clear a specific memory scope (underlying resources remain)
|
|
227
|
+
parallel-cli memory clear --scope-key workspace_acme --confirm-clear --json
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Omit `--scope-key` / `--memory-scope-key` to use personal Memory when the
|
|
231
|
+
credential and account are eligible. Application credentials require a stable
|
|
232
|
+
scope key containing only letters, digits, underscores, or hyphens.
|
|
233
|
+
|
|
192
234
|
## Non-Interactive Mode (for AI Agents & Scripts)
|
|
193
235
|
|
|
194
236
|
All commands support `--json` output and can be fully controlled via CLI arguments.
|
|
@@ -262,6 +304,9 @@ parallel-cli findall entity-search "AI startups in healthcare" -t companies -n 2
|
|
|
262
304
|
# Monitor: track web changes
|
|
263
305
|
parallel-cli monitor create "Track Tesla SEC filings" --frequency 1d --json
|
|
264
306
|
|
|
307
|
+
# Recall prior Memory entries
|
|
308
|
+
parallel-cli memory retrieve --query "Tesla filings" --json
|
|
309
|
+
|
|
265
310
|
# Plan without prompts (provide all args)
|
|
266
311
|
parallel-cli enrich plan -o config.yaml \
|
|
267
312
|
--source-type csv \
|
|
@@ -409,6 +454,36 @@ monitors = list_monitors()
|
|
|
409
454
|
details = get_monitor(monitor["monitor_id"])
|
|
410
455
|
```
|
|
411
456
|
|
|
457
|
+
### Memory
|
|
458
|
+
|
|
459
|
+
Retrieve and manage Memory entries:
|
|
460
|
+
|
|
461
|
+
```python
|
|
462
|
+
from parallel_web_tools import clear_memory, evict_memory, retrieve_memory
|
|
463
|
+
|
|
464
|
+
# Relevant prior work across Task, Monitor, and FindAll
|
|
465
|
+
memories = retrieve_memory("serverless inference vendors", limit=10)
|
|
466
|
+
|
|
467
|
+
# Retrieve from an isolated memory scope
|
|
468
|
+
scoped = retrieve_memory(
|
|
469
|
+
"inference vendors",
|
|
470
|
+
memory_scope_key="workspace_acme",
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
# Remove one run from Memory; the underlying Task run remains available
|
|
474
|
+
evict_memory(
|
|
475
|
+
"task",
|
|
476
|
+
"trun_abc123",
|
|
477
|
+
memory_scope_key="workspace_acme",
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
# Clear the selected memory; underlying runs remain available
|
|
481
|
+
clear_memory(memory_scope_key="workspace_acme")
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
These functions use the generated `client.beta.memory` resource provided by
|
|
485
|
+
`parallel-web` 1.2.0 or later.
|
|
486
|
+
|
|
412
487
|
## YAML Configuration Format
|
|
413
488
|
|
|
414
489
|
```yaml
|
|
@@ -3,17 +3,23 @@
|
|
|
3
3
|
# Re-export everything from core for convenience
|
|
4
4
|
from parallel_web_tools.core import (
|
|
5
5
|
AVAILABLE_PROCESSORS,
|
|
6
|
+
MEMORY_KINDS,
|
|
6
7
|
Column,
|
|
7
8
|
DeviceCodeInfo,
|
|
8
9
|
InputSchema,
|
|
10
|
+
MemoryApiError,
|
|
11
|
+
MemoryInputError,
|
|
12
|
+
MemoryKind,
|
|
9
13
|
ParseError,
|
|
10
14
|
ProcessorType,
|
|
11
15
|
SourceType,
|
|
12
16
|
cancel_monitor,
|
|
17
|
+
clear_memory,
|
|
13
18
|
create_monitor,
|
|
14
19
|
enrich_batch,
|
|
15
20
|
enrich_single,
|
|
16
21
|
entity_search_findall,
|
|
22
|
+
evict_memory,
|
|
17
23
|
get_api_key,
|
|
18
24
|
get_async_client,
|
|
19
25
|
get_auth_status,
|
|
@@ -27,6 +33,7 @@ from parallel_web_tools.core import (
|
|
|
27
33
|
parse_schema,
|
|
28
34
|
poll_device_token,
|
|
29
35
|
request_device_code,
|
|
36
|
+
retrieve_memory,
|
|
30
37
|
run_enrichment,
|
|
31
38
|
run_enrichment_from_dict,
|
|
32
39
|
run_findall,
|
|
@@ -36,7 +43,7 @@ from parallel_web_tools.core import (
|
|
|
36
43
|
update_monitor,
|
|
37
44
|
)
|
|
38
45
|
|
|
39
|
-
__version__ = "0.
|
|
46
|
+
__version__ = "0.8.1"
|
|
40
47
|
|
|
41
48
|
__all__ = [
|
|
42
49
|
# Auth
|
|
@@ -62,6 +69,14 @@ __all__ = [
|
|
|
62
69
|
"enrich_batch",
|
|
63
70
|
"enrich_single",
|
|
64
71
|
"run_tasks",
|
|
72
|
+
# Memory
|
|
73
|
+
"MEMORY_KINDS",
|
|
74
|
+
"MemoryApiError",
|
|
75
|
+
"MemoryInputError",
|
|
76
|
+
"MemoryKind",
|
|
77
|
+
"clear_memory",
|
|
78
|
+
"evict_memory",
|
|
79
|
+
"retrieve_memory",
|
|
65
80
|
# Runner
|
|
66
81
|
"run_enrichment",
|
|
67
82
|
"run_enrichment_from_dict",
|
|
@@ -8,7 +8,7 @@ import sys
|
|
|
8
8
|
import tempfile
|
|
9
9
|
import time
|
|
10
10
|
from pathlib import Path
|
|
11
|
-
from typing import Any, NoReturn
|
|
11
|
+
from typing import Any, NoReturn, cast
|
|
12
12
|
|
|
13
13
|
import click
|
|
14
14
|
import httpx
|
|
@@ -21,17 +21,22 @@ from parallel_web_tools.core import (
|
|
|
21
21
|
AVAILABLE_PROCESSORS,
|
|
22
22
|
FINDALL_GENERATORS,
|
|
23
23
|
JSON_SCHEMA_TYPE_MAP,
|
|
24
|
+
MEMORY_KINDS,
|
|
24
25
|
MONITOR_PROCESSORS,
|
|
25
26
|
MONITOR_TYPES,
|
|
26
27
|
RESEARCH_PROCESSORS,
|
|
28
|
+
MemoryInputError,
|
|
29
|
+
MemoryKind,
|
|
27
30
|
ReauthenticationRequired,
|
|
28
31
|
cancel_findall_run,
|
|
29
32
|
cancel_monitor,
|
|
33
|
+
clear_memory,
|
|
30
34
|
create_findall_run,
|
|
31
35
|
create_monitor,
|
|
32
36
|
create_research_task,
|
|
33
37
|
enrich_findall,
|
|
34
38
|
entity_search_findall,
|
|
39
|
+
evict_memory,
|
|
35
40
|
extend_findall,
|
|
36
41
|
get_api_key,
|
|
37
42
|
get_auth_status,
|
|
@@ -50,11 +55,13 @@ from parallel_web_tools.core import (
|
|
|
50
55
|
poll_findall,
|
|
51
56
|
poll_research,
|
|
52
57
|
poll_task_group,
|
|
58
|
+
retrieve_memory,
|
|
53
59
|
run_enrichment_from_dict,
|
|
54
60
|
run_findall,
|
|
55
61
|
run_research,
|
|
56
62
|
trigger_monitor,
|
|
57
63
|
update_monitor,
|
|
64
|
+
validate_memory_scope_key,
|
|
58
65
|
)
|
|
59
66
|
|
|
60
67
|
# Standalone CLI (PyInstaller) has limited features to reduce bundle size
|
|
@@ -268,6 +275,23 @@ def parse_comma_separated(values: tuple[str, ...]) -> list[str]:
|
|
|
268
275
|
return result
|
|
269
276
|
|
|
270
277
|
|
|
278
|
+
class MemoryScopeKeyType(click.ParamType):
|
|
279
|
+
"""Click validator for personal/application Memory scope keys."""
|
|
280
|
+
|
|
281
|
+
name = "memory scope key"
|
|
282
|
+
|
|
283
|
+
def convert(self, value, param, ctx):
|
|
284
|
+
if value is None:
|
|
285
|
+
return None
|
|
286
|
+
try:
|
|
287
|
+
return validate_memory_scope_key(value)
|
|
288
|
+
except MemoryInputError as exc:
|
|
289
|
+
self.fail(str(exc), param, ctx)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
MEMORY_SCOPE_KEY = MemoryScopeKeyType()
|
|
293
|
+
|
|
294
|
+
|
|
271
295
|
def write_json_output(data: dict[str, Any], output_file: str | None, output_json: bool) -> None:
|
|
272
296
|
"""Write output data to file and/or stdout as JSON.
|
|
273
297
|
|
|
@@ -496,7 +520,7 @@ def _auto_update():
|
|
|
496
520
|
@click.group(cls=ParallelCLI)
|
|
497
521
|
@click.version_option(version=__version__, prog_name="parallel-cli")
|
|
498
522
|
def main():
|
|
499
|
-
"""Parallel CLI - Search, research, enrich, and
|
|
523
|
+
"""Parallel CLI - Search, research, enrich, monitor, and recall the web."""
|
|
500
524
|
pass
|
|
501
525
|
|
|
502
526
|
|
|
@@ -876,6 +900,190 @@ def config_cmd(key: str | None, value: str | None, output_json: bool):
|
|
|
876
900
|
main.add_command(create_skills_group(console, _handle_error, EXIT_BAD_INPUT, EXIT_API_ERROR))
|
|
877
901
|
|
|
878
902
|
|
|
903
|
+
# =============================================================================
|
|
904
|
+
# Memory Commands
|
|
905
|
+
# =============================================================================
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
@main.group()
|
|
909
|
+
def memory():
|
|
910
|
+
"""Search and manage saved Task, Monitor, and FindAll entries."""
|
|
911
|
+
pass
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
def _render_memory_results(result: dict[str, Any]) -> None:
|
|
915
|
+
"""Render bounded Memory previews for human-readable CLI output."""
|
|
916
|
+
results = result.get("results", [])
|
|
917
|
+
if not results:
|
|
918
|
+
console.print("[yellow]No Memory entries found.[/yellow]")
|
|
919
|
+
return
|
|
920
|
+
|
|
921
|
+
noun = "entry" if len(results) == 1 else "entries"
|
|
922
|
+
console.print(f"[bold green]Found {len(results)} {noun} in Memory.[/bold green]\n")
|
|
923
|
+
for index, item in enumerate(results, 1):
|
|
924
|
+
kind = item.get("kind", "unknown")
|
|
925
|
+
source_id = item.get("id", "unknown")
|
|
926
|
+
updated_at = item.get("updated_at", "unknown")
|
|
927
|
+
console.print(f"[bold cyan]{index}. {kind} · {source_id}[/bold cyan]")
|
|
928
|
+
console.print(f" [dim]Updated: {updated_at}[/dim]")
|
|
929
|
+
|
|
930
|
+
input_excerpt = item.get("input_excerpt")
|
|
931
|
+
if input_excerpt:
|
|
932
|
+
console.print(" [bold]Input[/bold]")
|
|
933
|
+
console.print(f" {input_excerpt}", markup=False)
|
|
934
|
+
|
|
935
|
+
if kind == "task" and item.get("output_excerpt"):
|
|
936
|
+
console.print(" [bold]Output[/bold]")
|
|
937
|
+
console.print(f" {item['output_excerpt']}", markup=False)
|
|
938
|
+
elif kind == "findall":
|
|
939
|
+
console.print(f" [bold]Matched entities:[/bold] {item.get('matched_count', 0)}")
|
|
940
|
+
elif kind == "monitor":
|
|
941
|
+
console.print(f" [bold]Status:[/bold] {item.get('status', 'unknown')}")
|
|
942
|
+
for event in item.get("matched_events", []):
|
|
943
|
+
console.print(
|
|
944
|
+
f" [dim]Event {event.get('event_id', 'unknown')} · {event.get('detected_at', 'unknown')}[/dim]"
|
|
945
|
+
)
|
|
946
|
+
if event.get("excerpt"):
|
|
947
|
+
console.print(f" {event['excerpt']}", markup=False)
|
|
948
|
+
console.print()
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
@memory.command(name="retrieve")
|
|
952
|
+
@click.argument("query_arg", required=False, metavar="[QUERY]")
|
|
953
|
+
@click.option("--query", "query_option", help="Semantic query. Omit or pass an empty string for recent memories.")
|
|
954
|
+
@click.option("--limit", type=click.IntRange(1, 25), default=10, show_default=True)
|
|
955
|
+
@click.option("--kind", type=click.Choice(list(MEMORY_KINDS)), help="Filter by entry kind.")
|
|
956
|
+
@click.option("--since", help="RFC 3339 lower timestamp bound, including a timezone.")
|
|
957
|
+
@click.option(
|
|
958
|
+
"--scope-key",
|
|
959
|
+
"--memory-scope-key",
|
|
960
|
+
"memory_scope_key",
|
|
961
|
+
type=MEMORY_SCOPE_KEY,
|
|
962
|
+
help="Optional key identifying the memory scope to use. Omit to use personal memory, if available.",
|
|
963
|
+
)
|
|
964
|
+
@click.option("-o", "--output", "output_file", type=click.Path(), help="Save results to a JSON file.")
|
|
965
|
+
@click.option("--json", "output_json", is_flag=True, help="Output JSON to stdout.")
|
|
966
|
+
def memory_retrieve(
|
|
967
|
+
query_arg: str | None,
|
|
968
|
+
query_option: str | None,
|
|
969
|
+
limit: int,
|
|
970
|
+
kind: str | None,
|
|
971
|
+
since: str | None,
|
|
972
|
+
memory_scope_key: str | None,
|
|
973
|
+
output_file: str | None,
|
|
974
|
+
output_json: bool,
|
|
975
|
+
):
|
|
976
|
+
"""Search Memory or list recent entries.
|
|
977
|
+
|
|
978
|
+
Provide QUERY to rank entries by relevance. Omit it to return the most
|
|
979
|
+
recent entries.
|
|
980
|
+
"""
|
|
981
|
+
if query_arg is not None and query_option is not None:
|
|
982
|
+
raise click.UsageError("Provide the query either as QUERY or with --query, not both.")
|
|
983
|
+
query = query_option if query_option is not None else (query_arg or "")
|
|
984
|
+
|
|
985
|
+
try:
|
|
986
|
+
result = retrieve_memory(
|
|
987
|
+
query=query,
|
|
988
|
+
limit=limit,
|
|
989
|
+
kind=cast(MemoryKind | None, kind),
|
|
990
|
+
since=since,
|
|
991
|
+
memory_scope_key=memory_scope_key,
|
|
992
|
+
source="cli",
|
|
993
|
+
)
|
|
994
|
+
except MemoryInputError as e:
|
|
995
|
+
_handle_error(e, output_json=output_json, exit_code=EXIT_BAD_INPUT, prefix="Invalid Memory request")
|
|
996
|
+
return
|
|
997
|
+
except Exception as e:
|
|
998
|
+
_handle_error(e, output_json=output_json, prefix="Memory API error")
|
|
999
|
+
return
|
|
1000
|
+
|
|
1001
|
+
write_json_output(result, output_file, output_json)
|
|
1002
|
+
if not output_json:
|
|
1003
|
+
_render_memory_results(result)
|
|
1004
|
+
|
|
1005
|
+
|
|
1006
|
+
@memory.command(name="evict")
|
|
1007
|
+
@click.option("--kind", type=click.Choice(list(MEMORY_KINDS)), required=True, help="Entry kind.")
|
|
1008
|
+
@click.option("--id", "source_id", required=True, help="Exact entry ID.")
|
|
1009
|
+
@click.option(
|
|
1010
|
+
"--scope-key",
|
|
1011
|
+
"--memory-scope-key",
|
|
1012
|
+
"memory_scope_key",
|
|
1013
|
+
type=MEMORY_SCOPE_KEY,
|
|
1014
|
+
help="Optional key identifying the memory scope to use. Omit to use personal memory, if available.",
|
|
1015
|
+
)
|
|
1016
|
+
@click.option("--json", "output_json", is_flag=True, help="Output JSON to stdout.")
|
|
1017
|
+
def memory_evict(kind: str, source_id: str, memory_scope_key: str | None, output_json: bool):
|
|
1018
|
+
"""Remove one entry from Memory.
|
|
1019
|
+
|
|
1020
|
+
The underlying Task, Monitor, or FindAll resource is not deleted.
|
|
1021
|
+
"""
|
|
1022
|
+
try:
|
|
1023
|
+
result = evict_memory(
|
|
1024
|
+
kind=cast(MemoryKind, kind),
|
|
1025
|
+
source_id=source_id,
|
|
1026
|
+
memory_scope_key=memory_scope_key,
|
|
1027
|
+
source="cli",
|
|
1028
|
+
)
|
|
1029
|
+
except MemoryInputError as e:
|
|
1030
|
+
_handle_error(e, output_json=output_json, exit_code=EXIT_BAD_INPUT, prefix="Invalid Memory request")
|
|
1031
|
+
return
|
|
1032
|
+
except Exception as e:
|
|
1033
|
+
_handle_error(e, output_json=output_json, prefix="Memory API error")
|
|
1034
|
+
return
|
|
1035
|
+
|
|
1036
|
+
if output_json:
|
|
1037
|
+
print(json.dumps(result, indent=2))
|
|
1038
|
+
return
|
|
1039
|
+
|
|
1040
|
+
memory_label = f"Memory scope {memory_scope_key!r}" if memory_scope_key else "personal Memory"
|
|
1041
|
+
console.print(f"[bold green]Removed {kind} entry {source_id} from {memory_label}.[/bold green]")
|
|
1042
|
+
console.print("[dim]The underlying Task, Monitor, or FindAll resource was not deleted.[/dim]")
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
@memory.command(name="clear")
|
|
1046
|
+
@click.option(
|
|
1047
|
+
"--scope-key",
|
|
1048
|
+
"--memory-scope-key",
|
|
1049
|
+
"memory_scope_key",
|
|
1050
|
+
type=MEMORY_SCOPE_KEY,
|
|
1051
|
+
help="Optional key identifying the memory scope to use. Omit to use personal memory, if available.",
|
|
1052
|
+
)
|
|
1053
|
+
@click.option(
|
|
1054
|
+
"--confirm-clear",
|
|
1055
|
+
is_flag=True,
|
|
1056
|
+
help="Confirm permanent clearing of the selected Memory.",
|
|
1057
|
+
)
|
|
1058
|
+
@click.option("--json", "output_json", is_flag=True, help="Output JSON to stdout.")
|
|
1059
|
+
def memory_clear(memory_scope_key: str | None, confirm_clear: bool, output_json: bool):
|
|
1060
|
+
"""Remove all entries from selected Memory.
|
|
1061
|
+
|
|
1062
|
+
The underlying Task, Monitor, and FindAll resources are not deleted.
|
|
1063
|
+
"""
|
|
1064
|
+
if not confirm_clear:
|
|
1065
|
+
error = MemoryInputError("clear requires --confirm-clear")
|
|
1066
|
+
_handle_error(error, output_json=output_json, exit_code=EXIT_BAD_INPUT, prefix="Invalid Memory request")
|
|
1067
|
+
return
|
|
1068
|
+
|
|
1069
|
+
try:
|
|
1070
|
+
result = clear_memory(memory_scope_key=memory_scope_key, source="cli")
|
|
1071
|
+
except MemoryInputError as e:
|
|
1072
|
+
_handle_error(e, output_json=output_json, exit_code=EXIT_BAD_INPUT, prefix="Invalid Memory request")
|
|
1073
|
+
return
|
|
1074
|
+
except Exception as e:
|
|
1075
|
+
_handle_error(e, output_json=output_json, prefix="Memory API error")
|
|
1076
|
+
return
|
|
1077
|
+
|
|
1078
|
+
if output_json:
|
|
1079
|
+
print(json.dumps(result, indent=2))
|
|
1080
|
+
return
|
|
1081
|
+
|
|
1082
|
+
memory_label = f"Memory scope {memory_scope_key!r}" if memory_scope_key else "personal Memory"
|
|
1083
|
+
console.print(f"[bold green]Cleared {memory_label}.[/bold green]")
|
|
1084
|
+
console.print("[dim]Underlying Task, Monitor, and FindAll resources were not deleted.[/dim]")
|
|
1085
|
+
|
|
1086
|
+
|
|
879
1087
|
# =============================================================================
|
|
880
1088
|
# Search Command
|
|
881
1089
|
# =============================================================================
|
|
@@ -1960,6 +2168,12 @@ def research():
|
|
|
1960
2168
|
"--previous-interaction-id",
|
|
1961
2169
|
help="Interaction ID from a previous task to reuse as context",
|
|
1962
2170
|
)
|
|
2171
|
+
@click.option(
|
|
2172
|
+
"--memory-scope-key",
|
|
2173
|
+
"--scope-key",
|
|
2174
|
+
type=MEMORY_SCOPE_KEY,
|
|
2175
|
+
help="Optional key identifying the memory scope to use. Omit to use personal memory, if available.",
|
|
2176
|
+
)
|
|
1963
2177
|
def research_run(
|
|
1964
2178
|
query: str | None,
|
|
1965
2179
|
input_file: str | None,
|
|
@@ -1974,6 +2188,7 @@ def research_run(
|
|
|
1974
2188
|
force: bool,
|
|
1975
2189
|
output_json: bool,
|
|
1976
2190
|
previous_interaction_id: str | None,
|
|
2191
|
+
memory_scope_key: str | None,
|
|
1977
2192
|
):
|
|
1978
2193
|
"""Run deep research on a question or topic.
|
|
1979
2194
|
|
|
@@ -2004,6 +2219,8 @@ def research_run(
|
|
|
2004
2219
|
echo "My research question" | parallel-cli research run - --json
|
|
2005
2220
|
parallel-cli research run "What are the implications?" \\
|
|
2006
2221
|
--previous-interaction-id trun_abc123
|
|
2222
|
+
parallel-cli research run "Research for this workspace" \\
|
|
2223
|
+
--memory-scope-key workspace_acme
|
|
2007
2224
|
"""
|
|
2008
2225
|
output_schema = "text" if use_text else "auto"
|
|
2009
2226
|
|
|
@@ -2041,6 +2258,8 @@ def research_run(
|
|
|
2041
2258
|
"output_paths": planned_paths,
|
|
2042
2259
|
"force": force,
|
|
2043
2260
|
}
|
|
2261
|
+
if memory_scope_key is not None:
|
|
2262
|
+
dry_run_data["memory_scope_key"] = memory_scope_key
|
|
2044
2263
|
if output_json:
|
|
2045
2264
|
print(json.dumps(dry_run_data, indent=2))
|
|
2046
2265
|
else:
|
|
@@ -2069,6 +2288,7 @@ def research_run(
|
|
|
2069
2288
|
previous_interaction_id=previous_interaction_id,
|
|
2070
2289
|
output_schema=output_schema,
|
|
2071
2290
|
text_description=text_description,
|
|
2291
|
+
memory_scope_key=memory_scope_key,
|
|
2072
2292
|
)
|
|
2073
2293
|
run_id_box.append(result["run_id"])
|
|
2074
2294
|
|
|
@@ -2121,6 +2341,7 @@ def research_run(
|
|
|
2121
2341
|
previous_interaction_id=previous_interaction_id,
|
|
2122
2342
|
output_schema=output_schema,
|
|
2123
2343
|
text_description=text_description,
|
|
2344
|
+
memory_scope_key=memory_scope_key,
|
|
2124
2345
|
)
|
|
2125
2346
|
|
|
2126
2347
|
_save_and_display_research(result, output_base, output_json, force=force)
|
|
@@ -2540,6 +2761,12 @@ def findall():
|
|
|
2540
2761
|
is_flag=True,
|
|
2541
2762
|
help="Ingest schema via API to preview entity type and conditions, but don't create the run",
|
|
2542
2763
|
)
|
|
2764
|
+
@click.option(
|
|
2765
|
+
"--memory-scope-key",
|
|
2766
|
+
"--scope-key",
|
|
2767
|
+
type=MEMORY_SCOPE_KEY,
|
|
2768
|
+
help="Optional key identifying the memory scope to use. Omit to use personal memory, if available.",
|
|
2769
|
+
)
|
|
2543
2770
|
@click.option("-o", "--output", "output_file", type=click.Path(), help="Save results to JSON file")
|
|
2544
2771
|
@click.option("--json", "output_json", is_flag=True, help="Output JSON to stdout")
|
|
2545
2772
|
def findall_run(
|
|
@@ -2552,6 +2779,7 @@ def findall_run(
|
|
|
2552
2779
|
poll_interval: int,
|
|
2553
2780
|
no_wait: bool,
|
|
2554
2781
|
dry_run: bool,
|
|
2782
|
+
memory_scope_key: str | None,
|
|
2555
2783
|
output_file: str | None,
|
|
2556
2784
|
output_json: bool,
|
|
2557
2785
|
):
|
|
@@ -2593,6 +2821,8 @@ def findall_run(
|
|
|
2593
2821
|
"match_conditions": schema.get("match_conditions", []),
|
|
2594
2822
|
"enrichments": schema.get("enrichments", []),
|
|
2595
2823
|
}
|
|
2824
|
+
if memory_scope_key is not None:
|
|
2825
|
+
dry_run_data["memory_scope_key"] = memory_scope_key
|
|
2596
2826
|
|
|
2597
2827
|
if output_json:
|
|
2598
2828
|
print(json.dumps(dry_run_data, indent=2, default=str))
|
|
@@ -2639,6 +2869,7 @@ def findall_run(
|
|
|
2639
2869
|
exclude_list=exclude_list,
|
|
2640
2870
|
metadata=metadata,
|
|
2641
2871
|
source="cli",
|
|
2872
|
+
memory_scope_key=memory_scope_key,
|
|
2642
2873
|
)
|
|
2643
2874
|
|
|
2644
2875
|
if output_json:
|
|
@@ -2694,6 +2925,7 @@ def findall_run(
|
|
|
2694
2925
|
poll_interval=poll_interval,
|
|
2695
2926
|
on_status=on_status,
|
|
2696
2927
|
source="cli",
|
|
2928
|
+
memory_scope_key=memory_scope_key,
|
|
2697
2929
|
)
|
|
2698
2930
|
|
|
2699
2931
|
_output_findall_result(result, output_file, output_json)
|
|
@@ -3205,6 +3437,12 @@ def monitor():
|
|
|
3205
3437
|
is_flag=True,
|
|
3206
3438
|
help="event_stream only: include a sample of historical events on first run.",
|
|
3207
3439
|
)
|
|
3440
|
+
@click.option(
|
|
3441
|
+
"--memory-scope-key",
|
|
3442
|
+
"--scope-key",
|
|
3443
|
+
type=MEMORY_SCOPE_KEY,
|
|
3444
|
+
help="Optional key identifying the memory scope to use. Omit to use personal memory, if available.",
|
|
3445
|
+
)
|
|
3208
3446
|
@click.option("-o", "--output", "output_file", type=click.Path(), help="Save result to JSON file")
|
|
3209
3447
|
@click.option("--json", "output_json", is_flag=True, help="Output JSON to stdout")
|
|
3210
3448
|
def monitor_create(
|
|
@@ -3217,6 +3455,7 @@ def monitor_create(
|
|
|
3217
3455
|
metadata_json: str | None,
|
|
3218
3456
|
output_schema_json: str | None,
|
|
3219
3457
|
include_backfill: bool,
|
|
3458
|
+
memory_scope_key: str | None,
|
|
3220
3459
|
output_file: str | None,
|
|
3221
3460
|
output_json: bool,
|
|
3222
3461
|
):
|
|
@@ -3272,6 +3511,7 @@ def monitor_create(
|
|
|
3272
3511
|
include_backfill=include_backfill or None,
|
|
3273
3512
|
processor=processor,
|
|
3274
3513
|
source="cli",
|
|
3514
|
+
memory_scope_key=memory_scope_key,
|
|
3275
3515
|
)
|
|
3276
3516
|
|
|
3277
3517
|
write_json_output(result, output_file, output_json)
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/__init__.py
RENAMED
|
@@ -39,6 +39,18 @@ from parallel_web_tools.core.findall import (
|
|
|
39
39
|
poll_findall,
|
|
40
40
|
run_findall,
|
|
41
41
|
)
|
|
42
|
+
from parallel_web_tools.core.memory import (
|
|
43
|
+
MAX_MEMORY_QUERY_CHARS,
|
|
44
|
+
MAX_MEMORY_RESULTS,
|
|
45
|
+
MEMORY_KINDS,
|
|
46
|
+
MemoryApiError,
|
|
47
|
+
MemoryInputError,
|
|
48
|
+
MemoryKind,
|
|
49
|
+
clear_memory,
|
|
50
|
+
evict_memory,
|
|
51
|
+
retrieve_memory,
|
|
52
|
+
validate_memory_scope_key,
|
|
53
|
+
)
|
|
42
54
|
from parallel_web_tools.core.monitor import (
|
|
43
55
|
MONITOR_EVENT_TYPES,
|
|
44
56
|
MONITOR_FREQUENCY_PRESETS,
|
|
@@ -139,6 +151,17 @@ __all__ = [
|
|
|
139
151
|
"get_research_status",
|
|
140
152
|
"poll_research",
|
|
141
153
|
"run_research",
|
|
154
|
+
# Memory
|
|
155
|
+
"MAX_MEMORY_QUERY_CHARS",
|
|
156
|
+
"MAX_MEMORY_RESULTS",
|
|
157
|
+
"MEMORY_KINDS",
|
|
158
|
+
"MemoryApiError",
|
|
159
|
+
"MemoryInputError",
|
|
160
|
+
"MemoryKind",
|
|
161
|
+
"clear_memory",
|
|
162
|
+
"evict_memory",
|
|
163
|
+
"retrieve_memory",
|
|
164
|
+
"validate_memory_scope_key",
|
|
142
165
|
# FindAll
|
|
143
166
|
"ENTITY_SEARCH_ENTITY_TYPES",
|
|
144
167
|
"FINDALL_GENERATORS",
|
|
@@ -17,6 +17,7 @@ from collections.abc import Callable
|
|
|
17
17
|
from typing import Any, Literal, cast
|
|
18
18
|
|
|
19
19
|
from parallel_web_tools.core.auth import create_client
|
|
20
|
+
from parallel_web_tools.core.memory import validate_memory_scope_key
|
|
20
21
|
from parallel_web_tools.core.polling import poll_until
|
|
21
22
|
from parallel_web_tools.core.user_agent import ClientSource
|
|
22
23
|
|
|
@@ -106,6 +107,7 @@ def create_findall_run(
|
|
|
106
107
|
metadata: dict[str, Any] | None = None,
|
|
107
108
|
api_key: str | None = None,
|
|
108
109
|
source: ClientSource = "python",
|
|
110
|
+
memory_scope_key: str | None = None,
|
|
109
111
|
) -> dict[str, Any]:
|
|
110
112
|
"""Create a FindAll run without waiting for results.
|
|
111
113
|
|
|
@@ -119,6 +121,8 @@ def create_findall_run(
|
|
|
119
121
|
metadata: Optional metadata dict.
|
|
120
122
|
api_key: Optional API key override.
|
|
121
123
|
source: Client source identifier for User-Agent.
|
|
124
|
+
memory_scope_key: Optional key identifying the memory scope to use.
|
|
125
|
+
Omit to use personal memory, if available.
|
|
122
126
|
|
|
123
127
|
Returns:
|
|
124
128
|
Dict with findall_id, status, generator, and timestamps.
|
|
@@ -137,6 +141,9 @@ def create_findall_run(
|
|
|
137
141
|
if metadata:
|
|
138
142
|
kwargs["metadata"] = metadata
|
|
139
143
|
|
|
144
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
145
|
+
if scope_key is not None:
|
|
146
|
+
kwargs["memory_scope_key"] = scope_key
|
|
140
147
|
run = client.beta.findall.create(**kwargs)
|
|
141
148
|
status_info = _extract_status_info(run)
|
|
142
149
|
|
|
@@ -405,6 +412,7 @@ def run_findall(
|
|
|
405
412
|
on_status: FindAllStatusCallback | None = None,
|
|
406
413
|
source: ClientSource = "python",
|
|
407
414
|
enrich: bool = True,
|
|
415
|
+
memory_scope_key: str | None = None,
|
|
408
416
|
) -> dict[str, Any]:
|
|
409
417
|
"""Ingest, create, and poll a FindAll run to completion.
|
|
410
418
|
|
|
@@ -427,6 +435,8 @@ def run_findall(
|
|
|
427
435
|
on_status: Optional callback(status, findall_id, metrics) on each poll.
|
|
428
436
|
source: Client source identifier for User-Agent.
|
|
429
437
|
enrich: Whether to apply suggested enrichments from ingest. Default True.
|
|
438
|
+
memory_scope_key: Optional key identifying the memory scope to use.
|
|
439
|
+
Omit to use personal memory, if available.
|
|
430
440
|
|
|
431
441
|
Returns:
|
|
432
442
|
Dict with findall_id, status, metrics, and candidates.
|
|
@@ -460,6 +470,9 @@ def run_findall(
|
|
|
460
470
|
if metadata:
|
|
461
471
|
kwargs["metadata"] = metadata
|
|
462
472
|
|
|
473
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
474
|
+
if scope_key is not None:
|
|
475
|
+
kwargs["memory_scope_key"] = scope_key
|
|
463
476
|
run = client.beta.findall.create(**kwargs)
|
|
464
477
|
findall_id = run.findall_id
|
|
465
478
|
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"""Retrieve and manage Parallel Memory through the generated Python SDK."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import datetime
|
|
6
|
+
import re
|
|
7
|
+
from typing import Any, Literal
|
|
8
|
+
|
|
9
|
+
from parallel_web_tools.core.auth import create_client
|
|
10
|
+
from parallel_web_tools.core.user_agent import ClientSource
|
|
11
|
+
|
|
12
|
+
MemoryKind = Literal["task", "monitor", "findall"]
|
|
13
|
+
|
|
14
|
+
MEMORY_KINDS: tuple[MemoryKind, ...] = ("task", "monitor", "findall")
|
|
15
|
+
MAX_MEMORY_QUERY_CHARS = 500
|
|
16
|
+
MAX_MEMORY_RESULTS = 25
|
|
17
|
+
MEMORY_IDENTIFIER_PATTERN = r"^[a-zA-Z0-9_-]{1,128}$"
|
|
18
|
+
_MEMORY_IDENTIFIER_RE = re.compile(MEMORY_IDENTIFIER_PATTERN)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class MemoryInputError(ValueError):
|
|
22
|
+
"""Raised when a Memory request is invalid before it reaches the API."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class MemoryApiError(RuntimeError):
|
|
26
|
+
"""Raised when the Memory SDK returns a malformed response."""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
message: str,
|
|
31
|
+
*,
|
|
32
|
+
status_code: int | None = None,
|
|
33
|
+
body: dict[str, Any] | None = None,
|
|
34
|
+
) -> None:
|
|
35
|
+
super().__init__(message)
|
|
36
|
+
self.status_code = status_code
|
|
37
|
+
self.body = body
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def validate_memory_identifier(value: str, field: str) -> str:
|
|
41
|
+
"""Validate a scope key or source ID against the public API contract."""
|
|
42
|
+
if not _MEMORY_IDENTIFIER_RE.fullmatch(value):
|
|
43
|
+
raise MemoryInputError(f"{field} must be 1-128 ASCII letters, digits, underscores, or hyphens")
|
|
44
|
+
return value
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def validate_memory_scope_key(memory_scope_key: str | None) -> str | None:
|
|
48
|
+
"""Validate and return a Memory scope key, preserving ``None`` for personal memory."""
|
|
49
|
+
if memory_scope_key is None:
|
|
50
|
+
return None
|
|
51
|
+
return validate_memory_identifier(memory_scope_key, "memory_scope_key")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _normalize_since(value: str | datetime.datetime) -> str:
|
|
55
|
+
"""Return an RFC 3339 timestamp after verifying that it has a timezone."""
|
|
56
|
+
if isinstance(value, datetime.datetime):
|
|
57
|
+
parsed = value
|
|
58
|
+
rendered = value.isoformat()
|
|
59
|
+
else:
|
|
60
|
+
rendered = value
|
|
61
|
+
normalized = value[:-1] + "+00:00" if value.endswith(("Z", "z")) else value
|
|
62
|
+
try:
|
|
63
|
+
parsed = datetime.datetime.fromisoformat(normalized)
|
|
64
|
+
except ValueError as exc:
|
|
65
|
+
raise MemoryInputError("since must be an RFC 3339 timestamp") from exc
|
|
66
|
+
|
|
67
|
+
if parsed.tzinfo is None or parsed.utcoffset() is None:
|
|
68
|
+
raise MemoryInputError("since must include a timezone")
|
|
69
|
+
return rendered
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _serialize_sdk_response(value: Any) -> dict[str, Any]:
|
|
73
|
+
if isinstance(value, dict):
|
|
74
|
+
return value
|
|
75
|
+
if hasattr(value, "model_dump"):
|
|
76
|
+
data = value.model_dump(mode="json")
|
|
77
|
+
if isinstance(data, dict):
|
|
78
|
+
return data
|
|
79
|
+
if hasattr(value, "to_dict"):
|
|
80
|
+
data = value.to_dict()
|
|
81
|
+
if isinstance(data, dict):
|
|
82
|
+
return data
|
|
83
|
+
raise MemoryApiError("Memory SDK returned an unexpected response")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def retrieve_memory(
|
|
87
|
+
query: str | None = "",
|
|
88
|
+
limit: int = 10,
|
|
89
|
+
*,
|
|
90
|
+
kind: MemoryKind | None = None,
|
|
91
|
+
since: str | datetime.datetime | None = None,
|
|
92
|
+
memory_scope_key: str | None = None,
|
|
93
|
+
api_key: str | None = None,
|
|
94
|
+
source: ClientSource = "python",
|
|
95
|
+
) -> dict[str, Any]:
|
|
96
|
+
"""Retrieve relevant or recent saved Task, Monitor, and FindAll runs."""
|
|
97
|
+
if query is not None and len(query) > MAX_MEMORY_QUERY_CHARS:
|
|
98
|
+
raise MemoryInputError(f"query must be at most {MAX_MEMORY_QUERY_CHARS} characters")
|
|
99
|
+
if not 1 <= limit <= MAX_MEMORY_RESULTS:
|
|
100
|
+
raise MemoryInputError(f"limit must be between 1 and {MAX_MEMORY_RESULTS}")
|
|
101
|
+
if kind is not None and kind not in MEMORY_KINDS:
|
|
102
|
+
raise MemoryInputError(f"kind must be one of: {', '.join(MEMORY_KINDS)}")
|
|
103
|
+
|
|
104
|
+
kwargs: dict[str, Any] = {"query": query, "limit": limit}
|
|
105
|
+
if kind is not None:
|
|
106
|
+
kwargs["kind"] = kind
|
|
107
|
+
if since is not None:
|
|
108
|
+
kwargs["since"] = _normalize_since(since)
|
|
109
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
110
|
+
if scope_key is not None:
|
|
111
|
+
kwargs["memory_scope_key"] = scope_key
|
|
112
|
+
|
|
113
|
+
client = create_client(api_key, source)
|
|
114
|
+
result = _serialize_sdk_response(client.beta.memory.retrieve(**kwargs))
|
|
115
|
+
if not isinstance(result.get("results"), list):
|
|
116
|
+
raise MemoryApiError("Memory retrieve returned an unexpected response")
|
|
117
|
+
return result
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def evict_memory(
|
|
121
|
+
kind: MemoryKind,
|
|
122
|
+
source_id: str,
|
|
123
|
+
*,
|
|
124
|
+
memory_scope_key: str | None = None,
|
|
125
|
+
api_key: str | None = None,
|
|
126
|
+
source: ClientSource = "python",
|
|
127
|
+
) -> dict[str, Any]:
|
|
128
|
+
"""Remove one source from Memory without deleting the underlying resource."""
|
|
129
|
+
if kind not in MEMORY_KINDS:
|
|
130
|
+
raise MemoryInputError(f"kind must be one of: {', '.join(MEMORY_KINDS)}")
|
|
131
|
+
|
|
132
|
+
kwargs: dict[str, Any] = {
|
|
133
|
+
"kind": kind,
|
|
134
|
+
"id": validate_memory_identifier(source_id, "source id"),
|
|
135
|
+
}
|
|
136
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
137
|
+
if scope_key is not None:
|
|
138
|
+
kwargs["memory_scope_key"] = scope_key
|
|
139
|
+
|
|
140
|
+
client = create_client(api_key, source)
|
|
141
|
+
client.beta.memory.evict(**kwargs)
|
|
142
|
+
return {"ok": True, "action": "evict"}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def clear_memory(
|
|
146
|
+
*,
|
|
147
|
+
memory_scope_key: str | None = None,
|
|
148
|
+
api_key: str | None = None,
|
|
149
|
+
source: ClientSource = "python",
|
|
150
|
+
) -> dict[str, Any]:
|
|
151
|
+
"""Permanently clear personal Memory or a scoped Memory."""
|
|
152
|
+
kwargs: dict[str, Any] = {}
|
|
153
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
154
|
+
if scope_key is not None:
|
|
155
|
+
kwargs["memory_scope_key"] = scope_key
|
|
156
|
+
|
|
157
|
+
client = create_client(api_key, source)
|
|
158
|
+
client.beta.memory.clear(**kwargs)
|
|
159
|
+
return {"ok": True, "action": "clear"}
|
|
@@ -16,6 +16,7 @@ from __future__ import annotations
|
|
|
16
16
|
from typing import Any
|
|
17
17
|
|
|
18
18
|
from parallel_web_tools.core.auth import create_client
|
|
19
|
+
from parallel_web_tools.core.memory import validate_memory_scope_key
|
|
19
20
|
from parallel_web_tools.core.user_agent import ClientSource
|
|
20
21
|
|
|
21
22
|
# Friendly aliases for SDK frequency strings.
|
|
@@ -72,6 +73,7 @@ def create_monitor(
|
|
|
72
73
|
processor: str | None = None,
|
|
73
74
|
api_key: str | None = None,
|
|
74
75
|
source: ClientSource = "python",
|
|
76
|
+
memory_scope_key: str | None = None,
|
|
75
77
|
) -> dict[str, Any]:
|
|
76
78
|
"""Create a new monitor.
|
|
77
79
|
|
|
@@ -92,6 +94,8 @@ def create_monitor(
|
|
|
92
94
|
processor: ``lite`` (default, fast/cheap) or ``base`` (more thorough).
|
|
93
95
|
api_key: Optional API key override.
|
|
94
96
|
source: Client source identifier for User-Agent.
|
|
97
|
+
memory_scope_key: Optional key identifying the memory scope to use.
|
|
98
|
+
Omit to use personal memory, if available.
|
|
95
99
|
|
|
96
100
|
Returns:
|
|
97
101
|
Dict representation of the created Monitor.
|
|
@@ -126,6 +130,9 @@ def create_monitor(
|
|
|
126
130
|
if processor is not None:
|
|
127
131
|
kwargs["processor"] = processor
|
|
128
132
|
|
|
133
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
134
|
+
if scope_key is not None:
|
|
135
|
+
kwargs["memory_scope_key"] = scope_key
|
|
129
136
|
return _to_dict(client.monitor.create(**kwargs))
|
|
130
137
|
|
|
131
138
|
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/research.py
RENAMED
|
@@ -12,6 +12,7 @@ from collections.abc import Callable
|
|
|
12
12
|
from typing import Any, Literal
|
|
13
13
|
|
|
14
14
|
from parallel_web_tools.core.auth import create_client
|
|
15
|
+
from parallel_web_tools.core.memory import validate_memory_scope_key
|
|
15
16
|
from parallel_web_tools.core.polling import poll_until
|
|
16
17
|
from parallel_web_tools.core.user_agent import ClientSource
|
|
17
18
|
|
|
@@ -100,6 +101,7 @@ def create_research_task(
|
|
|
100
101
|
previous_interaction_id: str | None = None,
|
|
101
102
|
output_schema: OutputSchemaType = "auto",
|
|
102
103
|
text_description: str | None = None,
|
|
104
|
+
memory_scope_key: str | None = None,
|
|
103
105
|
) -> dict[str, Any]:
|
|
104
106
|
"""Create a deep research task without waiting for results.
|
|
105
107
|
|
|
@@ -114,6 +116,8 @@ def create_research_task(
|
|
|
114
116
|
"text" (markdown report with inline citations).
|
|
115
117
|
text_description: Optional steering description for text-schema reports
|
|
116
118
|
(e.g. "Keep under 1000 words, focus on M&A activity").
|
|
119
|
+
memory_scope_key: Optional key identifying the memory scope to use.
|
|
120
|
+
Omit to use personal memory, if available.
|
|
117
121
|
|
|
118
122
|
Returns:
|
|
119
123
|
Dict with run_id, interaction_id, result_url, output_schema, and other metadata.
|
|
@@ -130,6 +134,9 @@ def create_research_task(
|
|
|
130
134
|
if task_spec is not None:
|
|
131
135
|
create_kwargs["task_spec"] = task_spec
|
|
132
136
|
|
|
137
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
138
|
+
if scope_key is not None:
|
|
139
|
+
create_kwargs["memory_scope_key"] = scope_key
|
|
133
140
|
task = client.task_run.create(**create_kwargs)
|
|
134
141
|
|
|
135
142
|
return {
|
|
@@ -289,6 +296,7 @@ def run_research(
|
|
|
289
296
|
previous_interaction_id: str | None = None,
|
|
290
297
|
output_schema: OutputSchemaType = "auto",
|
|
291
298
|
text_description: str | None = None,
|
|
299
|
+
memory_scope_key: str | None = None,
|
|
292
300
|
) -> dict[str, Any]:
|
|
293
301
|
"""Run deep research and wait for results.
|
|
294
302
|
|
|
@@ -308,6 +316,8 @@ def run_research(
|
|
|
308
316
|
output_schema: "auto" (default; API-chosen structured output) or
|
|
309
317
|
"text" (markdown report with inline citations).
|
|
310
318
|
text_description: Optional steering description for text-schema reports.
|
|
319
|
+
memory_scope_key: Optional key identifying the memory scope to use.
|
|
320
|
+
Omit to use personal memory, if available.
|
|
311
321
|
|
|
312
322
|
Returns:
|
|
313
323
|
Dict with content and metadata, including the requested output_schema.
|
|
@@ -328,6 +338,9 @@ def run_research(
|
|
|
328
338
|
if task_spec is not None:
|
|
329
339
|
create_kwargs["task_spec"] = task_spec
|
|
330
340
|
|
|
341
|
+
scope_key = validate_memory_scope_key(memory_scope_key)
|
|
342
|
+
if scope_key is not None:
|
|
343
|
+
create_kwargs["memory_scope_key"] = scope_key
|
|
331
344
|
task = client.task_run.create(**create_kwargs)
|
|
332
345
|
run_id = task.run_id
|
|
333
346
|
interaction_id = getattr(task, "interaction_id", run_id)
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "parallel-web-tools"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.8.1"
|
|
8
8
|
description = "Parallel Tools: CLI and Python SDK for AI-powered web intelligence"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -29,7 +29,7 @@ classifiers = [
|
|
|
29
29
|
]
|
|
30
30
|
|
|
31
31
|
dependencies = [
|
|
32
|
-
"parallel-web>=1.
|
|
32
|
+
"parallel-web>=1.2.0,<2",
|
|
33
33
|
"python-dotenv>=1.0.0",
|
|
34
34
|
# CLI dependencies (minimal - search, extract, enrich with CLI args)
|
|
35
35
|
"click>=8.1.0",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/credentials.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/endpoints.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/service_types.py
RENAMED
|
File without changes
|
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/sql_utils.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/core/user_agent.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/integrations/utils.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/__init__.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/bigquery.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/csv.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/duckdb.py
RENAMED
|
File without changes
|
{parallel_web_tools-0.7.1rc2 → parallel_web_tools-0.8.1}/parallel_web_tools/processors/json.py
RENAMED
|
File without changes
|