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: Split feed into two
Kilian Lieret166e11c51c15
diff --git a/sweagent/web/server.py b/sweagent/web/server.pyindex 896d2e90..96855a83 100644--- a/sweagent/web/server.py+++ b/sweagent/web/server.py@@ -3,12 +3,11 @@ from flask import Flask, render_template, requestimport threadingimport sys-from pytest import skipfrom sweagent import CONFIG_DIR, PACKAGE_DIRfrom sweagent.agent.agents import AgentArgumentsfrom sweagent.agent.models import ModelArgumentsfrom sweagent.environment.swe_env import EnvironmentArguments-from flask_socketio import SocketIO, emit+from flask_socketio import SocketIO# baaaaaaadsys.path.append(str(PACKAGE_DIR.parent))@@ -29,16 +28,13 @@ def handle_connect():class WebUpdateRunHook(MainHook):def on_start(self):- print("on start")- emit('update', {'status': 'started'}, namespace="/run")+ socketio.emit('update', {'event': 'started'})def on_end(self):- print("on end")- emit('update', {'status': 'finished'})+ socketio.emit('update', {'event': 'finished'})def on_instance_completed(self, *, info, trajectory):- print("on instance completed")- emit('update', {'status': 'instance_completed', }, namespace="/run")+ socketio.emit('update', {'event': 'instance_completed', **info})@app.route('/run', methods=['GET'])@@ -71,11 +67,10 @@ def run():),actions=ActionsArguments(open_pr=False, skip_if_commits_reference_issue=True),)- WebUpdateRunHook().on_start()- # main = Main(defaults)- # main.add_hook(WebUpdateRunHook())- # thread = threading.Thread(target=main.main)- # thread.start()+ main = Main(defaults)+ main.add_hook(WebUpdateRunHook())+ thread = threading.Thread(target=main.main)+ thread.start()return 'Commands are being executed', 202diff --git a/sweagent/web/static/styles/mainpage.css b/sweagent/web/static/styles/mainpage.cssnew file mode 100644index 00000000..b6e49232--- /dev/null+++ b/sweagent/web/static/styles/mainpage.css@@ -0,0 +1,22 @@+.message {+ border: 1px solid #ccc;+ padding: 10px;+ margin-bottom: 10px;+ border-radius: 5px;+}+++#container {+ display: flex; /* Enables flexbox layout */+ justify-content: space-between; /* Spaces children evenly */+ padding: 10px;+}++#agentFeed, #envFeed {+ flex: 1; /* Each container takes up half the parent width */+ margin: 10px;+ max-width: 50%; /* Optionally limit the feed width */+ overflow-y: auto; /* Adds scroll bar if feed gets too long */+ height: 500px; /* Fixed height for feed */+ border: 1px solid black;+}\ No newline at end of filediff --git a/sweagent/web/templates/index.html b/sweagent/web/templates/index.htmlindex 7e9fedf1..0a3066d6 100644--- a/sweagent/web/templates/index.html+++ b/sweagent/web/templates/index.html@@ -2,14 +2,34 @@<html><head><title>Run Command</title>+ <link rel= "stylesheet" type= "text/css" href= "{{ url_for('static',filename='styles/mainpage.css') }}"><script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.0/socket.io.js"></script><script>+ function addMessageToFeed(feedID, title, text) {+ console.log("in addMessageToFeed");+ const feed = document.getElementById(feedID);+ const messageBlock = document.createElement('div');+ messageBlock.className = 'message';++ const messageTitle = document.createElement('h2');+ messageTitle.textContent = title;++ const messageText = document.createElement('p');+ messageText.textContent = text;++ messageBlock.appendChild(messageTitle);+ messageBlock.appendChild(messageText);++ feed.appendChild(messageBlock);+ }++document.addEventListener('DOMContentLoaded', function() {- const socket = io('/run');-+ const socket = io();socket.on('update', function(data) {console.log("update");- document.getElementById('update').textContent = data+ addMessageToFeed('agentFeed', data["event"], JSON.stringify(data));+ addMessageToFeed('envFeed', data["event"], JSON.stringify(data));});});</script>@@ -39,5 +59,10 @@.catch(error => console.error('Error:', error));});</script>+ <h1>Trajectory</h1>+ <div id="container">+ <div id="agentFeed"></div>+ <div id="envFeed"></div>+ </div></body></html>\ No newline at end of file