GET
/
api
/
v1
/
users
/
context
/
{user_id}
# To use the Python SDK, install the package:
# pip install memobase

from memobase import Memobase

client = Memobase(project_url='PROJECT_URL', api_key='PROJECT_TOKEN')

context = u.context()
{
  "data": {
    "context": "<string>"
  },
  "errno": 0,
  "errmsg": ""
}

Return a string of the user’s personalized context you can directly insert it into your prompt.

Format:

<memory>
# Below is the user profile:
{profile}

# Below is the latest events of the user:
{event}
</memory>
Please provide your answer using the information within the <memory> tag at the appropriate time.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

user_id
string
required

The ID of the user

Query Parameters

max_token_size
integer
default:1000

Max token size of returned Context

prefer_topics
string[]

Rank prefer topics at first to try to keep them in filtering, default order is by updated time

only_topics
string[]

Only return profiles with these topics, default is all

max_subtopic_size
integer

Max subtopic size of the same topic in returned Context

topic_limits_json
string

Set specific subtopic limits for topics in JSON, for example {"topic1": 3, "topic2": 5}. The limits in this param will override max_subtopic_size.

profile_event_ratio
number
default:0.8

Profile event ratio of returned Context

Response

200
application/json
Successful Response
data
object | null

Response containing user context

errno
enum<integer>

Error code, 0 means success

Available options:
0,
400,
401,
403,
404,
405,
409,
422,
500,
501,
502,
503,
504
errmsg
string
default:

Error message, empty when success