Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change the port and the localhost to other #7084

Open
Iamasdf opened this issue Apr 16, 2024 · 1 comment
Open

how to change the port and the localhost to other #7084

Iamasdf opened this issue Apr 16, 2024 · 1 comment

Comments

@Iamasdf
Copy link

Iamasdf commented Apr 16, 2024

I have try to chane the "autogpts/autogpt/.env“ AP_SERVER_CORS_ALLOWED_ORIGINS= 0.0.0.0 or a LAN IP . I also chane the AP_SERVER_PORT to 8090, howevery how many times I have change this setting.after I reboot my server an ./run agent start a_agent_name .
the result alway
8888888888
888
888
8888888 .d88b. 888d888 .d88b. .d88b.
888 d88""88b 888P" d88P"88b d8P Y8b
888 888 888 888 888 888 88888888
888 Y88..88P 888 Y88b 888 Y8b.
888 "Y88P" 888 "Y88888 "Y8888
888
Y8b d88P
"Y88P" v0.1.0

[2024-04-16 23:06:31,070] [main ] [INFO] 📝 Agent server starting on http://localhost:8000
✅ Agent application started and available on port 8000

I can't not chage the binding ip and port at all.

then I try to change the code in "/autogpts/autogpt/autogpt/app/agent_protocol_server.py"
class AgentProtocolServer:
_task_budgets: dict[str, ModelProviderBudget]

def __init__(
    self,
    app_config: Config,
    database: AgentDB,
    file_storage: FileStorage,
    llm_provider: ChatModelProvider,
):
    self.app_config = app_config
    self.db = database
    self.file_storage = file_storage
    self.llm_provider = llm_provider
    self.agent_manager = AgentManager(file_storage)
    self._task_budgets = {}

async def start(self, port: int = 8009, router: APIRouter = base_router):
    """Start the agent server."""
    logger.debug("Starting the agent server...")
    if not is_port_free(port):
        logger.error(f"Port {port} is already in use.")
        logger.info(
            "You can specify a port by either setting the AP_SERVER_PORT "
            "environment variable or defining AP_SERVER_PORT in the .env file."
        )
        return

    config = HypercornConfig()
    config.bind = [f"localhost:{port}"]
    app = FastAPI(
        title="AutoGPT Server",
        description="Forked from AutoGPT Forge; "
        "Modified version of The Agent Protocol.",
        version="v0.4",
    )

    # Configure CORS middleware
    default_origins = [f"http://192.168.0.100:{port}"]  # Default only local access
    configured_origins = [
        origin
        for origin in os.getenv("AP_SERVER_CORS_ALLOWED_ORIGINS", "").split(",")
        if origin  # Empty list if not configured
    ]
    origins = configured_origins or default_origins

    app.add_middleware(
        CORSMiddleware,
        allow_origins=origins,
        allow_credentials=True,
        allow_methods=["*"],
        allow_headers=["*"],
    )

I have chane the default_origins = [f"http://192.168.0.100:{port}"] and async def start(self, port: int = 8009, router: APIRouter = base_router):
I reboot system and start autoGpt again. it never change the binding Ip and port

@NHPT
Copy link

NHPT commented May 1, 2024

change host="localhost" of autogpts/<YOUR_AGENT_NAME>/forge/__main__.py,example:

$ vim ./autogpts/<YOUR_AGENT_NAME>/forge/__main__.py
uvicorn.run(
        "forge.app:app",
        host="0.0.0.0",
        port=int(port),
        log_level="error",
        # Reload on changes to code or .env
        reload=True,
        reload_dirs=os.path.dirname(os.path.dirname(__file__)),
        reload_excludes="*.py",  # Cancel default *.py include pattern
        reload_includes=[
            f"{os.path.basename(os.path.dirname(__file__))}/**/*.py",
            ".*",
            ".env",
        ],
    )
$ ./run agent start YOUR_AGENT_NAME

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants