Skip to content

Commit 936f453

Browse files
committed
fix(py sdk): context time_range_in_days param (#136)
1 parent c76b4fd commit 936f453

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/client/memobase/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
from .core.async_entry import AsyncMemoBaseClient, AsyncUser
55

66
__author__ = "memobase.io"
7-
__version__ = "0.0.25"
7+
__version__ = "0.0.26"
88
__url__ = "https://github.com/memodb-io/memobase"
99
__license__ = "Apache-2.0"

src/client/memobase/core/async_entry.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ async def context(
341341
chats: list[OpenAICompatibleMessage] = None,
342342
event_similarity_threshold: float = None,
343343
customize_context_prompt: str = None,
344+
time_range_in_days: int = None,
344345
full_profile_and_only_search_event: bool = None,
345346
fill_window_with_events: bool = None,
346347
) -> str:
@@ -375,6 +376,8 @@ async def context(
375376
params += (
376377
f"&customize_context_prompt={quote_plus(customize_context_prompt)}"
377378
)
379+
if time_range_in_days:
380+
params += f"&time_range_in_days={time_range_in_days}"
378381
if full_profile_and_only_search_event is not None:
379382
params += f"&full_profile_and_only_search_event={'true' if full_profile_and_only_search_event else 'false'}"
380383
if fill_window_with_events is not None:

src/client/memobase/core/entry.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -319,32 +319,32 @@ def search_event_by_tags(
319319
) -> list[UserEventData]:
320320
"""
321321
Search user events by tags.
322-
322+
323323
Args:
324324
tags: List of tag names that events must have (AND condition)
325325
tag_values: Dict of tag=value pairs for exact matches (AND condition)
326326
topk: Number of events to retrieve, default is 10
327-
327+
328328
Examples:
329329
- search_event_by_tags(tags=["emotion", "romance"])
330330
Returns events that have both 'emotion' AND 'romance' tags (with any value)
331-
331+
332332
- search_event_by_tags(tag_values={"emotion": "happy", "topic": "work"})
333333
Returns events where emotion tag equals 'happy' AND topic tag equals 'work'
334-
334+
335335
- search_event_by_tags(tags=["emotion"], tag_values={"topic": "work"})
336336
Returns events that have 'emotion' tag (any value) AND topic tag equals 'work'
337337
"""
338338
params = f"?topk={topk}"
339-
339+
340340
if tags:
341341
tags_str = ",".join(tags)
342342
params += f"&tags={tags_str}"
343-
343+
344344
if tag_values:
345345
tag_values_str = ",".join([f"{k}={v}" for k, v in tag_values.items()])
346346
params += f"&tag_values={tag_values_str}"
347-
347+
348348
r = unpack_response(
349349
self.project_client.client.get(
350350
f"/users/event_tags/search/{self.user_id}{params}"
@@ -364,6 +364,7 @@ def context(
364364
chats: list[OpenAICompatibleMessage] = None,
365365
event_similarity_threshold: float = None,
366366
customize_context_prompt: str = None,
367+
time_range_in_days: int = None,
367368
full_profile_and_only_search_event: bool = None,
368369
fill_window_with_events: bool = None,
369370
) -> str:
@@ -380,6 +381,8 @@ def context(
380381
params += f"&topic_limits_json={json.dumps(topic_limits)}"
381382
if profile_event_ratio:
382383
params += f"&profile_event_ratio={profile_event_ratio}"
384+
if time_range_in_days:
385+
params += f"&time_range_in_days={time_range_in_days}"
383386
if require_event_summary is not None:
384387
params += (
385388
f"&require_event_summary={'true' if require_event_summary else 'false'}"

0 commit comments

Comments
 (0)