Commit 11a8514
committed
feat(messagehistory): add role filtering to getRecent() method (#349)
Implements role-based filtering for message retrieval, allowing users to filter
messages by role type (system, user, llm, tool) when querying conversation history.
Changes:
- Add validateRoles() method to BaseMessageHistory for role validation
- Update getRecent() signature to accept optional role parameter
- Support single role string or List<String> of multiple roles
- Implement role filtering in MessageHistory using Filter.tag() combinations
- Maintain backward compatibility with existing getRecent() calls
Tests:
- Add RoleFilteringTest with 15 unit tests for validation logic
- Add RoleFilteringIntegrationTest with 15 integration tests
- Test single role, multiple roles, null role, and error cases
- Test role filtering with top_k, session_tag, raw, and asText parameters
Python reference: PR #387 - Role filtering for message history
Ported from: tests/integration/test_role_filter_get_recent.py1 parent 4938e12 commit 11a8514
File tree
4 files changed
+726
-5
lines changed- core/src
- main/java/com/redis/vl/extensions/messagehistory
- test/java/com/redis/vl/extensions/messagehistory
4 files changed
+726
-5
lines changedLines changed: 64 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | | - | |
| 65 | + | |
| 66 | + | |
60 | 67 | | |
61 | | - | |
| 68 | + | |
| 69 | + | |
62 | 70 | | |
63 | 71 | | |
64 | 72 | | |
| |||
117 | 125 | | |
118 | 126 | | |
119 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
120 | 182 | | |
121 | 183 | | |
122 | 184 | | |
| |||
Lines changed: 37 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
114 | 127 | | |
115 | 128 | | |
116 | | - | |
| 129 | + | |
| 130 | + | |
117 | 131 | | |
118 | 132 | | |
119 | 133 | | |
120 | 134 | | |
121 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
122 | 139 | | |
123 | 140 | | |
124 | 141 | | |
| |||
131 | 148 | | |
132 | 149 | | |
133 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
134 | 168 | | |
135 | 169 | | |
136 | | - | |
| 170 | + | |
137 | 171 | | |
138 | 172 | | |
139 | 173 | | |
| |||
0 commit comments