66
77# Import message types from core types module
88from memos .log import get_logger
9- from memos .types import MessageDict , PermissionDict , SearchMode
9+ from memos .types import MessageList , MessagesType , PermissionDict , SearchMode
1010
1111
1212logger = get_logger (__name__ )
@@ -56,7 +56,7 @@ class Message(BaseModel):
5656
5757class MemoryCreate (BaseRequest ):
5858 user_id : str = Field (..., description = "User ID" )
59- messages : list | None = Field (None , description = "List of messages to store." )
59+ messages : MessageList | None = Field (None , description = "List of messages to store." )
6060 memory_content : str | None = Field (None , description = "Content to store as memory" )
6161 doc_path : str | None = Field (None , description = "Path to document to store" )
6262 mem_cube_id : str | None = Field (None , description = "ID of the memory cube" )
@@ -83,7 +83,7 @@ class ChatRequest(BaseRequest):
8383 writable_cube_ids : list [str ] | None = Field (
8484 None , description = "List of cube IDs user can write for multi-cube chat"
8585 )
86- history : list | None = Field (None , description = "Chat history" )
86+ history : MessageList | None = Field (None , description = "Chat history" )
8787 mode : SearchMode = Field (SearchMode .FAST , description = "search mode: fast, fine, or mixture" )
8888 system_prompt : str | None = Field (None , description = "Base system prompt to use for chat" )
8989 top_k : int = Field (10 , description = "Number of results to return" )
@@ -165,7 +165,7 @@ class ChatCompleteRequest(BaseRequest):
165165 user_id : str = Field (..., description = "User ID" )
166166 query : str = Field (..., description = "Chat query message" )
167167 mem_cube_id : str | None = Field (None , description = "Cube ID to use for chat" )
168- history : list | None = Field (None , description = "Chat history" )
168+ history : MessageList | None = Field (None , description = "Chat history" )
169169 internet_search : bool = Field (False , description = "Whether to use internet search" )
170170 system_prompt : str | None = Field (None , description = "Base prompt to use for chat" )
171171 top_k : int = Field (10 , description = "Number of results to return" )
@@ -251,7 +251,7 @@ class MemoryCreateRequest(BaseRequest):
251251 """Request model for creating memories."""
252252
253253 user_id : str = Field (..., description = "User ID" )
254- messages : str | list | None = Field (None , description = "List of messages to store." )
254+ messages : str | MessagesType | None = Field (None , description = "List of messages to store." )
255255 memory_content : str | None = Field (None , description = "Memory content to store" )
256256 doc_path : str | None = Field (None , description = "Path to document to store" )
257257 mem_cube_id : str | None = Field (None , description = "Cube ID" )
@@ -326,6 +326,21 @@ class APISearchRequest(BaseRequest):
326326 ),
327327 )
328328
329+ search_tool_memory : bool = Field (
330+ True ,
331+ description = (
332+ "Whether to retrieve tool memories along with general memories. "
333+ "If enabled, the system will automatically recall tool memories "
334+ "relevant to the query. Default: True."
335+ ),
336+ )
337+
338+ tool_mem_top_k : int = Field (
339+ 6 ,
340+ ge = 0 ,
341+ description = "Number of tool memories to retrieve (top-K). Default: 6." ,
342+ )
343+
329344 # ==== Filter conditions ====
330345 # TODO: maybe add detailed description later
331346 filter : dict [str , Any ] | None = Field (
@@ -360,7 +375,7 @@ class APISearchRequest(BaseRequest):
360375 )
361376
362377 # ==== Context ====
363- chat_history : list | None = Field (
378+ chat_history : MessageList | None = Field (
364379 None ,
365380 description = (
366381 "Historical chat messages used internally by algorithms. "
@@ -490,7 +505,7 @@ class APIADDRequest(BaseRequest):
490505 )
491506
492507 # ==== Input content ====
493- messages : str | list | None = Field (
508+ messages : MessagesType | None = Field (
494509 None ,
495510 description = (
496511 "List of messages to store. Supports: "
@@ -506,7 +521,7 @@ class APIADDRequest(BaseRequest):
506521 )
507522
508523 # ==== Chat history ====
509- chat_history : list | None = Field (
524+ chat_history : MessageList | None = Field (
510525 None ,
511526 description = (
512527 "Historical chat messages used internally by algorithms. "
@@ -636,7 +651,7 @@ class APIFeedbackRequest(BaseRequest):
636651 "default_session" , description = "Session ID for soft-filtering memories"
637652 )
638653 task_id : str | None = Field (None , description = "Task ID for monitering async tasks" )
639- history : list [ MessageDict ] | None = Field (..., description = "Chat history" )
654+ history : MessageList | None = Field (..., description = "Chat history" )
640655 retrieved_memory_ids : list [str ] | None = Field (
641656 None , description = "Retrieved memory ids at last turn"
642657 )
@@ -670,7 +685,7 @@ class APIChatCompleteRequest(BaseRequest):
670685 writable_cube_ids : list [str ] | None = Field (
671686 None , description = "List of cube IDs user can write for multi-cube chat"
672687 )
673- history : list | None = Field (None , description = "Chat history" )
688+ history : MessageList | None = Field (None , description = "Chat history" )
674689 mode : SearchMode = Field (SearchMode .FAST , description = "search mode: fast, fine, or mixture" )
675690 system_prompt : str | None = Field (None , description = "Base system prompt to use for chat" )
676691 top_k : int = Field (10 , description = "Number of results to return" )
@@ -739,7 +754,7 @@ class SuggestionRequest(BaseRequest):
739754 user_id : str = Field (..., description = "User ID" )
740755 mem_cube_id : str = Field (..., description = "Cube ID" )
741756 language : Literal ["zh" , "en" ] = Field ("zh" , description = "Language for suggestions" )
742- message : list | None = Field (None , description = "List of messages to store." )
757+ message : MessagesType | None = Field (None , description = "List of messages to store." )
743758
744759
745760# ─── MemOS Client Response Models ──────────────────────────────────────────────
0 commit comments