Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Makefile for OpenDevin project
  2. # Variables
  3. DOCKER_IMAGE = ghcr.io/opendevin/sandbox
  4. BACKEND_PORT = 3000
  5. BACKEND_HOST = "127.0.0.1:$(BACKEND_PORT)"
  6. FRONTEND_PORT = 3001
  7. DEFAULT_WORKSPACE_DIR = "./workspace"
  8. DEFAULT_MODEL = "gpt-4-0125-preview"
  9. CONFIG_FILE = config.toml
  10. # Build
  11. build:
  12. @echo "Building project..."
  13. @echo "Pulling Docker image..."
  14. @docker pull $(DOCKER_IMAGE)
  15. @echo "Installing Python dependencies..."
  16. @python -m pip install pipenv
  17. @python -m pipenv install -v
  18. @echo "Setting up frontend environment..."
  19. @cd frontend && npm install
  20. # Start backend
  21. start-backend:
  22. @echo "Starting backend..."
  23. @python -m pipenv run uvicorn opendevin.server.listen:app --port $(BACKEND_PORT)
  24. # Start frontend
  25. start-frontend:
  26. @echo "Starting frontend..."
  27. @cd frontend && BACKEND_HOST=$(BACKEND_HOST) FRONTEND_PORT=$(FRONTEND_PORT) npm run start
  28. # Run the app
  29. run:
  30. @echo "Running the app..."
  31. @if [ "$(OS)" == "Windows_NT" ]; then \
  32. echo "`make run` is not supported on Windows. Please run `make start-frontend` and `make start-backend` separately."; \
  33. exit 1; \
  34. fi
  35. @mkdir -p logs
  36. @rm -f logs/pipe
  37. @mkfifo logs/pipe
  38. @cat logs/pipe | (make start-backend) &
  39. @echo 'test' | tee logs/pipe | (make start-frontend)
  40. # Setup config.toml
  41. setup-config:
  42. @echo "Setting up config.toml..."
  43. @read -p "Enter your LLM Model name (see docs.litellm.ai/docs/providers for full list) [default: $(DEFAULT_MODEL)]: " llm_model; \
  44. llm_model=$${llm_model:-$(DEFAULT_MODEL)}; \
  45. echo "LLM_MODEL=\"$$llm_model\"" >> $(CONFIG_FILE).tmp
  46. @read -p "Enter your LLM API key: " llm_api_key; \
  47. echo "LLM_API_KEY=\"$$llm_api_key\"" >> $(CONFIG_FILE).tmp
  48. @read -p "Enter your workspace directory [default: $(DEFAULT_WORKSPACE_DIR)]: " workspace_dir; \
  49. workspace_dir=$${workspace_dir:-$(DEFAULT_WORKSPACE_DIR)}; \
  50. echo "WORKSPACE_DIR=\"$$workspace_dir\"" >> $(CONFIG_FILE).tmp
  51. @mv $(CONFIG_FILE).tmp $(CONFIG_FILE)
  52. # Help
  53. help:
  54. @echo "Usage: make [target]"
  55. @echo "Targets:"
  56. @echo " build - Build project, including environment setup and dependencies."
  57. @echo " start-backend - Start the backend server for the OpenDevin project."
  58. @echo " start-frontend - Start the frontend server for the OpenDevin project."
  59. @echo " run - Run the OpenDevin application, starting both backend and frontend servers."
  60. @echo " Backend Log file will be stored in the 'logs' directory."
  61. @echo " setup-config - Setup the configuration for OpenDevin by providing LLM API key, LLM Model name, and workspace directory."
  62. @echo " help - Display this help message, providing information on available targets."
  63. # Phony targets
  64. .PHONY: install start-backend start-frontend run setup-config help