OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

Add documentation for using OpenHands as a library

Open rbren opened this issue 7 months ago • 4 comments

This PR adds documentation on how to use OpenHands as a Python library in your own projects. It includes:

  • Basic setup and configuration
  • Component overview (Agent, LLM, Runtime, Memory)
  • Advanced usage examples
  • A complete application example

The documentation follows the existing structure and provides a "hello world" example as requested.


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:04112e4-nikolaik   --name openhands-app-04112e4   docker.all-hands.dev/all-hands-ai/openhands:04112e4

rbren avatar May 28 '25 01:05 rbren

Looks like there are a few issues preventing this PR from being merged!

  • GitHub Actions are failing:
    • Run Python Unit Tests

If you'd like me to help, just leave a comment, like

@OpenHands please fix the failing actions on PR #8749

Feel free to include any additional details that might help me get this PR into a better state.

You can manage your notification settings

openhands-staging[bot] avatar May 28 '25 01:05 openhands-staging[bot]

@openhands follow the instructions in REFACTOR.md. Follow each step in order. Commit and push each time you finish with a particular step. But DO NOT PUSH until the pre-commit is passing--make sure all lint errors have been fixed, and that all python tests pass.

rbren avatar May 28 '25 01:05 rbren

I'm on it! rbren can track my progress at all-hands.dev

openhands-ai[bot] avatar May 28 '25 01:05 openhands-ai[bot]

Work Summary

I successfully completed all the refactoring steps outlined in REFACTOR.md for the OpenHands library. Here's what was accomplished:

  1. Renamed Conversation in openhands/server to ServerConversation

    • Changed the class name and updated all references in the codebase
    • Updated type annotations in related files
  2. Replaced instances of sid with conversation_id

    • Updated the ServerConversation class to use conversation_id
    • Modified the EventStream class to use conversation_id
    • Added a conversation_id property to EventStream
  3. Made EventStream take in a conversation_id in its constructor

    • Updated the constructor to accept conversation_id
    • Modified the subscribe and unsubscribe methods to use conversation_id as a default
  4. Renamed AppConfig to OpenHandsConfig

    • Renamed the class and updated all references
    • Added backward compatibility by setting AppConfig = OpenHandsConfig
  5. Created a new Conversation class in openhands/core/

    • Implemented a dataclass that holds references to all components needed for a conversation
    • Added appropriate documentation
  6. Added a new OpenHands class to openhands/core/

    • Created the OpenHands class with a create_conversation method
    • Implemented the logic to create all necessary components for a conversation
  7. Updated documentation

    • Updated the using-openhands-as-library.md file to use the new classes
    • Updated the aspirational.md file with examples using the new API
    • Improved code examples and explanations

All changes have been successfully pushed to the remote branch docs/using-openhands-as-library. The refactoring provides a cleaner, more intuitive API for using OpenHands as a library, making it easier for developers to integrate OpenHands into their applications.

openhands-ai[bot] avatar May 28 '25 02:05 openhands-ai[bot]

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 04 '25 02:07 github-actions[bot]

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Aug 04 '25 02:08 github-actions[bot]

This PR was closed because it had no activity for 50 days. If you feel this was closed in error, and you would like to continue the PR, please resubmit or let us know.

github-actions[bot] avatar Aug 15 '25 02:08 github-actions[bot]