.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "tutorial/task_memory.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_tutorial_task_memory.py: .. _memory: Memory ======================== In AgentScope, the memory is used to store the context of the agent, and retrieve it when needed. Specifically, AgentScope provides a memory base class ``MemoryBase`` and an in-memory implementation ``InMemoryMemory`` under ``agentscope.memory`` that can be used directly. Customize Memory ~~~~~~~~~~~~~~~~~~~~~~~~ To customize your own memory, just inherit from ``MemoryBase`` and implement the following methods: .. list-table:: :header-rows: 1 * - Method - Description * - ``add`` - Add ``Msg`` objects to the memory * - ``delete`` - Delete items from the memory * - ``size`` - The size of the memory * - ``clear`` - Clear the memory content * - ``get_memory`` - Get the memory content as a list of ``Msg`` objects * - ``state_dict`` - Get the state dictionary of the memory * - ``load_state_dict`` - Load the state dictionary of the memory Further Reading ~~~~~~~~~~~~~~~~~~~~~~~~ - :ref:`long-term-memory` .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_tutorial_task_memory.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: task_memory.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: task_memory.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: task_memory.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_