Skip to content

Commit

Permalink
feat: add setup script for Ollama installation and update README inst…
Browse files Browse the repository at this point in the history
…ructions
  • Loading branch information
shxntanu committed Dec 23, 2024
1 parent 8ef553f commit 47bccd4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 15 deletions.
20 changes: 5 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@

`lesa` is a CLI tool built in Python that allows you to converse with your documents from the terminal, completely offline and on-device using **Ollama**. Open the terminal in the directory of your choice and start a conversation with any document!




## Usage

To start a conversation with a document (`.pdf` and `.docx` for now), simply run:
Expand Down Expand Up @@ -57,23 +54,16 @@ This creates a `.lesa` config folder in your current working directory that stor

## Setup

### Prerequisites

`lesa` uses [Ollama](https://ollama.com/) under the hood to utilize the power of large language models. To install Ollama, run:
`lesa` uses [Ollama](https://ollama.com/) under the hood to utilize the power of large language models.
To install and setup Ollama, run the setup script [`setup-ollama.sh`](scripts/setup-ollama.sh).

```bash
curl -fsSL https://ollama.com/install.sh | sh
curl -fsSL https://raw.githubusercontent.com/shxntanu/lesa/main/scripts/setup-ollama.sh | bash
```

`lesa` uses the Llama 3.1 8b as the default. You can use any other model as well, just make sure it has enough context window to understand the content of your documents.

Pull Llama using:

```bash
ollama pull llama3.1
```
This script automatically installs the Ollama CLI and pulls the default model (llama3.1:latest) for you. Then install the package using pip.

### Installation
## Installation

Simply install the package using pip:

Expand Down
61 changes: 61 additions & 0 deletions scripts/setup-ollama.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

# Function to check if a command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}

# Function to detect OS
get_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "macos" ;;
*) echo "unsupported" ;;
esac
}

# Check if Ollama is already installed
if command_exists ollama; then
echo "Ollama is already installed."
else
echo "Ollama not found. Installing..."

OS=$(get_os)
case $OS in
"linux")
curl -fsSL https://ollama.com/install.sh | sh
;;
"macos")
brew install ollama
;;
*)
echo "Error: Unsupported operating system"
exit 1
;;
esac

# Check if installation was successful
if ! command_exists ollama; then
echo "Error: Ollama installation failed"
exit 1
fi
echo "Ollama installed successfully!"
fi

# Start Ollama service if it's not running
if ! pgrep -x "ollama" >/dev/null; then
echo "Starting Ollama service..."
ollama serve &
sleep 5 # Give some time for the service to start
fi

# Pull the llama3.1:latest model
echo "Pulling llama3.1:latest model..."
if ollama pull llama3.1:latest; then
echo "Model llama3.1:latest pulled successfully!"
else
echo "Error: Failed to pull llama3.1:latest model"
exit 1
fi

echo "Setup completed successfully!"

0 comments on commit 47bccd4

Please sign in to comment.