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]

Web WIP: Split up message types

Kilian Lieretb6585c6f26c0
diff --git a/sweagent/api/hooks.py b/sweagent/api/hooks.py
index e51021a2..1eba11d9 100644
--- a/sweagent/api/hooks.py
+++ b/sweagent/api/hooks.py
@@ -34,12 +34,12 @@ class WebUpdate:
def up_env(
self,
message: str,
+ type_: str,
format: str = "markdown",
- title="",
thought_idx: Optional[int] =None,
):
"""Update the environment feed"""
- self._emit('update', {'feed': 'env', 'title': title, 'message': message, 'format': format, 'thought_idx': thought_idx})
+ self._emit('update', {'feed': 'env', 'message': message, 'format': format, 'thought_idx': thought_idx, 'type': type_})
def finish_run(self):
"""Finish the run. We use that to control which buttons are active."""
@@ -53,7 +53,7 @@ class MainUpdateHook(MainHook):
self._wu = wu
def on_start(self):
- self._wu.up_env(message="Environment container initialized", format="text")
+ self._wu.up_env(message="Environment container initialized", format="text", type_="info")
def on_end(self):
self._wu.up_agent(message="The run has ended", format="text")
@@ -81,14 +81,14 @@ class AgentUpdateHook(AgentHook):
def on_sub_action_started(self, *, sub_action: dict):
msg = f"```bash\n{sub_action['action']}\n```"
self._sub_action = sub_action["action"].strip()
- self._wu.up_env(message=msg, title=f"Action", thought_idx=self._thought_idx)
+ self._wu.up_env(message=msg, thought_idx=self._thought_idx, type_="command")
def on_sub_action_executed(self, *, obs: str, done: bool):
language = ""
if self._sub_action == "submit":
language = "diff"
msg = f"```{language}\n{obs}\n```"
- self._wu.up_env(message=msg, thought_idx=self._thought_idx)
+ self._wu.up_env(message=msg, thought_idx=self._thought_idx, type_="output")
def on_query_message_added(
self,
diff --git a/sweagent/frontend/src/App.js b/sweagent/frontend/src/App.js
index d330c815..cb101bcc 100644
--- a/sweagent/frontend/src/App.js
+++ b/sweagent/frontend/src/App.js
@@ -85,8 +85,12 @@ function App() {
// Use effect to listen to socket updates
React.useEffect(() => {
const handleUpdate = (data) => {
- const updateFeed = data.feed === 'agent' ? setAgentFeed : setEnvFeed;
- updateFeed(prevMessages => [...prevMessages, { title: data.title, message: data.message, format: data.format, step: data.thought_idx }]);
+ if (data.feed === 'agent') {
+ setAgentFeed(prevMessages => [...prevMessages, { title: data.title, message: data.message, format: data.format, step: data.thought_idx }]);
+ }
+ else if (data.feed === "env") {
+ setEnvFeed(prevMessages => [...prevMessages, { message: data.message, type: data.type, format: data.format, step: data.thought_idx }]);
+ }
};
const handleLogMessage = (data) => {
@@ -117,18 +121,16 @@ function App() {
return (
<div>
- <h1>Start run</h1>
- <form onSubmit={handleSubmit}>
- <label htmlFor="data_path">Data Path:</label>
- <input type="text" value={dataPath} onChange={(e) => setDataPath(e.target.value)} required />
- <label htmlFor="test_run">Test run (no LM queries)</label>
- <input type="checkbox" checked={testRun} onChange={(e) => setTestRun(e.target.checked)} />
- <button type="submit" disabled={isComputing}>Run</button>
- </form>
- <button onClick={handleStop} disabled={!isComputing}>Stop Computation</button>
- <h2>Trajectory</h2>
<div className="container-demo">
<hr />
+ <form onSubmit={handleSubmit}>
+ <label htmlFor="data_path">Data Path:</label>
+ <input type="text" value={dataPath} onChange={(e) => setDataPath(e.target.value)} required />
+ <label htmlFor="test_run">Test run (no LM queries)</label>
+ <input type="checkbox" checked={testRun} onChange={(e) => setTestRun(e.target.checked)} />
+ <button type="submit" disabled={isComputing}>Run</button>
+ </form>
+ <button onClick={handleStop} disabled={!isComputing}>Stop Computation</button>
<div id="demo">
<hr />
<div className="panels">
diff --git a/sweagent/frontend/src/components/MacBar.js b/sweagent/frontend/src/components/MacBar.js
index 0e694599..5863d72b 100644
--- a/sweagent/frontend/src/components/MacBar.js
+++ b/sweagent/frontend/src/components/MacBar.js
@@ -4,7 +4,7 @@ import PropTypes from "prop-types"; // Import PropTypes for type checking
import ExpandIcon from "./utils/icons/ExpandIcon";
import "../static/macbar.css";
-import Message from './Message';
+import Message from './AgentMessage';
const MacBar = ({
setIsTyping,
diff --git a/sweagent/frontend/src/components/Message.js b/sweagent/frontend/src/components/Message.js
deleted file mode 100644
index c5532d65..00000000
--- a/sweagent/frontend/src/components/Message.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import React from 'react';
-
-import "../static/message.css";
-
-const Message = ({ item, handleMouseEnter, isHighlighted, feedRef }) => {
- const stepClass = item.step !== null ? `step${item.step}` : '';
- const highlightClass = isHighlighted ? 'highlight' : '';
-
- return (
- <div
- className={`message ${item.format} ${stepClass} ${highlightClass}`}
- onMouseEnter={() => handleMouseEnter(item, feedRef)}
- >
- <h4>{item.title}</h4>
- <span>{item.message}</span>
- </div>
- );
-};
-
-export default Message;
\ No newline at end of file
diff --git a/sweagent/frontend/src/components/panels/AgentFeed.js b/sweagent/frontend/src/components/panels/AgentFeed.js
index 90dfb37a..0d7d67c9 100644
--- a/sweagent/frontend/src/components/panels/AgentFeed.js
+++ b/sweagent/frontend/src/components/panels/AgentFeed.js
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Message from '../Message';
+import Message from '../AgentMessage';
import workspaceLogo from '../../assets/panel_icons/workspace.png';
diff --git a/sweagent/frontend/src/components/panels/EnvFeed.js b/sweagent/frontend/src/components/panels/EnvFeed.js
index 1f649780..6f5b488f 100644
--- a/sweagent/frontend/src/components/panels/EnvFeed.js
+++ b/sweagent/frontend/src/components/panels/EnvFeed.js
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Message from '../Message';
+import EnvMessage from '../EnvMessage';
import MacBar from '../MacBar';
import terminalLogo from '../../assets/panel_icons/terminal.png';
@@ -31,7 +31,7 @@ const EnvFeed = ({ feed, id, title, highlightedStep, handleMouseEnter, selfRef,
<div className="scrollableDiv" ref={selfRef} >
<div className="innerDiv">
{feed.map((item, index) => (
- <Message
+ <EnvMessage
key={index}
item={item}
handleMouseEnter={handleMouseEnter}
diff --git a/sweagent/frontend/src/components/panels/LogPanel.js b/sweagent/frontend/src/components/panels/LogPanel.js
index c6ac54d7..f0e04249 100644
--- a/sweagent/frontend/src/components/panels/LogPanel.js
+++ b/sweagent/frontend/src/components/panels/LogPanel.js
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
-import Message from '../Message';
+import Message from '../AgentMessage';
import MacBar from '../MacBar';
import editorLogo from '../../assets/panel_icons/editor.png';
diff --git a/sweagent/frontend/src/static/message.css b/sweagent/frontend/src/static/message.css
index 7ec3ece0..4bf87990 100644
--- a/sweagent/frontend/src/static/message.css
+++ b/sweagent/frontend/src/static/message.css
@@ -1,10 +1,6 @@
.message {
- background-color: #eee;
- border-radius: 0 1em 1em 1em;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
- padding: 0.25em 1em;
- }
-
- .highlight {
- background-color: #eac2c2;
- }
\ No newline at end of file
+}
+
+.highlight {
+ background-color: #eac2c2;
+}
\ No newline at end of file