Skip to content

Commit

Permalink
Merge pull request #73 from filip-michalsky/more_python_compat
Browse files Browse the repository at this point in the history
python compatibility + migrate to poetry + installation instructions + dependencies clean up
  • Loading branch information
filip-michalsky authored Dec 10, 2023
2 parents 17af7d3 + 879c6f1 commit df1d3fb
Show file tree
Hide file tree
Showing 12 changed files with 4,444 additions and 104 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
OPENAI_API_KEY="xx"
OTHER_API_KEY="yy"
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,45 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
experimental: [false]
python-version: ["3.8", "3.9", "3.10", "3.11"] # Testing across multiple Python versions
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
cache: 'pip'
cache-dependency-path: 'requirements*'
- name: check OS

- name: Check OS
run: cat /etc/os-release
- name: Install dependencies

- name: Install/upgrade Python setup tools
run: python3 -m pip install --upgrade pip setuptools wheel

- name: Install additional system dependencies
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends git make gcc
- name: Install/upgrade Python setup deps
run: python3 -m pip install --upgrade pip setuptools wheel
- name: Install dev requirements
- name: Install Poetry
run: |
pip install -r requirements-dev.txt
- name: Install SalesGPT
pip install poetry
- name: Configure Poetry
run: |
poetry config virtualenvs.create false
- name: Install dependencies using Poetry
run: |
python3 -m pip install .
python3 setup.py egg_info
- name: Unit tests
poetry install
- name: Run Unit Tests
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: |
export OPENAI_API_KEY=$OPENAI_API_KEY
make test
make test # Executing tests with Poetry
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
!.github/workflows

*.log
**.env
.DS_Store
Expand Down Expand Up @@ -194,4 +196,4 @@ internal/*
*_pitch.npy
*_phoneme.npy
wandb
depot/*
depot/*
100 changes: 100 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Project Setup Instructions

## Introduction

This CONTRIBUTING document provides instructions for setting up your development environment for our project. It includes steps for creating a virtual environment, installing Python, using Poetry for dependency management, and cloning the project from GitHub and running a trial of our project.

## Why Use a Virtual Environment?

A virtual environment is a self-contained directory that holds a specific version of Python and various packages. Using a virtual environment allows you to manage dependencies for different projects separately, avoiding conflicts and ensuring consistency across development setups.

## Prerequisites

- Access to a command-line interface (Terminal for Mac, Command Prompt or PowerShell for Windows)
- Internet connection

### 1. Installing Python

If you do not have Python 3.8 or higher, or would like a separate Python version for this project, follow these steps to download and install it. You can download and install a new version of Python without overwriting your current version. Python supports having multiple versions installed on the same system.

#### For Windows:

- Download the Installer: Go to the official Python website and download the installer for the new Python version.
- Run the Installer: Launch the installer. Be sure to select the option to “Customize installation”.
- Choose a Different Directory: During the installation process, specify a different installation directory than the one used by your current Python version.
- Update the Environment Variables (Optional): If you want to use the new Python version as the default in your command line, you can update the PATH environment variable to point to the new installation.

#### For Mac:

- Download Python: Visit the official Python website and download the desired Python versions.
- Install Python: Open the downloaded installer and follow the instructions.
- Verify Installations: Open Terminal and check the installations by typing `python3.x --version`, where `3.x` corresponds to the version numbers you've installed.

### 2. Creating a Virtual Environment

#### For Windows:

- Open Command Prompt or PowerShell.
- Navigate to your project directory: `cd path\to\your\project`
- Create a virtual environment: `python -m venv env`
- Activate the virtual environment: `.\env\Scripts\activate`

#### For Mac:

- Open Terminal.
- Navigate to your project directory: `cd path/to/your/project`
- Create a virtual environment: `python3 -m venv env`
- Activate the virtual environment: `source env/bin/activate`

### 3. Installing Poetry

Poetry is a tool for dependency management and packaging in Python.

#### For Windows and Mac:

- Ensure your virtual environment is active.
- Make sure you have the latest version of pip using: `pip install -U pip setuptools`
- Install Poetry by running: `pip install poetry`

### 4. Cloning the GitHub Repository

To clone the project repository:

- Ensure git is installed on your system. If not, download and install from git-scm.com.
- Navigate to the directory where you want to clone the repository.
- Clone the repository: `git clone https://github.com/filip-michalsky/SalesGPT.git`.

### 5. Installing Dependencies with Poetry

Dependencies must be installed to ensure all necessary libraries and packages are available for the project.

#### For Windows and Mac:

- Run `poetry install` in the project directory.
- This command reads the `pyproject.toml` file and installs all listed dependencies.

### 6. Setting Up Environment Variables

Environment variables, including API keys, are crucial for the project's configuration and security.

#### For Windows and Mac:

- Create a `.env` file in the project root.
- Use the `.env.example` file as a template.
- Add your API keys and other necessary variables, following the example's format.
- This step ensures that your personal and project-specific configurations are correctly set up.

### 7. Running Tests with Pytest

Running tests is essential for ensuring the integrity and functionality of the code.

#### For Windows and Mac:

- Execute `make test` in the command line.
- This command runs all test cases in the project.
- Ensure there are no failures; warnings can be ignored.
- Successful test runs indicate that the setup and project code are functioning correctly.

## Conclusion

You now have a complete setup for developing the project, including dependency management and testing. Always activate the virtual environment before working on the project.
34 changes: 33 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# Define shell to use
#SHELL := /bin/bash

# Define Python interpreter
#PYTHON_MAC := python3
#PYTHON_WINDOWS := python

# Define virtual environment directory
VENV := env

# Default target executed when no arguments are given to make.
default: test

test: ## run tests with pytest.
@echo "Running tests..."
@pytest --cov=salesgpt
@pytest --cov=salesgpt --cov-report=term-missing --cov-report=html
@echo "Tests executed."

# Set up the development environment
setup:
pip install -U pip setuptools
pip install poetry
@echo "Poetry installed."
@echo "Installing project dependencies using Poetry."
poetry install
@echo "Dependencies installed."

# Clean up the environment
clean:
@echo "Cleaning up..."
rm -rf $(VENV)
rm -rf SalesGPT
@echo "Environment cleaned up."

.PHONY: default setup test clean
59 changes: 49 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,71 @@ sales_agent.step()

## Install

Make sure you have a **python 3.10+** and run:
Make sure you have a **python >=3.8,<3.12**:

`pip install -r requirements.txt`
Create a virtual environment at a location on your computer. We use the generic "env" name for our virtual environment in the setup. You can rename this, but make sure to then use this name later when working with the environment (also rename the VENV variable in the Makefile accordingly to be able to use make commands successfully after cloning our repository):

Create `.env` file and put your API keys there by specifying a line, for instance:
#### For Windows:

`OPENAI_API_KEY=sk-xxx`
- Open Command Prompt or PowerShell.
- Navigate to your project directory: `cd path\to\your\project`
- Create a virtual environment: `python -m venv env`
- Activate the virtual environment: `.\env\Scripts\activate`

Install with pip
#### For Mac:

- Open Terminal.
- Navigate to your project directory: `cd path/to/your/project`
- Create a virtual environment: `python3 -m venv env`
- Activate the virtual environment: `source env/bin/activate`

To deactivate a virtual environment after you have stopped using it simply run: `deactivate`

Clone the SalesGPT Github repository:

`git clone https://github.com/filip-michalsky/SalesGPT.git`

Navigate to the repository and in case you used a different venv name rename the VENV variable in the Makefile:

`cd SalesGPT`



If you simply want to work with SalesGPT as an end user without local changes you can install from PyPI using:

`pip install salesgpt`

If you want to work on your own version of SalesGPT or contribute to our open-source version install by activating your virtual environment as aforementioned and then run:

`make setup`

For more detailed installation steps along with the reasons for doing each please visit CONTRIBUTING.md

Finally, for use of SalesGPT create an `.env` file just as our `.env.example` and put your API keys there by specifying a new line just as we have done.

## Run an Example AI Sales agent
If you used a local installation of SalesGPT skip the next two steps and directly run the run.py script:

`git clone https://github.com/filip-michalsky/SalesGPT.git`

`cd SalesGPT`

`python run.py --verbose True --config examples/example_agent_setup.json`

from your terminal.

## Test your setup

1. Activate an environment with `python 3.10+`
2. cd `SalesGPT`
2. `pip install -r requirements.txt`
3. `pytest`
1. Activate your environment as described above. (run `source env/bin/activate` on Unix-like systems and `.\env\Scripts\activate` on Windows. Replace *env* with the name of your virtual environment)
2. cd `SalesGPT` If you haven't already navigated to the SalesGPT home directory
3. `make test`

All tests should pass. Warnings can be ignored.

## Uninstall SalesGPT

All tests should pass.
To delete the virtual environment you used for SalesGPT programming and your SalesGPT repository from your system navigate to the directory where you installed your virtual environment and cloned SalesGPT and run:
`make clean`

## Deploy

Expand Down
Loading

0 comments on commit df1d3fb

Please sign in to comment.