v1

latestOpenAPI 3.1.02026-07-173045128.2 KB
context

Get User Context

get/api/v1/users/context/{user_id}

Path parameters

string uuid4 required
OR
string uuid5 required

The ID of the user

Query parameters

max_token_sizeinteger

Max token size of returned Context

Max token size of returned Context

prefer_topicsstring[]

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

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

only_topicsstring[]

Only return profiles with these topics, default is all

Only return profiles with these topics, default is all

max_subtopic_sizeinteger

Max subtopic size of the same topic in returned Context

Max subtopic size of the same topic in returned Context

topic_limits_jsonstring

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

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_rationumber

Profile event ratio of returned Context

Profile event ratio of returned Context

require_event_summaryboolean

Whether to require event summary in returned Context

Whether to require event summary in returned Context

chats_strstring

Pass the recent chats to enable context search. Memobase will use those chats to search for relevant events. It's a list of chats in OpenAI Message format, for example: [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi"}].

NOTICE

  • It will increase your latency by 0.1-1 seconds, because Memobase will use Embedding to search for relevant profiles and events.
  • It will cost your Memobase tokens, roughly 100~200 tokens per chat based on the profile size.
  • The profiles in the context will not be searched by the chats_str.
  • If you want also search profiles, see full_profile_and_only_search_event query parameter.

Pass the recent chats to enable context search. Memobase will use those chats to search for relevant events. It's a list of chats in OpenAI Message format, for example: [{"role": "user", "content": "Hello"}, {"role": "assistant", "content": "Hi"}].

NOTICE

  • It will increase your latency by 0.1-1 seconds, because Memobase will use Embedding to search for relevant profiles and events.
  • It will cost your Memobase tokens, roughly 100~200 tokens per chat based on the profile size.
  • The profiles in the context will not be searched by the chats_str.
  • If you want also search profiles, see full_profile_and_only_search_event query parameter.
event_similarity_thresholdnumber

Event similarity threshold of returned Context

Event similarity threshold of returned Context

time_range_in_daysinteger

Only allow events within the past few days, default is 180

Only allow events within the past few days, default is 180

customize_context_promptstring

Customize context prompt template.

  • use {profile_section} to refer to the profile section
  • use {event_section} to refer to the event section

For example:

# Memory
Unless the user has relevant queries, do not actively mention those memories in the conversation.
## User Background:
{profile_section}

## Latest Events:
{event_section}

Customize context prompt template.

  • use {profile_section} to refer to the profile section
  • use {event_section} to refer to the event section

For example:

# Memory
Unless the user has relevant queries, do not actively mention those memories in the conversation.
## User Background:
{profile_section}

## Latest Events:
{event_section}
full_profile_and_only_search_eventboolean

If you pass chats_str and set this to False, Memobase will search for relevant profiles and events at the same time. NOTICE

  • It will increase your latency by 2-5(based on the profile size) seconds, because Memobase will use LLM and Embedding to search for relevant profiles and events.
  • It will cost your Memobase tokens, roughly 100~1000 tokens per chat based on the profile size.

If you pass chats_str and set this to False, Memobase will search for relevant profiles and events at the same time. NOTICE

  • It will increase your latency by 2-5(based on the profile size) seconds, because Memobase will use LLM and Embedding to search for relevant profiles and events.
  • It will cost your Memobase tokens, roughly 100~1000 tokens per chat based on the profile size.
fill_window_with_eventsboolean

If set to True, Memobase will fill the token window with the rest events.

If set to True, Memobase will fill the token window with the rest events.

Response

Successful Response

errno0 | 400 | 401 | 403 | 404 | 405 | 409 | 422 | 500 | 501 | 502 | 503 | 504 | 520
errmsgstring

Error message, empty when success