Add documentation for using OpenHands as a library
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
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 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.
I'm on it! rbren can track my progress at all-hands.dev
Work Summary
I successfully completed all the refactoring steps outlined in REFACTOR.md for the OpenHands library. Here's what was accomplished:
-
Renamed
Conversationin openhands/server toServerConversation- Changed the class name and updated all references in the codebase
- Updated type annotations in related files
-
Replaced instances of
sidwithconversation_id- Updated the ServerConversation class to use conversation_id
- Modified the EventStream class to use conversation_id
- Added a conversation_id property to EventStream
-
Made EventStream take in a
conversation_idin its constructor- Updated the constructor to accept conversation_id
- Modified the subscribe and unsubscribe methods to use conversation_id as a default
-
Renamed AppConfig to OpenHandsConfig
- Renamed the class and updated all references
- Added backward compatibility by setting AppConfig = OpenHandsConfig
-
Created a new
Conversationclass in openhands/core/- Implemented a dataclass that holds references to all components needed for a conversation
- Added appropriate documentation
-
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
-
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.
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.
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.
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.