88
99import httpx
1010
11- from ..types import memory_add_params , memory_list_params , memory_search_params , memory_upload_params
11+ from ..types import (
12+ memory_add_params ,
13+ memory_list_params ,
14+ memory_search_params ,
15+ memory_update_params ,
16+ memory_upload_params ,
17+ )
1218from .._types import Body , Omit , Query , Headers , NotGiven , FileTypes , omit , not_given
1319from .._utils import extract_files , maybe_transform , deepcopy_minimal , async_maybe_transform
1420from .._compat import cached_property
@@ -50,11 +56,123 @@ def with_streaming_response(self) -> MemoriesResourceWithStreamingResponse:
5056 """
5157 return MemoriesResourceWithStreamingResponse (self )
5258
59+ def update (
60+ self ,
61+ resource_id : str ,
62+ * ,
63+ source : Literal [
64+ "collections" ,
65+ "vault" ,
66+ "web_crawler" ,
67+ "notion" ,
68+ "slack" ,
69+ "google_calendar" ,
70+ "reddit" ,
71+ "box" ,
72+ "google_drive" ,
73+ "airtable" ,
74+ "algolia" ,
75+ "amplitude" ,
76+ "asana" ,
77+ "ashby" ,
78+ "bamboohr" ,
79+ "basecamp" ,
80+ "bubbles" ,
81+ "calendly" ,
82+ "confluence" ,
83+ "clickup" ,
84+ "datadog" ,
85+ "deel" ,
86+ "discord" ,
87+ "dropbox" ,
88+ "exa" ,
89+ "facebook" ,
90+ "front" ,
91+ "github" ,
92+ "gitlab" ,
93+ "google_docs" ,
94+ "google_mail" ,
95+ "google_sheet" ,
96+ "hubspot" ,
97+ "jira" ,
98+ "linear" ,
99+ "microsoft_teams" ,
100+ "mixpanel" ,
101+ "monday" ,
102+ "outlook" ,
103+ "perplexity" ,
104+ "rippling" ,
105+ "salesforce" ,
106+ "segment" ,
107+ "todoist" ,
108+ "twitter" ,
109+ "zoom" ,
110+ ],
111+ collection : Union [str , object , None ] | Omit = omit ,
112+ metadata : Union [Dict [str , Union [str , float , bool ]], object , None ] | Omit = omit ,
113+ text : Union [str , object , None ] | Omit = omit ,
114+ title : Union [str , object , None ] | Omit = omit ,
115+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
116+ # The extra values given here take precedence over values defined on the client or passed to this method.
117+ extra_headers : Headers | None = None ,
118+ extra_query : Query | None = None ,
119+ extra_body : Body | None = None ,
120+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
121+ ) -> MemoryStatus :
122+ """Updates an existing document in the index.
123+
124+ You can update the text, collection,
125+ title, and metadata. The document must already exist or a 404 will be returned.
126+ This works for documents from any source (vault, slack, gmail, etc.).
127+
128+ To remove a collection, set it to null explicitly.
129+
130+ Args:
131+ collection: The collection to move the document to. Set to null to remove the collection.
132+
133+ metadata: Custom metadata for filtering. Keys must be alphanumeric with underscores, max
134+ 64 chars. Values must be string, number, or boolean. Will be merged with
135+ existing metadata.
136+
137+ text: Full text of the document. If provided, the document will be re-indexed.
138+
139+ title: Title of the document.
140+
141+ extra_headers: Send extra headers
142+
143+ extra_query: Add additional query parameters to the request
144+
145+ extra_body: Add additional JSON properties to the request
146+
147+ timeout: Override the client-level default timeout for this request, in seconds
148+ """
149+ if not source :
150+ raise ValueError (f"Expected a non-empty value for `source` but received { source !r} " )
151+ if not resource_id :
152+ raise ValueError (f"Expected a non-empty value for `resource_id` but received { resource_id !r} " )
153+ return self ._post (
154+ f"/memories/update/{ source } /{ resource_id } " ,
155+ body = maybe_transform (
156+ {
157+ "collection" : collection ,
158+ "metadata" : metadata ,
159+ "text" : text ,
160+ "title" : title ,
161+ },
162+ memory_update_params .MemoryUpdateParams ,
163+ ),
164+ options = make_request_options (
165+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
166+ ),
167+ cast_to = MemoryStatus ,
168+ )
169+
53170 def list (
54171 self ,
55172 * ,
56173 collection : Optional [str ] | Omit = omit ,
57174 cursor : Optional [str ] | Omit = omit ,
175+ filter : Optional [str ] | Omit = omit ,
58176 size : int | Omit = omit ,
59177 source : Optional [
60178 Literal [
@@ -122,6 +240,10 @@ def list(
122240 Args:
123241 collection: Filter documents by collection.
124242
243+ filter:
244+ Filter documents by metadata using MongoDB-style operators. Example:
245+ {"department": "engineering", "priority": {"$gt": 3}}
246+
125247 source: Filter documents by source.
126248
127249 extra_headers: Send extra headers
@@ -144,6 +266,7 @@ def list(
144266 {
145267 "collection" : collection ,
146268 "cursor" : cursor ,
269+ "filter" : filter ,
147270 "size" : size ,
148271 "source" : source ,
149272 },
@@ -606,11 +729,123 @@ def with_streaming_response(self) -> AsyncMemoriesResourceWithStreamingResponse:
606729 """
607730 return AsyncMemoriesResourceWithStreamingResponse (self )
608731
732+ async def update (
733+ self ,
734+ resource_id : str ,
735+ * ,
736+ source : Literal [
737+ "collections" ,
738+ "vault" ,
739+ "web_crawler" ,
740+ "notion" ,
741+ "slack" ,
742+ "google_calendar" ,
743+ "reddit" ,
744+ "box" ,
745+ "google_drive" ,
746+ "airtable" ,
747+ "algolia" ,
748+ "amplitude" ,
749+ "asana" ,
750+ "ashby" ,
751+ "bamboohr" ,
752+ "basecamp" ,
753+ "bubbles" ,
754+ "calendly" ,
755+ "confluence" ,
756+ "clickup" ,
757+ "datadog" ,
758+ "deel" ,
759+ "discord" ,
760+ "dropbox" ,
761+ "exa" ,
762+ "facebook" ,
763+ "front" ,
764+ "github" ,
765+ "gitlab" ,
766+ "google_docs" ,
767+ "google_mail" ,
768+ "google_sheet" ,
769+ "hubspot" ,
770+ "jira" ,
771+ "linear" ,
772+ "microsoft_teams" ,
773+ "mixpanel" ,
774+ "monday" ,
775+ "outlook" ,
776+ "perplexity" ,
777+ "rippling" ,
778+ "salesforce" ,
779+ "segment" ,
780+ "todoist" ,
781+ "twitter" ,
782+ "zoom" ,
783+ ],
784+ collection : Union [str , object , None ] | Omit = omit ,
785+ metadata : Union [Dict [str , Union [str , float , bool ]], object , None ] | Omit = omit ,
786+ text : Union [str , object , None ] | Omit = omit ,
787+ title : Union [str , object , None ] | Omit = omit ,
788+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
789+ # The extra values given here take precedence over values defined on the client or passed to this method.
790+ extra_headers : Headers | None = None ,
791+ extra_query : Query | None = None ,
792+ extra_body : Body | None = None ,
793+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
794+ ) -> MemoryStatus :
795+ """Updates an existing document in the index.
796+
797+ You can update the text, collection,
798+ title, and metadata. The document must already exist or a 404 will be returned.
799+ This works for documents from any source (vault, slack, gmail, etc.).
800+
801+ To remove a collection, set it to null explicitly.
802+
803+ Args:
804+ collection: The collection to move the document to. Set to null to remove the collection.
805+
806+ metadata: Custom metadata for filtering. Keys must be alphanumeric with underscores, max
807+ 64 chars. Values must be string, number, or boolean. Will be merged with
808+ existing metadata.
809+
810+ text: Full text of the document. If provided, the document will be re-indexed.
811+
812+ title: Title of the document.
813+
814+ extra_headers: Send extra headers
815+
816+ extra_query: Add additional query parameters to the request
817+
818+ extra_body: Add additional JSON properties to the request
819+
820+ timeout: Override the client-level default timeout for this request, in seconds
821+ """
822+ if not source :
823+ raise ValueError (f"Expected a non-empty value for `source` but received { source !r} " )
824+ if not resource_id :
825+ raise ValueError (f"Expected a non-empty value for `resource_id` but received { resource_id !r} " )
826+ return await self ._post (
827+ f"/memories/update/{ source } /{ resource_id } " ,
828+ body = await async_maybe_transform (
829+ {
830+ "collection" : collection ,
831+ "metadata" : metadata ,
832+ "text" : text ,
833+ "title" : title ,
834+ },
835+ memory_update_params .MemoryUpdateParams ,
836+ ),
837+ options = make_request_options (
838+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
839+ ),
840+ cast_to = MemoryStatus ,
841+ )
842+
609843 def list (
610844 self ,
611845 * ,
612846 collection : Optional [str ] | Omit = omit ,
613847 cursor : Optional [str ] | Omit = omit ,
848+ filter : Optional [str ] | Omit = omit ,
614849 size : int | Omit = omit ,
615850 source : Optional [
616851 Literal [
@@ -678,6 +913,10 @@ def list(
678913 Args:
679914 collection: Filter documents by collection.
680915
916+ filter:
917+ Filter documents by metadata using MongoDB-style operators. Example:
918+ {"department": "engineering", "priority": {"$gt": 3}}
919+
681920 source: Filter documents by source.
682921
683922 extra_headers: Send extra headers
@@ -700,6 +939,7 @@ def list(
700939 {
701940 "collection" : collection ,
702941 "cursor" : cursor ,
942+ "filter" : filter ,
703943 "size" : size ,
704944 "source" : source ,
705945 },
@@ -1146,6 +1386,9 @@ class MemoriesResourceWithRawResponse:
11461386 def __init__ (self , memories : MemoriesResource ) -> None :
11471387 self ._memories = memories
11481388
1389+ self .update = to_raw_response_wrapper (
1390+ memories .update ,
1391+ )
11491392 self .list = to_raw_response_wrapper (
11501393 memories .list ,
11511394 )
@@ -1173,6 +1416,9 @@ class AsyncMemoriesResourceWithRawResponse:
11731416 def __init__ (self , memories : AsyncMemoriesResource ) -> None :
11741417 self ._memories = memories
11751418
1419+ self .update = async_to_raw_response_wrapper (
1420+ memories .update ,
1421+ )
11761422 self .list = async_to_raw_response_wrapper (
11771423 memories .list ,
11781424 )
@@ -1200,6 +1446,9 @@ class MemoriesResourceWithStreamingResponse:
12001446 def __init__ (self , memories : MemoriesResource ) -> None :
12011447 self ._memories = memories
12021448
1449+ self .update = to_streamed_response_wrapper (
1450+ memories .update ,
1451+ )
12031452 self .list = to_streamed_response_wrapper (
12041453 memories .list ,
12051454 )
@@ -1227,6 +1476,9 @@ class AsyncMemoriesResourceWithStreamingResponse:
12271476 def __init__ (self , memories : AsyncMemoriesResource ) -> None :
12281477 self ._memories = memories
12291478
1479+ self .update = async_to_streamed_response_wrapper (
1480+ memories .update ,
1481+ )
12301482 self .list = async_to_streamed_response_wrapper (
12311483 memories .list ,
12321484 )
0 commit comments