Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. @mkdir -p logs
  32. @rm -f logs/pipe
  33. @mkfifo logs/pipe
  34. @cat logs/pipe | (make start-backend) &
  35. @echo 'test' | tee logs/pipe | (make start-frontend)
  36. # Setup config.toml
  37. setup-config:
  38. @echo "Setting up config.toml..."
  39. @read -p "Enter your LLM Model name (see docs.litellm.ai/docs/providers for full list) [default: $(DEFAULT_MODEL)]: " llm_model; \
  40. llm_model=$${llm_model:-$(DEFAULT_MODEL)}; \
  41. echo "LLM_MODEL=\"$$llm_model\"" >> $(CONFIG_FILE).tmp
  42. @read -p "Enter your LLM API key: " llm_api_key; \
  43. echo "LLM_API_KEY=\"$$llm_api_key\"" >> $(CONFIG_FILE).tmp
  44. @read -p "Enter your workspace directory [default: $(DEFAULT_WORKSPACE_DIR)]: " workspace_dir; \
  45. workspace_dir=$${workspace_dir:-$(DEFAULT_WORKSPACE_DIR)}; \
  46. echo "WORKSPACE_DIR=\"$$workspace_dir\"" >> $(CONFIG_FILE).tmp
  47. @mv $(CONFIG_FILE).tmp $(CONFIG_FILE)
  48. # Help
  49. help:
  50. @echo "Usage: make [target]"
  51. @echo "Targets:"
  52. @echo " build - Build project, including environment setup and dependencies."
  53. @echo " start-backend - Start the backend server for the OpenDevin project."
  54. @echo " start-frontend - Start the frontend server for the OpenDevin project."
  55. @echo " run - Run the OpenDevin application, starting both backend and frontend servers."
  56. @echo " Backend Log file will be stored in the 'logs' directory."
  57. @echo " setup-config - Setup the configuration for OpenDevin by providing LLM API key, LLM Model name, and workspace directory."
  58. @echo " help - Display this help message, providing information on available targets."
  59. # Phony targets
  60. .PHONY: install start-backend start-frontend run setup-config help