update_memory
async
¶
update_memory(
space_id: SpaceId,
memory_id: MemoryId,
*,
config_overrides: Optional[AsyncOpenSearchMemoryClientConfig] = None,
content: Optional[MemoryUpdateContent] = None,
metadata: Optional[MetadataMap] = None,
metadata_mode: Optional[MetadataMode] = None,
actor_id: Optional[ActorId] = None,
strategy_name: Optional[StrategyName] = None,
) -> UpdateMemoryOutput
Updates a memory in place. Supply only the fields to change. Omitted fields keep their stored values. A request must supply content or metadata, or it fails with ValidationException. Supplying content re-embeds the memory. A change to metadata alone doesn't.
The memory keeps its memoryId across updates. Shortly after an update, searches stop returning the previous content.
memoryType can't be changed. To change it, delete the memory and create a new one.
A memory past its expiry (set from the space's memoryExpiryDays when the memory is written) reads as not found: the operation fails with ResourceNotFoundException and changes nothing. An update does not move the expiry.
Concurrent updates to one memory are last-writer-wins. There is no version check. To avoid lost updates, serialize your updates to a memory.
If you supply content and the request would exceed the service's rate for embedding requests, it fails with ThrottlingException. Retry with exponential backoff.
If the space uses a customer managed AWS KMS key, the call can also fail because of the key. It fails with AccessDeniedException if you aren't allowed to use the key, and with ThrottlingException if AWS KMS throttles the request. It fails with ValidationException if the key is disabled, pending deletion, or deleted.
Parameters:
-
space_id(SpaceId) –The ID of the space that owns the memory, for example
sp-02864597b164. -
memory_id(MemoryId) –The ID of the memory to update.
-
content(Optional[MemoryUpdateContent], default:None) –Replacement memory text. Supplying it re-embeds the memory. Omit to leave the text unchanged.
-
metadata(Optional[MetadataMap], default:None) –The metadata tags to apply. By default this map replaces the stored metadata, and any key not present is removed. Set
metadataModetoMERGEto keep the keys you don't supply. Limits apply to the resulting metadata, not to the request. Keys that begin withx-amz-and the keydocumentS3Sourceare reserved: a request that sets one fails withValidationException.A space can use at most 50 distinct metadata keys across all of its events and memories. A request that would add a key beyond that fails with
ValidationException. Reuse an existing key instead. -
metadata_mode(Optional[MetadataMode], default:None) –How
metadatacombines with what is stored. The default isREPLACE. -
actor_id(Optional[ActorId], default:None) –The ID of the actor that the memory must belong to. Omit it to skip this check. If it doesn't match the stored memory, the call fails with
ResourceNotFoundException, as if the memory did not exist. -
strategy_name(Optional[StrategyName], default:None) –The name of the strategy that the memory must belong to. Omit it to skip this check. If it doesn't match the stored memory, the call fails with
ResourceNotFoundException, as if the memory did not exist.
Raises:
-
AccessDeniedException–You don't have sufficient access to perform this operation. To use this operation, you must have AWS Identity and Access Management (IAM) permissions for the operation, and on the resource it acts on. If the space uses a customer managed AWS Key Management Service (AWS KMS) key, you must also have permission to use the key.
-
ConflictException–The request conflicts with the current state of the resource. For example, the space is being created, updated, or deleted, a space with the same name already exists, or you reused a client token with different parameters. Wait for the space to finish being created, updated, or deleted, or use a different name or client token, and then retry.
-
InternalServerException–The service couldn't process the request because of an internal error. Retry the request.
-
ResourceNotFoundException–The specified resource doesn't exist. Check the IDs in the request.
-
ThrottlingException–The service throttled the request. Retry the request with exponential backoff.
-
ValidationException–The request isn't valid. The
reason,message, andfieldListmembers describe the problem. Fix the request, and then try again. -
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_opensearchmemory/_services/async_open_search_memory.py
1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 | |