qgallouedec HF Staff commited on
Commit
a4bf183
·
verified ·
1 Parent(s): 63912b1

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +22 -9
index.html CHANGED
@@ -1,3 +1,10 @@
 
 
 
 
 
 
 
1
 
2
  <div style="padding-bottom: 20px;">
3
  <div id="trl_diff" style="width: 100%; height: 400px; border: 1px solid grey;"></div>
@@ -23,23 +30,29 @@
23
  paths: { vs: "https://unpkg.com/monaco-editor@latest/min/vs" }
24
  });
25
 
 
 
26
  require(["vs/editor/editor.main"], function () {
27
- const diffEditor = monaco.editor.createDiffEditor(
28
  document.getElementById("trl_diff"),
29
- {
30
- readOnly: true,
31
- automaticLayout: true
32
- }
33
  );
 
 
 
 
 
 
 
34
 
35
  Promise.all([
36
- fetch("https://raw.githubusercontent.com/huggingface/trl/main/trl/trainer/grpo_trainer.py").then(r => r.text()),
37
- fetch("https://raw.githubusercontent.com/huggingface/trl/main/trl/trainer/rloo_trainer.py").then(r => r.text())
38
  ]).then(([originalTxt, modifiedTxt]) => {
39
  diffEditor.setModel({
40
  original: monaco.editor.createModel(originalTxt, "python"),
41
  modified: monaco.editor.createModel(modifiedTxt, "python")
42
  });
43
  });
44
- });
45
- </script>
 
1
+ <div style="padding-bottom: 10px; display: flex; gap: 10px; align-items: center;">
2
+ <input id="original_url" type="text" placeholder="Original file URL" style="flex: 1; padding: 6px; font-size: 13px;"
3
+ value="https://raw.githubusercontent.com/huggingface/trl/main/trl/trainer/grpo_trainer.py" />
4
+ <input id="modified_url" type="text" placeholder="Modified file URL" style="flex: 1; padding: 6px; font-size: 13px;"
5
+ value="https://raw.githubusercontent.com/huggingface/trl/main/trl/trainer/rloo_trainer.py" />
6
+ <button onclick="loadDiff()" style="padding: 6px 14px; font-size: 13px;">Load</button>
7
+ </div>
8
 
9
  <div style="padding-bottom: 20px;">
10
  <div id="trl_diff" style="width: 100%; height: 400px; border: 1px solid grey;"></div>
 
30
  paths: { vs: "https://unpkg.com/monaco-editor@latest/min/vs" }
31
  });
32
 
33
+ let diffEditor;
34
+
35
  require(["vs/editor/editor.main"], function () {
36
+ diffEditor = monaco.editor.createDiffEditor(
37
  document.getElementById("trl_diff"),
38
+ { readOnly: true, automaticLayout: true }
 
 
 
39
  );
40
+ loadDiff();
41
+ });
42
+
43
+ function loadDiff() {
44
+ const originalUrl = document.getElementById("original_url").value.trim();
45
+ const modifiedUrl = document.getElementById("modified_url").value.trim();
46
+ if (!diffEditor || !originalUrl || !modifiedUrl) return;
47
 
48
  Promise.all([
49
+ fetch(originalUrl).then(r => r.text()),
50
+ fetch(modifiedUrl).then(r => r.text())
51
  ]).then(([originalTxt, modifiedTxt]) => {
52
  diffEditor.setModel({
53
  original: monaco.editor.createModel(originalTxt, "python"),
54
  modified: monaco.editor.createModel(modifiedTxt, "python")
55
  });
56
  });
57
+ }
58
+ </script>