diff --git a/.gitignore b/.gitignore index ca0cf47..57b5179 100644 --- a/.gitignore +++ b/.gitignore @@ -149,5 +149,5 @@ cython_debug/ node_modules/ package-lock.json -/.chainlit +.chainlit/ chainlit.md diff --git a/examples/README.md b/examples/README.md index 98760aa..bcba968 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,6 +10,16 @@ Here we show you how to use isek to quickly build an agent, and how to build an isek setup ``` +## 1️⃣ Set Up Environment + +Create a `.env` file: + +```env +OPENAI_MODEL_NAME=gpt-4o-mini +OPENAI_BASE_URL=https://api.openai.com/v1 +OPENAI_API_KEY=your_api_key +``` + ## 🧪 Understanding how ISEK works - 【LV1】Show you how to build a simple agent diff --git a/examples/UI/chainlit/start_ui.py b/examples/UI/chainlit/start_ui.py index f9e7a6a..2580684 100644 --- a/examples/UI/chainlit/start_ui.py +++ b/examples/UI/chainlit/start_ui.py @@ -101,8 +101,9 @@ def start_server(): try: # Start the server in a subprocess + dirc = os.path.dirname(__file__) server_process = subprocess.Popen([ - sys.executable, "examples/UI/chainlit/agent_server.py" + sys.executable, f"{dirc}/agent_server.py" ], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True) # Wait a moment for server to start time.sleep(3) @@ -130,8 +131,9 @@ def start_chainlit(): try: # Start Chainlit in a subprocess + dirc = os.path.dirname(__file__) chainlit_process = subprocess.Popen([ - sys.executable, "-m", "chainlit", "run", "examples/UI/chainlit/chainlit_app.py" + sys.executable, "-m", "chainlit", "run", f"{dirc}/chainlit_app.py" ]) time.sleep(2) diff --git a/isek/cli.py b/isek/cli.py index 5e811cd..4a94f8d 100644 --- a/isek/cli.py +++ b/isek/cli.py @@ -3,9 +3,22 @@ import importlib.util import subprocess import sys +import shutil +import platform from pathlib import Path +def get_npm_command(): + """ + Returns the available npm executable path on the current platform + (supports Windows, Linux, and macOS). + """ + if platform.system() == "Windows": + return shutil.which("npm.cmd") or shutil.which("npm") + else: + return shutil.which("npm") + + def load_module(script_path: Path): """Dynamically load module""" try: @@ -104,7 +117,9 @@ def is_development_environment(): # Step 2: Check if Node.js is installed try: subprocess.run(["node", "--version"], check=True, capture_output=True) - subprocess.run(["npm", "--version"], check=True, capture_output=True) + subprocess.run( + [get_npm_command(), "--version"], check=True, capture_output=True + ) except (subprocess.CalledProcessError, FileNotFoundError): click.secho( "⚠️ Node.js and npm are required for P2P functionality", fg="yellow" @@ -118,7 +133,7 @@ def is_development_environment(): click.secho("📦 Installing JavaScript dependencies for P2P...", fg="yellow") try: subprocess.check_call( - ["npm", "install"], + [get_npm_command(), "install"], cwd=p2p_dir, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,