Skip to content

Commit 15f1f47

Browse files
feat(api): add memory support
1 parent a2b4daa commit 15f1f47

31 files changed

Lines changed: 1085 additions & 32 deletions

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
lint:
1919
timeout-minutes: 10
2020
name: lint
21-
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
21+
runs-on: 'ubuntu-latest'
2222
if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata')
2323
steps:
2424
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -44,7 +44,7 @@ jobs:
4444
permissions:
4545
contents: read
4646
id-token: write
47-
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
47+
runs-on: 'ubuntu-latest'
4848
steps:
4949
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
5050

@@ -64,7 +64,7 @@ jobs:
6464

6565
- name: Get GitHub OIDC Token
6666
if: |-
67-
github.repository == 'stainless-sdks/parallel-sdk-python' &&
67+
github.repository == 'parallel-web/parallel-sdk-python-staging' &&
6868
!startsWith(github.ref, 'refs/heads/stl/')
6969
id: github-oidc
7070
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
@@ -73,7 +73,7 @@ jobs:
7373

7474
- name: Upload tarball
7575
if: |-
76-
github.repository == 'stainless-sdks/parallel-sdk-python' &&
76+
github.repository == 'parallel-web/parallel-sdk-python-staging' &&
7777
!startsWith(github.ref, 'refs/heads/stl/')
7878
env:
7979
URL: https://pkg.stainless.com/s
@@ -84,7 +84,7 @@ jobs:
8484
test:
8585
timeout-minutes: 10
8686
name: test
87-
runs-on: ${{ startsWith(github.repository, 'stainless-sdks/') && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
87+
runs-on: 'ubuntu-latest'
8888
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
8989
steps:
9090
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 30
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/parallel-web/parallel-sdk-3001a018c926803bb713f19d99c3d5d39ed44ce3fe670bebefc326fd252b8821.yml
3-
openapi_spec_hash: 0883a98aa5b566818f5910d01c831c4a
4-
config_hash: 8572a2d7a5ede9ade3be8ad4d8aafd7d
1+
configured_endpoints: 33
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/parallel-web/parallel-sdk-dcb1605f4878ba899f427518b5f86d2bb79fc37820caa27392695fe8b7f5295c.yml
3+
openapi_spec_hash: 6c7d3db50b53be72d8b35c260f771004
4+
config_hash: d4f69197dba970d05757624fe3f7b373

scripts/utils/upload-artifact.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ UPLOAD_RESPONSE=$(curl -v -X PUT \
2020

2121
if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then
2222
echo -e "\033[32mUploaded build to Stainless storage.\033[0m"
23-
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/parallel-sdk-python/$SHA/$FILENAME'\033[0m"
23+
echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/parallel-sdk-python-staging/$SHA/$FILENAME'\033[0m"
2424
else
2525
echo -e "\033[31mFailed to upload artifact.\033[0m"
2626
exit 1

src/parallel/_client.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def search(
355355
advanced_settings: Optional[AdvancedSearchSettingsParam] | Omit = omit,
356356
client_model: Optional[str] | Omit = omit,
357357
max_chars_total: Optional[int] | Omit = omit,
358-
mode: Optional[Literal["turbo", "basic", "advanced"]] | Omit = omit,
358+
mode: Optional[Literal["turbo", "basic", "advanced", "fast"]] | Omit = omit,
359359
objective: Optional[str] | Omit = omit,
360360
session_id: Optional[str] | Omit = omit,
361361
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -388,11 +388,12 @@ def search(
388388
389389
max_chars_total: Upper bound on total characters across excerpts from all results.
390390
391-
mode: Search mode preset: supported values are `turbo`, `basic`, and `advanced`. Turbo
392-
mode is optimized for the fastest responses. Basic mode offers low latency and
393-
works best with 2-3 high-quality search_queries. Advanced mode provides higher
394-
quality with more advanced retrieval and compression. Defaults to `advanced`
395-
when omitted.
391+
mode: Search mode preset: supported values are `turbo`, `fast`, `basic`, and
392+
`advanced`. Turbo mode is optimized for the fastest responses. Fast mode trades
393+
some quality for low latency, and works best with concise, high-quality
394+
objective and search_queries. Basic mode offers low latency and works best with
395+
2-3 high-quality search_queries. Advanced mode provides higher quality with more
396+
advanced retrieval and compression. Defaults to `advanced` when omitted.
396397
397398
objective: Natural-language description of the underlying question or goal driving the
398399
search. Used together with search_queries to focus results on the most relevant
@@ -748,7 +749,7 @@ async def search(
748749
advanced_settings: Optional[AdvancedSearchSettingsParam] | Omit = omit,
749750
client_model: Optional[str] | Omit = omit,
750751
max_chars_total: Optional[int] | Omit = omit,
751-
mode: Optional[Literal["turbo", "basic", "advanced"]] | Omit = omit,
752+
mode: Optional[Literal["turbo", "basic", "advanced", "fast"]] | Omit = omit,
752753
objective: Optional[str] | Omit = omit,
753754
session_id: Optional[str] | Omit = omit,
754755
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -781,11 +782,12 @@ async def search(
781782
782783
max_chars_total: Upper bound on total characters across excerpts from all results.
783784
784-
mode: Search mode preset: supported values are `turbo`, `basic`, and `advanced`. Turbo
785-
mode is optimized for the fastest responses. Basic mode offers low latency and
786-
works best with 2-3 high-quality search_queries. Advanced mode provides higher
787-
quality with more advanced retrieval and compression. Defaults to `advanced`
788-
when omitted.
785+
mode: Search mode preset: supported values are `turbo`, `fast`, `basic`, and
786+
`advanced`. Turbo mode is optimized for the fastest responses. Fast mode trades
787+
some quality for low latency, and works best with concise, high-quality
788+
objective and search_queries. Basic mode offers low latency and works best with
789+
2-3 high-quality search_queries. Advanced mode provides higher quality with more
790+
advanced retrieval and compression. Defaults to `advanced` when omitted.
789791
790792
objective: Natural-language description of the underlying question or goal driving the
791793
search. Used together with search_queries to focus results on the most relevant

src/parallel/resources/beta/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88
BetaResourceWithStreamingResponse,
99
AsyncBetaResourceWithStreamingResponse,
1010
)
11+
from .memory import (
12+
MemoryResource,
13+
AsyncMemoryResource,
14+
MemoryResourceWithRawResponse,
15+
AsyncMemoryResourceWithRawResponse,
16+
MemoryResourceWithStreamingResponse,
17+
AsyncMemoryResourceWithStreamingResponse,
18+
)
1119
from .findall import (
1220
FindAllResource,
1321
AsyncFindAllResource,
@@ -24,6 +32,12 @@
2432
"AsyncFindAllResourceWithRawResponse",
2533
"FindAllResourceWithStreamingResponse",
2634
"AsyncFindAllResourceWithStreamingResponse",
35+
"MemoryResource",
36+
"AsyncMemoryResource",
37+
"MemoryResourceWithRawResponse",
38+
"AsyncMemoryResourceWithRawResponse",
39+
"MemoryResourceWithStreamingResponse",
40+
"AsyncMemoryResourceWithStreamingResponse",
2741
"BetaResource",
2842
"AsyncBetaResource",
2943
"BetaResourceWithRawResponse",

src/parallel/resources/beta/api.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,26 @@ Methods:
3939
- <code title="post /v1beta/findall/ingest">client.beta.findall.<a href="./src/parallel/resources/beta/findall.py">ingest</a>(\*\*<a href="src/parallel/types/beta/findall_ingest_params.py">params</a>) -> <a href="./src/parallel/types/beta/findall_schema.py">FindAllSchema</a></code>
4040
- <code title="get /v1beta/findall/runs/{findall_id}/result">client.beta.findall.<a href="./src/parallel/resources/beta/findall.py">result</a>(findall_id) -> <a href="./src/parallel/types/beta/findall_run_result.py">FindAllRunResult</a></code>
4141
- <code title="get /v1beta/findall/runs/{findall_id}/schema">client.beta.findall.<a href="./src/parallel/resources/beta/findall.py">schema</a>(findall_id) -> <a href="./src/parallel/types/beta/findall_schema.py">FindAllSchema</a></code>
42+
43+
## Memory
44+
45+
Types:
46+
47+
```python
48+
from parallel.types.beta import (
49+
FindAllMemoryResult,
50+
MemoryClearRequest,
51+
MemoryEvictRequest,
52+
MemoryRetrieveRequest,
53+
MemoryRetrieveResponse,
54+
MonitorMemoryEvent,
55+
MonitorMemoryResult,
56+
TaskMemoryResult,
57+
)
58+
```
59+
60+
Methods:
61+
62+
- <code title="post /v1beta/memory/retrieve">client.beta.memory.<a href="./src/parallel/resources/beta/memory.py">retrieve</a>(\*\*<a href="src/parallel/types/beta/memory_retrieve_params.py">params</a>) -> <a href="./src/parallel/types/beta/memory_retrieve_response.py">MemoryRetrieveResponse</a></code>
63+
- <code title="post /v1beta/memory/clear">client.beta.memory.<a href="./src/parallel/resources/beta/memory.py">clear</a>(\*\*<a href="src/parallel/types/beta/memory_clear_params.py">params</a>) -> None</code>
64+
- <code title="post /v1beta/memory/evict">client.beta.memory.<a href="./src/parallel/resources/beta/memory.py">evict</a>(\*\*<a href="src/parallel/types/beta/memory_evict_params.py">params</a>) -> None</code>

src/parallel/resources/beta/beta.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
from __future__ import annotations
44

5+
from .memory import (
6+
MemoryResource,
7+
AsyncMemoryResource,
8+
MemoryResourceWithRawResponse,
9+
AsyncMemoryResourceWithRawResponse,
10+
MemoryResourceWithStreamingResponse,
11+
AsyncMemoryResourceWithStreamingResponse,
12+
)
513
from .findall import (
614
FindAllResource,
715
AsyncFindAllResource,
@@ -24,6 +32,13 @@ def findall(self) -> FindAllResource:
2432
"""
2533
return FindAllResource(self._client)
2634

35+
@cached_property
36+
def memory(self) -> MemoryResource:
37+
"""
38+
The Memory API retrieves and manages memories created by Tasks, Monitors, and FindAll runs. Memories can be personal or isolated with a `memory_scope_key`.
39+
"""
40+
return MemoryResource(self._client)
41+
2742
@cached_property
2843
def with_raw_response(self) -> BetaResourceWithRawResponse:
2944
"""
@@ -52,6 +67,13 @@ def findall(self) -> AsyncFindAllResource:
5267
"""
5368
return AsyncFindAllResource(self._client)
5469

70+
@cached_property
71+
def memory(self) -> AsyncMemoryResource:
72+
"""
73+
The Memory API retrieves and manages memories created by Tasks, Monitors, and FindAll runs. Memories can be personal or isolated with a `memory_scope_key`.
74+
"""
75+
return AsyncMemoryResource(self._client)
76+
5577
@cached_property
5678
def with_raw_response(self) -> AsyncBetaResourceWithRawResponse:
5779
"""
@@ -83,6 +105,13 @@ def findall(self) -> FindAllResourceWithRawResponse:
83105
"""
84106
return FindAllResourceWithRawResponse(self._beta.findall)
85107

108+
@cached_property
109+
def memory(self) -> MemoryResourceWithRawResponse:
110+
"""
111+
The Memory API retrieves and manages memories created by Tasks, Monitors, and FindAll runs. Memories can be personal or isolated with a `memory_scope_key`.
112+
"""
113+
return MemoryResourceWithRawResponse(self._beta.memory)
114+
86115

87116
class AsyncBetaResourceWithRawResponse:
88117
def __init__(self, beta: AsyncBetaResource) -> None:
@@ -95,6 +124,13 @@ def findall(self) -> AsyncFindAllResourceWithRawResponse:
95124
"""
96125
return AsyncFindAllResourceWithRawResponse(self._beta.findall)
97126

127+
@cached_property
128+
def memory(self) -> AsyncMemoryResourceWithRawResponse:
129+
"""
130+
The Memory API retrieves and manages memories created by Tasks, Monitors, and FindAll runs. Memories can be personal or isolated with a `memory_scope_key`.
131+
"""
132+
return AsyncMemoryResourceWithRawResponse(self._beta.memory)
133+
98134

99135
class BetaResourceWithStreamingResponse:
100136
def __init__(self, beta: BetaResource) -> None:
@@ -107,6 +143,13 @@ def findall(self) -> FindAllResourceWithStreamingResponse:
107143
"""
108144
return FindAllResourceWithStreamingResponse(self._beta.findall)
109145

146+
@cached_property
147+
def memory(self) -> MemoryResourceWithStreamingResponse:
148+
"""
149+
The Memory API retrieves and manages memories created by Tasks, Monitors, and FindAll runs. Memories can be personal or isolated with a `memory_scope_key`.
150+
"""
151+
return MemoryResourceWithStreamingResponse(self._beta.memory)
152+
110153

111154
class AsyncBetaResourceWithStreamingResponse:
112155
def __init__(self, beta: AsyncBetaResource) -> None:
@@ -118,3 +161,10 @@ def findall(self) -> AsyncFindAllResourceWithStreamingResponse:
118161
The FindAll API discovers and evaluates entities that match complex criteria from natural language objectives. Submit a high-level goal and the service automatically generates structured match conditions, discovers relevant candidates, and evaluates each against the criteria. Returns comprehensive results with detailed reasoning, citations, and confidence scores for each match decision. Streaming events and webhooks are supported.
119162
"""
120163
return AsyncFindAllResourceWithStreamingResponse(self._beta.findall)
164+
165+
@cached_property
166+
def memory(self) -> AsyncMemoryResourceWithStreamingResponse:
167+
"""
168+
The Memory API retrieves and manages memories created by Tasks, Monitors, and FindAll runs. Memories can be personal or isolated with a `memory_scope_key`.
169+
"""
170+
return AsyncMemoryResourceWithStreamingResponse(self._beta.memory)

src/parallel/resources/beta/findall.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def create(
7575
match_limit: int,
7676
objective: str,
7777
exclude_list: Optional[Iterable[findall_create_params.ExcludeList]] | Omit = omit,
78+
memory_scope_key: Optional[str] | Omit = omit,
7879
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
7980
webhook: Optional[WebhookParam] | Omit = omit,
8081
betas: List[ParallelBetaParam] | Omit = omit,
@@ -111,7 +112,11 @@ def create(
111112
112113
objective: Natural language objective of the FindAll run.
113114
114-
exclude_list: List of entity names/IDs to exclude from results.
115+
exclude_list: List of entity names/IDs to exclude from results. At most 10,000 entries are
116+
allowed.
117+
118+
memory_scope_key: User-provided key identifying the memory scope to use. Omit to use personal
119+
memory, if available.
115120
116121
metadata: Metadata for the FindAll run.
117122
@@ -148,6 +153,7 @@ def create(
148153
"match_limit": match_limit,
149154
"objective": objective,
150155
"exclude_list": exclude_list,
156+
"memory_scope_key": memory_scope_key,
151157
"metadata": metadata,
152158
"webhook": webhook,
153159
},
@@ -675,6 +681,7 @@ async def create(
675681
match_limit: int,
676682
objective: str,
677683
exclude_list: Optional[Iterable[findall_create_params.ExcludeList]] | Omit = omit,
684+
memory_scope_key: Optional[str] | Omit = omit,
678685
metadata: Optional[Dict[str, Union[str, float, bool]]] | Omit = omit,
679686
webhook: Optional[WebhookParam] | Omit = omit,
680687
betas: List[ParallelBetaParam] | Omit = omit,
@@ -711,7 +718,11 @@ async def create(
711718
712719
objective: Natural language objective of the FindAll run.
713720
714-
exclude_list: List of entity names/IDs to exclude from results.
721+
exclude_list: List of entity names/IDs to exclude from results. At most 10,000 entries are
722+
allowed.
723+
724+
memory_scope_key: User-provided key identifying the memory scope to use. Omit to use personal
725+
memory, if available.
715726
716727
metadata: Metadata for the FindAll run.
717728
@@ -748,6 +759,7 @@ async def create(
748759
"match_limit": match_limit,
749760
"objective": objective,
750761
"exclude_list": exclude_list,
762+
"memory_scope_key": memory_scope_key,
751763
"metadata": metadata,
752764
"webhook": webhook,
753765
},

0 commit comments

Comments
 (0)