Asynchronous Insert/Flush

Memobase offers asynchronous operations for inserting and flushing data. This allows for improved performance and responsiveness by offloading these tasks to background processes.

When you perform an async insert or flush, the data is not immediately processed. Instead, it’s queued for later processing.

By doing so, the memory process won’t block your Apps, and you can just leave it to Memobase to handle the data.

SDK Examples

Here are some examples of how to switch between sync and async insert/flush in our SDKs:

from memobase import MemoBaseClient
from memobase.core.blob import ChatBlob

client = MemoBaseClient(project_url='PROJECT_URL', api_key='PROJECT_TOKEN')
u = client.get_user(uid)

# Async insert (default)
b = ChatBlob(messages=[
    {
        "role": "user",
        "content": "Hi, I'm here again"
    },
    {
        "role": "assistant",
        "content": "Hi, Gus! How can I help you?"
    }
])
bid = u.insert(b)

# Async flush (default)
u.flush()

# Sync flush (wait for completion)
u.flush(sync=True)

For detailed API, refer to flush and insert.

Asynchronous Insert/Flush

Memobase offers asynchronous operations for inserting and flushing data. This allows for improved performance and responsiveness by offloading these tasks to background processes.

When you perform an async insert or flush, the data is not immediately processed. Instead, it’s queued for later processing.

By doing so, the memory process won’t block your Apps, and you can just leave it to Memobase to handle the data.

SDK Examples

Here are some examples of how to switch between sync and async insert/flush in our SDKs:

from memobase import MemoBaseClient
from memobase.core.blob import ChatBlob

client = MemoBaseClient(project_url='PROJECT_URL', api_key='PROJECT_TOKEN')
u = client.get_user(uid)

# Async insert (default)
b = ChatBlob(messages=[
    {
        "role": "user",
        "content": "Hi, I'm here again"
    },
    {
        "role": "assistant",
        "content": "Hi, Gus! How can I help you?"
    }
])
bid = u.insert(b)

# Async flush (default)
u.flush()

# Sync flush (wait for completion)
u.flush(sync=True)

For detailed API, refer to flush and insert.