Skip to content
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

Add event search endpoint with pagination and filtering #4688

Merged
merged 25 commits into from
Nov 26, 2024

Conversation

tofarr
Copy link
Collaborator

@tofarr tofarr commented Nov 1, 2024

Added Endpoint to get the content of the EventStream via REST

(I think the line above should be included in release notes)

I needed this for debugging. e.g.:

fetch('/api/events/search', {
  headers: {
    'Authorization': 'Bearer YOUR_SESSION_TOKEN'
  }
}).then((response) => {
  response.json().then((content) => {
    console.log(content)
  })
})

Auto Generated by OpenHands

This PR adds a new /api/events/search endpoint that allows searching through the event stream with pagination and filtering capabilities.

Features:

  • Pagination with configurable page size (default 20, max 100)
  • Text search across event content
  • Filter by event type
  • Filter by event source
  • Filter by date range
  • Returns page metadata for navigation

Example usage:

# Basic usage with default pagination
GET /api/events/search

# With text search and custom page size
GET /api/events/search?query=error&page_size=50

# With type filter and date range
GET /api/events/search?event_type=FileReadAction&start_date=2024-01-01T00:00:00

To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:129ff76-nikolaik   --name openhands-app-129ff76   docker.all-hands.dev/all-hands-ai/openhands:129ff76

tofarr and others added 8 commits October 31, 2024 13:21
- Split _initialize_agent into smaller focused methods:
  - _set_loading_state
  - _extract_config_args
  - _configure_llm
  - _start_agent_session

- Split on_event into smaller focused methods:
  - _should_skip_event
  - _is_environment_feedback_event
  - _send_as_agent_event

Each method now has a single responsibility and clear documentation.
@tofarr tofarr marked this pull request as draft November 1, 2024 18:08
AI Assistant and others added 13 commits November 1, 2024 12:10
- Move get_matching_events to EventStream class
- Extract filtering logic to _should_filter_event method
- Change pagination to use stream indices
- Add proper limit validation
- Remove unnecessary total events count
- Improve error handling and documentation
- Add tests for event type filtering
- Add tests for text search functionality
- Add tests for source filtering
- Add tests for pagination
- Add tests for limit validation
- Fix source filtering to use enum value instead of name
…nds-AI/OpenHands into feature/add-event-search-endpoint
@tofarr tofarr marked this pull request as ready for review November 12, 2024 15:01
Copy link
Collaborator

@tobitege tobitege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tofarr tofarr enabled auto-merge (squash) November 26, 2024 17:00
@tofarr tofarr merged commit be6ca4a into main Nov 26, 2024
12 checks passed
@tofarr tofarr deleted the feature/add-event-search-endpoint branch November 26, 2024 17:18
@enyst enyst mentioned this pull request Jan 29, 2025
1 task
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