mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2026-01-31 11:54:30 +01:00
Updated forge to server the frontend again
This commit is contained in:
@@ -72,11 +72,11 @@
|
||||
|
||||
Your agent can started using the `./run agent start YOUR_AGENT_NAME`
|
||||
|
||||
This will build the frontend, install the dependencies and then start the agent on `http://localhost:8000/`
|
||||
This start the agent on `http://localhost:8000/`
|
||||
|
||||

|
||||
|
||||
The frontend can be accessed from `http://localhost:5000/`(follow the README.md in the frontend folder to spin up the UI), you will first need to login using either a google account or your github account.
|
||||
The frontend can be accessed from `http://localhost:8000/`, you will first need to login using either a google account or your github account.
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import asyncio
|
||||
import os
|
||||
from uuid import uuid4
|
||||
import pathlib
|
||||
|
||||
from fastapi import APIRouter, FastAPI, UploadFile
|
||||
from fastapi.responses import RedirectResponse
|
||||
@@ -56,12 +57,19 @@ class Agent:
|
||||
)
|
||||
|
||||
app.include_router(router, prefix="/ap/v1")
|
||||
# app.mount("/app", StaticFiles(directory="../../frontend/build/web"), name="app")
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
frontend_path = pathlib.Path(os.path.join(script_dir, "../../../../frontend/build/web")).resolve()
|
||||
|
||||
if os.path.exists(frontend_path):
|
||||
app.mount("/app", StaticFiles(directory=frontend_path), name="app")
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def root():
|
||||
return RedirectResponse(url='/app/index.html', status_code=307)
|
||||
else:
|
||||
LOG.warning(f"Frontend not found. {frontend_path} does not exist. The frontend will not be served")
|
||||
app.add_middleware(AgentMiddleware, agent=self)
|
||||
|
||||
@app.get("/", include_in_schema=False)
|
||||
async def root():
|
||||
return RedirectResponse(url='/app/index.html', status_code=307)
|
||||
|
||||
|
||||
config.loglevel = "ERROR"
|
||||
config.bind = [f"0.0.0.0:{port}"]
|
||||
|
||||
6
cli.py
6
cli.py
@@ -264,15 +264,9 @@ def start(agent_name):
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
agent_dir = os.path.join(script_dir, f"autogpts/{agent_name}")
|
||||
frontend_dir = os.path.join(script_dir, "frontend")
|
||||
frontend_build = os.path.join(frontend_dir, "build.sh")
|
||||
run_command = os.path.join(agent_dir, "run")
|
||||
if os.path.exists(agent_dir) and os.path.isfile(run_command):
|
||||
subprocess.Popen([frontend_build], cwd=frontend_dir)
|
||||
os.chdir(agent_dir)
|
||||
if os.name == 'nt':
|
||||
click.echo(click.style("😞 The script cannot be run on Windows.", fg="red"))
|
||||
return
|
||||
subprocess.Popen(["./run"], cwd=agent_dir)
|
||||
click.echo(f"Agent '{agent_name}' started")
|
||||
elif not os.path.exists(agent_dir):
|
||||
|
||||
Reference in New Issue
Block a user