@@ -91,7 +91,7 @@ Remove a specific exchange from the message history.
9191* ** Return type:**
9292 None
9393
94- #### ` get_recent(top_k=5, as_text=False, raw=False, session_tag=None) `
94+ #### ` get_recent(top_k=5, as_text=False, raw=False, session_tag=None, role=None ) `
9595
9696Retrieve the recent message history in sequential order.
9797
@@ -103,15 +103,19 @@ Retrieve the recent message history in sequential order.
103103 prompt and response
104104 * ** session_tag** (* Optional* * [ * * str* * ] * ) – Tag of the entries linked to a specific
105105 conversation session. Defaults to instance ULID.
106+ * ** role** (* Optional* * [ * * Union* * [ * * str* * ,* * List* * [ * * str* * ] * * ] * * ] * ) – Filter messages by role(s).
107+ Can be a single role string ("system", "user", "llm", "tool") or
108+ a list of roles. If None, all roles are returned.
106109* ** Returns:**
107110 A single string transcription of the session
108111 : or list of strings if as_text is false.
109112* ** Return type:**
110113 Union[ str, List[ str]]
111114* ** Raises:**
112- ** ValueError** – if top_k is not an integer greater than or equal to 0.
115+ ** ValueError** – if top_k is not an integer greater than or equal to 0,
116+ or if role contains invalid values.
113117
114- #### ` get_relevant(prompt, as_text=False, top_k=5, fall_back=False, session_tag=None, raw=False, distance_threshold=None) `
118+ #### ` get_relevant(prompt, as_text=False, top_k=5, fall_back=False, session_tag=None, raw=False, distance_threshold=None, role=None ) `
115119
116120Searches the message history for information semantically related to
117121the specified prompt.
@@ -134,13 +138,17 @@ context to the next LLM call.
134138 if no relevant context is found.
135139 * ** raw** (* bool* ) – Whether to return the full Redis hash entry or just the
136140 message.
141+ * ** role** (* Optional* * [ * * Union* * [ * * str* * ,* * List* * [ * * str* * ] * * ] * * ] * ) – Filter messages by role(s).
142+ Can be a single role string ("system", "user", "llm", "tool") or
143+ a list of roles. If None, all roles are returned.
137144* ** Returns:**
138145 Either a list of strings, or a
139146 list of prompts and responses in JSON containing the most relevant.
140147* ** Return type:**
141148 Union[ List[ str] , List[ Dict[ str,str]]
142149
143- Raises ValueError: if top_k is not an integer greater or equal to 0.
150+ Raises ValueError: if top_k is not an integer greater or equal to 0,
151+ : or if role contains invalid values.
144152
145153#### ` store(prompt, response, session_tag=None) `
146154
@@ -237,7 +245,7 @@ Remove a specific exchange from the conversation history.
237245* ** Return type:**
238246 None
239247
240- #### ` get_recent(top_k=5, as_text=False, raw=False, session_tag=None) `
248+ #### ` get_recent(top_k=5, as_text=False, raw=False, session_tag=None, role=None ) `
241249
242250Retrieve the recent message history in sequential order.
243251
@@ -249,13 +257,17 @@ Retrieve the recent message history in sequential order.
249257 prompt and response.
250258 * ** session_tag** (* Optional* * [ * * str* * ] * ) – Tag of the entries linked to a specific
251259 conversation session. Defaults to instance ULID.
260+ * ** role** (* Optional* * [ * * Union* * [ * * str* * ,* * List* * [ * * str* * ] * * ] * * ] * ) – Filter messages by role(s).
261+ Can be a single role string ("system", "user", "llm", "tool") or
262+ a list of roles. If None, all roles are returned.
252263* ** Returns:**
253264 A single string transcription of the messages
254265 : or list of strings if as_text is false.
255266* ** Return type:**
256267 Union[ str, List[ str]]
257268* ** Raises:**
258- ** ValueError** – if top_k is not an integer greater than or equal to 0.
269+ ** ValueError** – if top_k is not an integer greater than or equal to 0,
270+ or if role contains invalid values.
259271
260272#### ` store(prompt, response, session_tag=None) `
261273
0 commit comments