A step-by-step tutorial to build your own RAG model
- Install Microsoft Visual Studio Code
- Install Python Programming Language
- Create a Free LLM Account
- Paste Code
- Run
Open a web browser (e.g., Chrome, Firefox). Go to the official website: https://code.visualstudio.com/.
On the homepage, you will see a "Download for Windows" button. Click this button. If you're using Windows, the website will automatically detect your OS and suggest the correct download. If you're using macOS or Linux, select the appropriate version for your system (Intel, ARM64, etc.). The download should start automatically. If not, you can click the provided link to manually start the download.
Once the download is complete, open the downloaded file (e.g., VSCodeUserSetup-x64.exe). The installer will launch. Follow these steps: Agree to the License Agreement: Click "I accept the agreement" and then click "Next." Choose the installation location: The default location is fine, but you can change it if you prefer. Select additional tasks: It’s recommended to check options like "Add to PATH" for easier access. You can also choose to create a desktop icon for quick access. Click "Next" and then "Install." Once installation is complete, click "Finish" to launch Visual Studio Code.
Go to the Python website: Visit the official Python website at https://www.python.org/downloads/. Download the latest version of Python: The website should automatically detect your operating system (Windows, macOS, Linux). Click the "Download Python" button for your platform. Open the downloaded .exe file. Check the box that says "Add Python to PATH". This is crucial as it allows you to run Python from the command line. Click "Install Now."
Open VS Code. Install the Python extension: Click on the Extensions icon on the left sidebar or press Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (macOS). Search for Python in the Extensions Marketplace. Install the extension from Microsoft (it should have high ratings).
Dependencies are included in the pyproject.toml
file under the [tool.poetry.dependencies]
header, you can open your terminal and just type pip install <name_of_package>
for example pip install openai
make sure you install the specific versions described in the pyproject.toml
file
This guide will walk you through installing Poetry and managing dependencies in a Python project using the pyproject.toml
file.
Poetry is a Python package manager that simplifies dependency management and package building.
Run the following command to download and install Poetry:
curl -sSL https://install.python-poetry.org | python3 -
On Windows, you can use PowerShell:
(Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | python -
Once installed, verify that Poetry is working by checking the version:
poetry --version
If Poetry is not automatically added to your PATH
, you'll need to do it manually.
Poetry is usually installed in ~/.local/bin
on macOS/Linux or %USERPROFILE%\.poetry\bin
on Windows.
-
macOS/Linux: Add the following line to your shell configuration file (e.g.,
~/.bashrc
,~/.zshrc
):export PATH="$HOME/.local/bin:$PATH"
-
Windows: Add the Poetry path to your system environment variables through the Control Panel.
Navigate to the directory containing the pyproject.toml
file:
cd /path/to/your/project
Make sure that the pyproject.toml
file is in this directory.
To install all dependencies from the pyproject.toml
file, run:
poetry install
Poetry will resolve the dependencies, create a virtual environment, and install everything needed for your project.
If you want to activate the virtual environment that Poetry created, use:
poetry shell
To check the installed dependencies, use:
poetry show
If you need to manage dependencies after installation:
To add a new dependency, run:
poetry add <package-name>
To remove a dependency, run:
poetry remove <package-name>
With dependencies installed, you can run your Python scripts inside the Poetry-managed virtual environment.
-
If you're in a Poetry shell, use:
python your_script.py
-
If you're not in the Poetry shell, run:
poetry run python your_script.py
To manually update the poetry.lock
file after modifying dependencies:
poetry lock
This ensures the lock file is up to date with the latest dependencies.