t06_github_pr_browsing.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from evaluation.integration_tests.tests.base import BaseIntegrationTest, TestResult
  2. from openhands.events.action import AgentFinishAction, MessageAction
  3. from openhands.events.event import Event
  4. from openhands.events.observation import AgentDelegateObservation
  5. from openhands.runtime.base import Runtime
  6. class Test(BaseIntegrationTest):
  7. INSTRUCTION = 'Look at https://github.com/All-Hands-AI/OpenHands/pull/8, and tell me what is happening there and what did @asadm suggest.'
  8. @classmethod
  9. def initialize_runtime(cls, runtime: Runtime) -> None:
  10. pass
  11. @classmethod
  12. def verify_result(cls, runtime: Runtime, histories: list[Event]) -> TestResult:
  13. # check if the "The answer is OpenHands is all you need!" is in any message
  14. message_actions = [
  15. event
  16. for event in histories
  17. if isinstance(
  18. event, (MessageAction, AgentFinishAction, AgentDelegateObservation)
  19. )
  20. ]
  21. for event in message_actions:
  22. if isinstance(event, AgentDelegateObservation):
  23. content = event.content
  24. elif isinstance(event, AgentFinishAction):
  25. content = event.outputs.get('content', '')
  26. elif isinstance(event, MessageAction):
  27. content = event.content
  28. else:
  29. raise ValueError(f'Unknown event type: {type(event)}')
  30. if (
  31. 'non-commercial' in content
  32. or 'MIT' in content
  33. or 'Apache 2.0' in content
  34. ):
  35. return TestResult(success=True)
  36. return TestResult(
  37. success=False,
  38. reason=f'The answer is not found in any message. Total messages: {len(message_actions)}. Messages: {message_actions}',
  39. )