Spaces:
Sleeping
Sleeping
Commit
·
00a3b3a
1
Parent(s):
dfabb80
Final
Browse files- Dockerfile +1 -1
- src/__pycache__/app.cpython-313.pyc +0 -0
- src/app.py +1 -4
- src/codeagent/src/codeagent/main.py +15 -12
Dockerfile
CHANGED
|
@@ -24,7 +24,7 @@ RUN apt-get update && apt-get install -y \
|
|
| 24 |
COPY requirements.txt ./
|
| 25 |
COPY src/ ./src/
|
| 26 |
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
| 27 |
-
COPY frontend/app/dist/ /app/
|
| 28 |
|
| 29 |
RUN python3 -m venv /opt/venv
|
| 30 |
ENV PATH="/opt/venv/bin:$PATH"
|
|
|
|
| 24 |
COPY requirements.txt ./
|
| 25 |
COPY src/ ./src/
|
| 26 |
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
| 27 |
+
COPY frontend/app/dist/ ./frontend/app/dist/
|
| 28 |
|
| 29 |
RUN python3 -m venv /opt/venv
|
| 30 |
ENV PATH="/opt/venv/bin:$PATH"
|
src/__pycache__/app.cpython-313.pyc
CHANGED
|
Binary files a/src/__pycache__/app.cpython-313.pyc and b/src/__pycache__/app.cpython-313.pyc differ
|
|
|
src/app.py
CHANGED
|
@@ -14,10 +14,7 @@ from flask_socketio import SocketIO, emit
|
|
| 14 |
|
| 15 |
event_queue = queue.Queue()
|
| 16 |
|
| 17 |
-
|
| 18 |
-
app = Flask(__name__, static_folder='static', static_url_path='/')
|
| 19 |
-
else:
|
| 20 |
-
app = Flask(__name__, static_folder='../frontend/app/dist', static_url_path='/')
|
| 21 |
|
| 22 |
socketio = SocketIO(app, cors_allowed_origins="*")
|
| 23 |
|
|
|
|
| 14 |
|
| 15 |
event_queue = queue.Queue()
|
| 16 |
|
| 17 |
+
app = Flask(__name__, static_folder='../frontend/app/dist', static_url_path='/')
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
socketio = SocketIO(app, cors_allowed_origins="*")
|
| 20 |
|
src/codeagent/src/codeagent/main.py
CHANGED
|
@@ -15,20 +15,19 @@ from app import socketio
|
|
| 15 |
# from codeagent.src.codeagent.crews.git_crew.git_crew import GitCrew
|
| 16 |
from codeagent.src.codeagent.crews.SqlCrew.sqlcrew import SqlCrew
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
class SocketWriter(
|
| 21 |
def __init__(self, emit_func):
|
| 22 |
self.emit = emit_func
|
| 23 |
-
super().__init__(None, write_through=True)
|
| 24 |
|
| 25 |
-
def write(self,
|
| 26 |
-
if
|
| 27 |
-
self.emit(
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
class FlowState(BaseModel):
|
| 34 |
user_input: str = ""
|
|
@@ -77,9 +76,13 @@ class CodeAgentFlow(Flow[FlowState]):
|
|
| 77 |
# self.state.result = result.raw
|
| 78 |
pass
|
| 79 |
elif self.state.decision == "SqlCrew":
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
else:
|
| 84 |
self.state.result = f"Invalid decision from router: {self.state.decision}"
|
| 85 |
|
|
|
|
| 15 |
# from codeagent.src.codeagent.crews.git_crew.git_crew import GitCrew
|
| 16 |
from codeagent.src.codeagent.crews.SqlCrew.sqlcrew import SqlCrew
|
| 17 |
|
| 18 |
+
import io
|
| 19 |
|
| 20 |
+
class SocketWriter(io.TextIOBase):
|
| 21 |
def __init__(self, emit_func):
|
| 22 |
self.emit = emit_func
|
|
|
|
| 23 |
|
| 24 |
+
def write(self, s):
|
| 25 |
+
if s.strip():
|
| 26 |
+
self.emit("log", {'msg': s.strip()})
|
| 27 |
+
return len(s)
|
| 28 |
|
| 29 |
+
def flush(self):
|
| 30 |
+
pass
|
| 31 |
|
| 32 |
class FlowState(BaseModel):
|
| 33 |
user_input: str = ""
|
|
|
|
| 76 |
# self.state.result = result.raw
|
| 77 |
pass
|
| 78 |
elif self.state.decision == "SqlCrew":
|
| 79 |
+
old_stdout = sys.stdout
|
| 80 |
+
sys.stdout = SocketWriter(lambda event, data: socketio.emit(event, data))
|
| 81 |
+
try:
|
| 82 |
+
result = SqlCrew().crew().kickoff(inputs={"task": self.state.user_input})
|
| 83 |
+
self.state.result = result.raw
|
| 84 |
+
finally:
|
| 85 |
+
sys.stdout = old_stdout
|
| 86 |
else:
|
| 87 |
self.state.result = f"Invalid decision from router: {self.state.decision}"
|
| 88 |
|