Skip to content

Commit

Permalink
Update the installation guide. Still WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
drazvan committed Nov 2, 2023
1 parent b725e65 commit 23e7c49
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 69 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ NeMo Guardrails is an open-source toolkit for easily adding *programmable guardr
## Requirements

Python 3.8+.
**TODO**: add reference to requirements for compiling Annoy on Windows.

NeMo Guardrails uses [annoy](https://github.com/spotify/annoy) which is a C++ library with Python bindings. To install NeMo Guardrails you will need to have the C++ compiler and dev tools installed. Check out the [Installation Guide](./docs/getting_started/installation-guide.md#prerequisites) for platform-specific instructions.

## Installation

Expand Down
5 changes: 4 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ The documentation is divided into the following sections:

The getting started section covers two topics:

* [Installation Guide](./getting_started/installation-guide.md): This guide walks you through the process of setting up an environment to run Guardrails. It also showcases the various ways in which you can interact with the bot.
* [Installation Guide](./getting_started/installation-guide.md): This guide walks you through the process of setting up your environment and installing NeMo Guardrails

* [CLI](./getting_started/cli.md): This guide introduces the NeMo Guardrails CLI and walks you through playing with the example configurations using the Chat CLI and the Server.

* [The "Hello World" example](./getting_started/hello-world.md): This example walks you through setting up basic rails along with peeling some layers for the Guardrail runtime to explain how the rails work.

## Examples
Expand Down
68 changes: 68 additions & 0 deletions docs/getting_started/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# CLI

**NOTE: THIS SECTION IS WORK IN PROGRESS.**



7. You should now be able to invoke the `nemoguardrails` CLI.

```bash
> nemoguardrails --help

Usage: nemoguardrails [OPTIONS] COMMAND [ARGS]...

Options:
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.

Commands:
actions-server Starts a NeMo Guardrails actions server.
chat Starts an interactive chat session.
server Starts a NeMo Guardrails server.
```

You can also use the `--help` flag to learn more about each of the `nemoguardrails` commands:

```bash
> nemoguardrails actions-server --help

Usage: nemoguardrails actions-server [OPTIONS]

Starts a NeMo Guardrails actions server.

Options:
--port INTEGER The port that the server should listen on. [default: 8001]
--help Show this message and exit.
```

```bash
> nemoguardrails chat --help

Usage: nemoguardrails chat [OPTIONS]

Starts an interactive chat session.

Options:
--config TEXT Path to a directory containing configuration files
to use. Can also point to a single configuration
file. [default: config]
--verbose / --no-verbose If the chat should be verbose and output the
prompts [default: no-verbose]
--help Show this message and exit.
```

```bash
> nemoguardrails server --help

Usage: nemoguardrails server [OPTIONS]

Starts a NeMo Guardrails server.

Options:
--port INTEGER The port that the server should listen on. [default: 8000]
--help Show this message and exit.
```
110 changes: 43 additions & 67 deletions docs/getting_started/installation-guide.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
# Getting Started
# Installation Guide

> **NOTE**: this needs to be focused only on the installation part.
**⚠️THIS SECTION IS WORK IN PROGRESS. ⚠️**

This is a getting started guide for users of the alpha version. This guide will cover:
This guide will walk you through installing NeMo Guardrails, and it will cover:

1. Installation of the NeMo Guardrails toolkit;
2. Creation of a basic rails application;
3. Using the interactive chat;
4. Calling actions from flows.
1. Setting up a fresh virtual environment.
2. Installing using `pip` or `conda`.
3. Installing from Source Code.
4. Optional dependencies.

## Installation
## Prerequisites

1. First, create a folder for your project e.g. `my_assistant`.
Python 3.8+.

NeMo Guardrails uses [annoy](https://github.com/spotify/annoy), which is a C++ library with Python bindings. To be able to install it, you need ...

**⚠️TODO: figure out the exact dependencies for Unix-based, Mac and Windows.**
- `apt-get install gcc g++` ?
- Windows: Visual Studio Build Tools with "Desktop development with C++"?

## Setting up a virtual environment

If you want to experiment with NeMo Guardrails from scratch, we recommend using a fresh virtual environment. Otherwise, you can skip to the following subsection.

1. First, create a folder for your project, e.g., `my_assistant.`

```bash
> mkdir my_assistant
Expand All @@ -30,81 +42,45 @@ This is a getting started guide for users of the alpha version. This guide will
> source venv/bin/activate
```

4. Install NeMo Guardrails using pip.
## Installation using `pip`

To install NeMo Guardrails using pip:

```bash
> pip install nemoguardrails
```

5. If you want to use OpenAI, also install the `openai` package. And make sure that you have the `OPENAI_API_KEY` environment variable set.
To install NeMo Guardrails using Conda:

```bash
> pip install openai
> export OPENAI_API_KEY=...
```
```bash
conda install langchain -c conda-forge
```

7. You should now be able to invoke the `nemoguardrails` CLI.
## Installing from source code

```bash
> nemoguardrails --help

Usage: nemoguardrails [OPTIONS] COMMAND [ARGS]...

Options:
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.

Commands:
actions-server Starts a NeMo Guardrails actions server.
chat Starts an interactive chat session.
server Starts a NeMo Guardrails server.
```
NeMo Guardrails is under active development and the main branch will always contain the latest development version. To install from source, you first need to clone the repository:

You can also use the `--help` flag to learn more about each of the `nemoguardrails` commands:
```
git clone https://github.com/NVIDIA/NeMo-Guardrails.git
```

```bash
> nemoguardrails actions-server --help
Next, you need to install the package locally:

Usage: nemoguardrails actions-server [OPTIONS]
```
cd NeMo-Guardrails
pip install -e .
```

Starts a NeMo Guardrails actions server.
## Optional dependencies

Options:
--port INTEGER The port that the server should listen on. [default: 8001]
--help Show this message and exit.
```
If you want to use OpenAI, also install the `openai` package. And make sure that you have the `OPENAI_API_KEY` environment variable set.

```bash
> nemoguardrails chat --help

Usage: nemoguardrails chat [OPTIONS]

Starts an interactive chat session.

Options:
--config TEXT Path to a directory containing configuration files
to use. Can also point to a single configuration
file. [default: config]
--verbose / --no-verbose If the chat should be verbose and output the
prompts [default: no-verbose]
--help Show this message and exit.
> pip install openai
> export OPENAI_API_KEY=...
```

```bash
> nemoguardrails server --help

Usage: nemoguardrails server [OPTIONS]

Starts a NeMo Guardrails server.

Options:
--port INTEGER The port that the server should listen on. [default: 8000]
--help Show this message and exit.
```
**⚠️TODO: add information about the extras.**

## What's next?

Expand Down

0 comments on commit 23e7c49

Please sign in to comment.