import{_ as i,c as a,o as n,ae as t}from"./chunks/framework.AELpvxz7.js";const y=JSON.parse('{"title":"index","description":"","frontmatter":{"title":"index","order":100,"collapsed":true},"headers":[],"relativePath":"en/dev/api/tools/marshoai_memory/index.md","filePath":"en/dev/api/tools/marshoai_memory/index.md","lastUpdated":null}'),h={name:"en/dev/api/tools/marshoai_memory/index.md"};function e(l,s,k,p,r,o){return n(),a("div",null,s[0]||(s[0]=[t(`

Module nonebot_plugin_marshoai.tools.marshoai_memory


async func write_memory(memory: str, user_id: str)

Source code or View on GitHub
python
async def write_memory(memory: str, user_id: str):
    with open(memory_path, 'r', encoding='utf-8') as f:
        memory_data = json.load(f)
    memorys = memory_data.get(user_id, [])
    memorys.append(memory)
    memory_data[user_id] = memorys
    with open(memory_path, 'w', encoding='utf-8') as f:
        json.dump(memory_data, f, ensure_ascii=False, indent=4)
    return '记忆已经保存啦~'

async func read_memory(user_id: str)

Source code or View on GitHub
python
async def read_memory(user_id: str):
    with open(memory_path, 'r', encoding='utf-8') as f:
        memory_data = json.load(f)
    memorys = memory_data.get(user_id, [])
    if not memorys:
        return '好像对ta还没有任何记忆呢~'
    return '这些是有关ta的记忆:' + '\\n'.join(memorys)

async func organize_memories()

Source code or View on GitHub
python
async def organize_memories():
    with open(memory_path, 'r', encoding='utf-8') as f:
        memory_data = json.load(f)
    for i in memory_data:
        ...
`,10)]))}const E=i(h,[["render",e]]);export{y as __pageData,E as default};