Skip to content

feat: filter messages by ID #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2025
Merged

Conversation

alex-mcgovern
Copy link
Contributor

@alex-mcgovern alex-mcgovern commented Mar 4, 2025

While integrating the pagination changes in #1020 I realised that we need the ability to find specific messages for display in the UI. Previously we just filtered the entire set, but after adding pagination to this endpoint, that is no longer possible.

This PR adds a filter_by_ids param to GET /v1/workspaces/:name/messages, which accepts a list of IDs to filter by. I thought about GET /v1/workspaces/:name/messages/:id — but I think given the semi-complex logic of parsing disparate prompts & outputs and matching them to messages, this might be simpler, as well as allowing other opportunities to find specific messages and highlight them in the dashboard at a later point.

Examples

Without filtering:

curl -s "http://localhost:8989/api/v1/workspaces/default/messages?page=1&page_size=2" | jq '[.data[].chat_id]'
[
  "aa85b6a5-423a-4cd0-a27f-51088b5fe30c",
  "5ac437ff-6b1c-4aa4-b276-d43bce33f28e"
]

Filtering by a single ID:

curl -s "http://localhost:8989/api/v1/workspaces/default/messages?page=1&page_size=2&filter_by_ids=aa85b6a5-423a-4cd0-a27f-51088b5fe30c" | jq '[.data[].chat_id]'
[
  "aa85b6a5-423a-4cd0-a27f-51088b5fe30c"
]

Filtering by multiple IDs:

curl -s "http://localhost:8989/api/v1/workspaces/default/messages?page=1&page_size=2&filter_by_ids=aa85b6a5-423a-4cd0-a27f-51088b5fe30c&filter_by_ids=5ac437ff-6b1c-4aa4-b276-d43bce33f28e" | jq '[.data[].chat_id]'
[
  "aa85b6a5-423a-4cd0-a27f-51088b5fe30c",
  "5ac437ff-6b1c-4aa4-b276-d43bce33f28e"
]

Filtering by non-existent ID:

curl -s "http://localhost:8989/api/v1/workspaces/default/messages?page=1&page_size=2&filter_by_ids=2
F2FDF94-429D-45E4-9D61-DFA4DB3E6D2F" | jq
{
  "data": [],
  "limit": 2,
  "offset": 0,
  "total": 63
}

@alex-mcgovern alex-mcgovern merged commit a6c9e76 into issue-1020 Mar 4, 2025
@alex-mcgovern alex-mcgovern deleted the feat/filter-messages-by-id branch March 4, 2025 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants