Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Inspector: Add some bad syntax higlighting to inspector

Kilian Lieret6a98ba2eae28
diff --git a/sweagent/inspector/fileViewer.js b/sweagent/inspector/fileViewer.js
index 07f09cc8..f7533ffb 100644
--- a/sweagent/inspector/fileViewer.js
+++ b/sweagent/inspector/fileViewer.js
@@ -42,6 +42,7 @@ const roleMap = {
default: "Default",
system: "System",
demo: "Demonstration",
+ model_patch: "Model Patch",
};
function getRoleText(role) {
@@ -110,11 +111,16 @@ function viewFile(fileName) {
</strong>
</div>
<div class="content-container">
- <pre>${contentText}</pre>
+ <pre><code class="language-python">${contentText}</code></pre>
</div>
<div class="shadow"></div>
`;
container.appendChild(historyItem);
+
+ // Highlight the code after adding it to the DOM
+ historyItem.querySelectorAll("pre code").forEach((block) => {
+ hljs.highlightElement(block);
+ });
}, delay);
delay += delayIncrement; // Increment delay for the next message
diff --git a/sweagent/inspector/index.html b/sweagent/inspector/index.html
index 04c1b7b1..48887f7c 100644
--- a/sweagent/inspector/index.html
+++ b/sweagent/inspector/index.html
@@ -2,6 +2,9 @@
<head>
<title>Trajectory Viewer</title>
<link rel="stylesheet" type="text/css" href="style.css">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.min.css">
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/languages/python.min.js"></script>
<script src="fileViewer.js"></script>
</head>
<body>