Skip to content

Commit 274f935

Browse files
neubigGraham Neubig
andauthored
Add SDK-backed OpenHands SFT converter (#241)
* Add SDK-backed OpenHands SFT converter * Normalize SDK SFT records for HF chat templates * Keep SDK dependencies optional for CI * Bump schema version for dataset metadata * Run CI on Python 3.12 for SDK support * Address SDK converter review feedback * Preserve webshop custom click labels --------- Co-authored-by: Graham Neubig <gneubig@users.noreply.github.com>
1 parent d2a19e6 commit 274f935

74 files changed

Lines changed: 14650 additions & 907 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/check_api_docstrings.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Python
2020
uses: actions/setup-python@v5
2121
with:
22-
python-version: '3.11'
22+
python-version: '3.12'
2323

2424
- name: Install ruff
2525
run: |

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Set up Python
1818
uses: actions/setup-python@v4
1919
with:
20-
python-version: '3.10'
20+
python-version: '3.12'
2121
cache: 'pip'
2222

2323
- name: Install dependencies

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [3.11]
14+
python-version: [3.12]
1515

1616
steps:
1717
- uses: actions/checkout@v4

agents/openhands_sdk/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# OpenHands SDK SFT Converter
2+
3+
This converter builds SFT records through OpenHands SDK primitives instead of
4+
manually formatting OpenAI chat messages.
5+
6+
For each standardized trajectory it:
7+
8+
1. Loads dataset `metadata.json`.
9+
2. Registers every metadata `custom_tools` entry as an SDK custom tool.
10+
3. Creates an SDK `Conversation`, letting the SDK construct the system prompt
11+
and tool map.
12+
4. Appends converted standardized actions and observations to the SDK event log.
13+
5. Uses SDK event/message formatting helpers to emit `messages` and `tools`.
14+
15+
Regenerate one dataset with:
16+
17+
```bash
18+
export MY_DATASET=agenttuning_alfworld
19+
export PYTHONPATH=`pwd`:$PYTHONPATH
20+
python scripts/json_to_jsonl.py < datasets/$MY_DATASET/sample_std.json \
21+
| python agents/openhands_sdk/std_to_sft.py \
22+
| python scripts/jsonl_to_json.py \
23+
> datasets/$MY_DATASET/sample_sft/openhands_sdk.json
24+
```

agents/openhands_sdk/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""OpenHands SDK SFT conversion package."""

0 commit comments

Comments
 (0)