-
Notifications
You must be signed in to change notification settings - Fork 28
Add startup scripts for server and client on macOS/Linux and Windows #728
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
087df03
Add startup scripts for server and client on macOS/Linux and Windows
makkzone 8805068
Merge branch 'cognizant-ai-lab:main' into main
makkzone 165cf45
updated based on PR review comments
makkzone cf25970
Merge branch 'main' of https://github.com/makkzone/neuro-san
makkzone aca2238
Merge branch 'cognizant-ai-lab:main' into main
makkzone 5ee0562
Merge branch 'main' into main
d1donlydfink 48c0ceb
Merge branch 'main' into main
d1donlydfink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| # Neuro-SAN Startup Scripts | ||
|
|
||
| This folder contains easy-to-use startup scripts for launching the Neuro-SAN server and client on different operating systems. | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Quick Start | ||
|
|
||
| ### macOS / Linux | ||
|
|
||
| **Start the server:** | ||
| ```bash | ||
| chmod +x startup/start-server.sh | ||
| ./startup/start-server.sh | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| **Start the client (in another terminal):** | ||
| ```bash | ||
| chmod +x startup/start-client.sh | ||
| ./startup/start-client.sh | ||
| ``` | ||
|
|
||
| ### Windows | ||
|
|
||
| **Start the server:** | ||
| ```cmd | ||
| startup\start-server.bat | ||
| ``` | ||
|
|
||
| **Start the client (in another terminal):** | ||
| ```cmd | ||
| startup\start-client.bat | ||
| ``` | ||
|
|
||
| ## What These Scripts Do | ||
|
|
||
| ### Server Scripts (`start-server.sh` / `start-server.bat`) | ||
|
|
||
| 1. ✅ Check for virtual environment (create if missing) | ||
| 2. ✅ Activate virtual environment | ||
| 3. ✅ Set PYTHONPATH | ||
| 4. ✅ Install dependencies (if not already installed) | ||
| 5. ✅ Enable CORS headers (for web applications) | ||
| 6. ✅ Check for API keys (warns if missing) | ||
| 7. ✅ Start the Neuro-SAN server on port 8080 | ||
|
|
||
| ### Client Scripts (`start-client.sh` / `start-client.bat`) | ||
|
|
||
| 1. ✅ Activate virtual environment | ||
| 2. ✅ Set PYTHONPATH | ||
| 3. ✅ Start the CLI client with specified agent | ||
|
|
||
| ## Client Usage | ||
|
|
||
| ### Direct Mode (No Server Required) | ||
| ```bash | ||
| # macOS/Linux | ||
| ./startup/start-client.sh hello_world | ||
|
|
||
| # Windows | ||
| startup\start-client.bat hello_world | ||
| ``` | ||
|
|
||
| ### Server Mode (Connects to Running Server) | ||
| ```bash | ||
| # macOS/Linux | ||
| ./startup/start-client.sh hello_world --http | ||
|
|
||
| # Windows | ||
| startup\start-client.bat hello_world --http | ||
| ``` | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Available Agents | ||
|
|
||
| Based on the server logs, you can use any of these agents: | ||
| - `hello_world` - Simple greeting agent (default) | ||
| - `copy_cat` - Echo agent | ||
| - `math_guy` - Math operations | ||
| - `date_time` - Current date and time | ||
| - `music_nerd` - Music-related queries | ||
| - `gist` - Terse announcements | ||
| - And many more... | ||
d1donlydfink marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Environment Variables | ||
|
|
||
| ### Required | ||
| - `OPENAI_API_KEY` - Your OpenAI API key | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Optional | ||
| - `AGENT_HTTP_PORT` - Server port (default: 8080) | ||
| - `AGENT_SERVER_NAME` - Server name for health reporting | ||
| - Other provider API keys (AWS, Azure, Anthropic, etc.) | ||
d1donlydfink marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ### Setting Environment Variables | ||
|
|
||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| **macOS/Linux:** | ||
| ```bash | ||
| export OPENAI_API_KEY="your-key-here" | ||
| ``` | ||
|
|
||
| **Windows:** | ||
| ```cmd | ||
| set OPENAI_API_KEY=your-key-here | ||
| ``` | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Port Already in Use | ||
| If you see "Address already in use" error: | ||
| ```bash | ||
| # macOS/Linux | ||
| lsof -i :8080 | ||
| kill <PID> | ||
|
|
||
| # Windows | ||
| netstat -ano | findstr :8080 | ||
| taskkill /PID <PID> /F | ||
| ``` | ||
|
|
||
| ### Virtual Environment Issues | ||
| Delete the `.venv` or `venv` folder and run the script again to recreate it. | ||
|
|
||
| ### Missing Dependencies | ||
| The scripts automatically install dependencies, but you can manually run: | ||
| ```bash | ||
| pip install -r requirements.txt | ||
| ``` | ||
|
|
||
| ## Server Endpoints | ||
|
|
||
| Once the server is running: | ||
| - **Server URL:** http://localhost:8080 | ||
| - **Health Check:** http://localhost:8080/health | ||
| - **API endpoints:** See the OpenAPI spec for details | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Stopping the Server | ||
|
|
||
| Press `Ctrl+C` in the terminal where the server is running. | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| @echo off | ||
| REM Neuro-SAN Client Startup Script for Windows | ||
| REM This script starts the neuro-san CLI client | ||
|
|
||
| setlocal enabledelayedexpansion | ||
|
|
||
| echo =============================================== | ||
| echo Neuro-SAN Client Startup | ||
| echo =============================================== | ||
| echo. | ||
|
|
||
| REM Get the directory where this script is located | ||
| set SCRIPT_DIR=%~dp0 | ||
| set PROJECT_DIR=%SCRIPT_DIR%.. | ||
| cd /d "%PROJECT_DIR%" | ||
|
|
||
| REM Activate virtual environment | ||
| if exist ".venv" ( | ||
| set VENV_DIR=.venv | ||
| ) else if exist "venv" ( | ||
| set VENV_DIR=venv | ||
| ) else ( | ||
| echo Virtual environment not found! | ||
| echo Please run start-server.bat first to set up the environment. | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| echo Activating virtual environment... | ||
| call "%VENV_DIR%\Scripts\activate.bat" | ||
| if errorlevel 1 ( | ||
| echo Failed to activate virtual environment | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| echo Virtual environment activated | ||
| echo. | ||
|
|
||
| REM Set PYTHONPATH | ||
| set PYTHONPATH=%PROJECT_DIR% | ||
|
|
||
| REM Get agent name from command line argument or use default | ||
| set AGENT_NAME=%1 | ||
| if "%AGENT_NAME%"=="" set AGENT_NAME=hello_world | ||
|
|
||
| REM Check if connecting to server or running direct | ||
| if "%2"=="--server" goto server_mode | ||
| if "%2"=="--http" goto server_mode | ||
| goto direct_mode | ||
|
|
||
| :server_mode | ||
| echo Connecting to server mode... | ||
| echo Make sure the server is running (start-server.bat) | ||
| echo. | ||
| python -m neuro_san.client.agent_cli --http --agent %AGENT_NAME% | ||
| goto end | ||
|
|
||
| :direct_mode | ||
| echo Running in direct mode (no server)... | ||
| echo. | ||
| python -m neuro_san.client.agent_cli --agent %AGENT_NAME% | ||
|
|
||
| :end | ||
| pause |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Neuro-SAN Client Startup Script for macOS/Linux | ||
| # This script starts the neuro-san CLI client | ||
|
|
||
| set -e | ||
|
|
||
| echo "===============================================" | ||
| echo " Neuro-SAN Client Startup" | ||
| echo "===============================================" | ||
| echo "" | ||
|
|
||
| # Get the directory where this script is located | ||
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
| PROJECT_DIR="$(dirname "$SCRIPT_DIR")" | ||
|
|
||
| cd "$PROJECT_DIR" | ||
|
|
||
| # Activate virtual environment | ||
| if [ -d ".venv" ]; then | ||
| VENV_DIR=".venv" | ||
| elif [ -d "venv" ]; then | ||
| VENV_DIR="venv" | ||
| else | ||
| echo "❌ Virtual environment not found!" | ||
| echo "Please run start-server.sh first to set up the environment." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Activating virtual environment..." | ||
| source "$VENV_DIR/bin/activate" | ||
| echo "✅ Virtual environment activated" | ||
| echo "" | ||
|
|
||
| # Set PYTHONPATH | ||
| export PYTHONPATH="$PROJECT_DIR" | ||
|
|
||
| # Get agent name from command line argument or use default | ||
| AGENT_NAME="${1:-hello_world}" | ||
|
|
||
| # Check if connecting to server or running direct | ||
| if [ "$2" = "--server" ] || [ "$2" = "--http" ]; then | ||
| echo "Connecting to server mode..." | ||
| echo "Make sure the server is running (start-server.sh)" | ||
| echo "" | ||
| python -m neuro_san.client.agent_cli --http --agent "$AGENT_NAME" | ||
| else | ||
| echo "Running in direct mode (no server)..." | ||
| echo "" | ||
| python -m neuro_san.client.agent_cli --agent "$AGENT_NAME" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| @echo off | ||
| REM Neuro-SAN Server Startup Script for Windows | ||
| REM This script handles all necessary steps to launch the neuro-san server | ||
|
|
||
| setlocal enabledelayedexpansion | ||
|
|
||
| echo =============================================== | ||
| echo Neuro-SAN Server Startup | ||
| echo =============================================== | ||
| echo. | ||
|
|
||
| REM Get the directory where this script is located | ||
| set SCRIPT_DIR=%~dp0 | ||
| set PROJECT_DIR=%SCRIPT_DIR%.. | ||
| cd /d "%PROJECT_DIR%" | ||
|
|
||
| echo Project directory: %PROJECT_DIR% | ||
| echo. | ||
|
|
||
| REM Check if virtual environment exists | ||
| if not exist "venv" if not exist ".venv" ( | ||
| echo Virtual environment not found! | ||
| echo Creating virtual environment... | ||
| python -m venv .venv | ||
| if errorlevel 1 ( | ||
| echo Failed to create virtual environment | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| echo Virtual environment created | ||
| echo. | ||
| ) | ||
|
|
||
| REM Activate virtual environment | ||
| if exist ".venv" ( | ||
| set VENV_DIR=.venv | ||
| ) else ( | ||
| set VENV_DIR=venv | ||
| ) | ||
|
|
||
| echo Activating virtual environment... | ||
| call "%VENV_DIR%\Scripts\activate.bat" | ||
| if errorlevel 1 ( | ||
| echo Failed to activate virtual environment | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| echo Virtual environment activated | ||
| echo. | ||
|
|
||
| REM Set PYTHONPATH | ||
| set PYTHONPATH=%PROJECT_DIR% | ||
| echo PYTHONPATH set to: %PYTHONPATH% | ||
| echo. | ||
|
|
||
| REM Check if dependencies are installed | ||
| echo Checking dependencies... | ||
| python -c "import neuro_san" 2>nul | ||
| if errorlevel 1 ( | ||
| echo Installing dependencies... | ||
| pip install -r requirements.txt | ||
| if errorlevel 1 ( | ||
| echo Failed to install dependencies | ||
| pause | ||
| exit /b 1 | ||
| ) | ||
| echo Dependencies installed | ||
| ) else ( | ||
| echo Dependencies already installed | ||
| ) | ||
| echo. | ||
|
|
||
| REM Check for API keys | ||
| if not defined OPENAI_API_KEY ( | ||
| echo WARNING: OPENAI_API_KEY environment variable is not set! | ||
| echo Some features may not work without API keys. | ||
| echo Set it with: set OPENAI_API_KEY=your-key-here | ||
| echo. | ||
| ) | ||
makkzone marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| REM Enable CORS headers for web applications | ||
| set AGENT_ALLOW_CORS_HEADERS=1 | ||
| echo CORS headers enabled | ||
| echo. | ||
|
|
||
| REM Start the server | ||
| echo =============================================== | ||
| echo Starting Neuro-SAN Server on port 8080 | ||
| echo =============================================== | ||
| echo. | ||
| echo Server will be available at: http://localhost:8080 | ||
| echo Press Ctrl+C to stop the server | ||
| echo. | ||
|
|
||
| python -m neuro_san.service.main_loop.server_main_loop | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.