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 enh: Control button activity depending on run state
Kilian Lieret9da540233624
diff --git a/sweagent/api/hooks.py b/sweagent/api/hooks.pyindex 94a0d0cb..3f5c5545 100644--- a/sweagent/api/hooks.py+++ b/sweagent/api/hooks.py@@ -40,6 +40,10 @@ class WebUpdate:):"""Update the environment feed"""self._emit('update', {'feed': 'env', 'title': title, 'message': message, 'format': format, 'thought_idx': thought_idx})++ def finish_run(self):+ """Finish the run. We use that to control which buttons are active."""+ self._emit('finish_run', {})@@ -53,6 +57,7 @@ class MainUpdateHook(MainHook):def on_end(self):self._wu.up_agent(message="The run has ended", format="text")+ self._wu.finish_run()def on_instance_completed(self, *, info, trajectory):self._wu.up_agent(message=f"Instance completed")diff --git a/sweagent/api/server.py b/sweagent/api/server.pyindex db34d17b..2cd50ed0 100644--- a/sweagent/api/server.py+++ b/sweagent/api/server.py@@ -86,7 +86,6 @@ def run():test_run = request.args["test_run"].lower() == "true"model_name = "gpt4"if test_run:- print(">>>>>>>>>> test_run")os.environ["SWE_AGENT_EXPERIMENTAL_COMMUNICATE"] = "1"model_name = "instant_empty_submit"env_utils.START_UP_DELAY = 1@@ -119,9 +118,6 @@ def run():thread = MainThread(main)global THREADSTHREADS[session_id] = thread- print("||||||||||||||||||||||||||||||||||||||||||||||")- print(f"Starting session {session_id} with {thread}")- print("||||||||||||||||||||||||||||||||||||||||||||||")thread.start()return 'Commands are being executed', 202diff --git a/sweagent/frontend/src/App.js b/sweagent/frontend/src/App.jsindex c5a5c405..a49f5f92 100644--- a/sweagent/frontend/src/App.js+++ b/sweagent/frontend/src/App.js@@ -14,6 +14,7 @@ function App() {const [envFeed, setEnvFeed] = useState([]);const [highlightedStep, setHighlightedStep] = useState(null);const [logs, setLogs] = useState('');+ const [isComputing, setIsComputing] = useState(false);const agentFeedRef = useRef(null);const envFeedRef = useRef(null);@@ -27,6 +28,7 @@ function App() {// Handle form submissionconst handleSubmit = async (event) => {+ setIsComputing(true);event.preventDefault();setAgentFeed([]);setEnvFeed([]);@@ -40,6 +42,7 @@ function App() {const handleStop = async () => {+ setIsComputing(false);try {const response = await axios.get('/stop');console.log(response.data);@@ -60,12 +63,18 @@ function App() {setLogs(prevLogs => prevLogs + data.message);}+ const handleFinishedRun = (data) => {+ setIsComputing(false);+ }+socket.on('update', handleUpdate);socket.on('log_message', handleLogMessage);+ socket.on('finish_run', handleFinishedRun);return () => {socket.off('update', handleUpdate);socket.off('log_message', handleLogMessage);+ socket.off('finish_run', handleFinishedRun);};}, []);@@ -77,9 +86,9 @@ function App() {<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">Run</button>+ <button type="submit" disabled={isComputing}>Run</button></form>- <button onClick={handleStop}>Stop Computation</button>+ <button onClick={handleStop} disabled={!isComputing}>Stop Computation</button><h2>Trajectory</h2><div id="container"><Feed feed={agentFeed} highlightedStep={highlightedStep} handleMouseEnter={handleMouseEnter} selfRef={agentFeedRef} otherRef={envFeedRef} title="Agent Feed" />