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]
minor changes for server and client endpoints to better handling cors
Tam Nguyene4b0b9d10d1c
diff --git a/sweagent/frontend/src/App.js b/sweagent/frontend/src/App.jsindex 1ee160a9..359c4423 100644--- a/sweagent/frontend/src/App.js+++ b/sweagent/frontend/src/App.js@@ -3,8 +3,9 @@ import axios from 'axios';import io from 'socket.io-client';import './App.css';+const url = ''; // Will get this from .env// Connect to Socket.io-const socket = io(); // Adjust the URL based on your Flask server+const socket = io(url);function App() {const [dataPath, setDataPath] = useState('https://github.com/klieret/swe-agent-test-repo/issues/1');@@ -14,6 +15,9 @@ function App() {const [envFeed, setEnvFeed] = useState([]);const [highlightedStep, setHighlightedStep] = useState(null);++ axios.defaults.baseURL = url;+const handleMouseEnter = (step) => {setHighlightedStep(step);};diff --git a/sweagent/web/server.py b/sweagent/web/server.pyindex fd62c16f..48146fe9 100644--- a/sweagent/web/server.py+++ b/sweagent/web/server.py@@ -1,6 +1,6 @@import osfrom typing import Optional-from flask import Flask, render_template, request+from flask import Flask, render_template, request, make_responseimport threadingimport sys@@ -113,10 +113,10 @@ class AgentUpdateHook(AgentHook):return self._wu.up_agent(title="Demo", message=content, thought_idx=self._thought_idx + 1)self._wu.up_agent(title="Query", message=content, thought_idx=self._thought_idx + 1)--[email protected]('/run', methods=['GET'])[email protected]('/run', methods=['GET', 'OPTIONS'])def run():+ if request.method == "OPTIONS": # CORS preflight+ return _build_cors_preflight_response()data_path = request.args["data_path"]test_run = request.args["test_run"].lower() == "true"model_name = "gpt4"@@ -155,6 +155,12 @@ def run():thread.start()return 'Commands are being executed', 202+def _build_cors_preflight_response():+ response = make_response()+ response.headers.add("Access-Control-Allow-Origin", "*")+ response.headers.add('Access-Control-Allow-Headers', "*")+ response.headers.add('Access-Control-Allow-Methods', "*")+ return responseif __name__ == "__main__":socketio.run(app, port=5000, debug=True)\ No newline at end of file