Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,28 @@ documents and developers who want to build their own RAG pipeline.

### Without Docker

#### Option 1: Using uv (Recommended for faster installation)

1. Clone the repository and run the uv installation script:

```shell
# clone this repo
git clone https://github.com/Cinnamon/kotaemon
cd kotaemon

# run the uv installation script (installs uv automatically if not present)
bash scripts/run_uv.sh
```

This script will:
- Install uv package manager if not present
- Create a virtual environment with Python 3.10
- Install all dependencies using uv (significantly faster than conda/pip)
- Set up PDF.js viewer
- Launch the application

#### Option 2: Using conda (Traditional method)

1. Clone and install required packages on a fresh python environment.

```shell
Expand Down
24 changes: 22 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ dynamic = ["version"]
requires-python = ">= 3.10"
description = "Kotaemon App"
dependencies = [
"kotaemon @ git+https://github.com/Cinnamon/kotaemon.git@main#subdirectory=libs/kotaemon",
"ktem @ git+https://github.com/Cinnamon/kotaemon.git@main#subdirectory=libs/ktem"
"kotaemon",
"ktem"
]
authors = [
{ name = "@trducng", email = "[email protected]" },
Expand All @@ -32,6 +32,26 @@ classifiers = [
"Operating System :: OS Independent",
]

[tool.uv.sources]
kotaemon = { workspace = true }
ktem = { workspace = true }

# uv workspace configuration
[tool.uv.workspace]
members = ["libs/kotaemon", "libs/ktem"]

[dependency-groups]
dev = [
"black",
"coverage",
"flake8",
"ipython",
"pre-commit",
"pytest",
"pytest-mock",
"sphinx"
]

[project.urls]
Homepage = "https://cinnamon.github.io/kotaemon/"
Repository = "https://github.com/Cinnamon/kotaemon/"
Expand Down
187 changes: 187 additions & 0 deletions scripts/run_uv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
#!/bin/bash

# Kotaemon UV Installation Script
# This script provides a faster and simpler alternative to conda-based installation

set -euo pipefail

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color

function print_header() {
echo -e "\n${BLUE}======================================================${NC}"
echo -e "${BLUE}$1${NC}"
echo -e "${BLUE}======================================================${NC}\n"
}

function print_success() {
echo -e "${GREEN}✓ $1${NC}"
}

function print_warning() {
echo -e "${YELLOW}⚠ $1${NC}"
}

function print_error() {
echo -e "${RED}✗ $1${NC}"
}

function check_path_for_spaces() {
if [[ $PWD =~ \ ]]; then
print_error "The current workdir has whitespace which can lead to unintended behaviour. Please modify your path and continue later."
exit 1
fi
}

function check_python_version() {
print_success "uv will automatically manage Python 3.10 - no manual Python installation needed!"
}

function install_uv() {
if command -v uv &> /dev/null; then
print_success "uv is already installed"
return 0
fi

print_header "Installing uv package manager"

if command -v curl &> /dev/null; then
curl -LsSf https://astral.sh/uv/install.sh | sh
elif command -v wget &> /dev/null; then
wget -qO- https://astral.sh/uv/install.sh | sh
else
print_error "Neither curl nor wget is available. Please install one of them."
exit 1
fi

# Add uv to PATH for current session
export PATH="$HOME/.local/bin:$PATH"

if command -v uv &> /dev/null; then
print_success "uv installed successfully"
else
print_error "uv installation failed"
exit 1
fi
}

function setup_environment() {
print_header "Setting up Python environment with uv"

# Create virtual environment with Python 3.10 (uv will download Python if needed)
if [[ ! -d ".venv" ]]; then
print_success "Creating virtual environment with Python 3.10 (uv will download if needed)..."
uv venv --python 3.10
print_success "Created virtual environment"
else
print_warning "Virtual environment already exists"
fi

# Activate virtual environment
source .venv/bin/activate
print_success "Activated virtual environment"
}

function install_dependencies() {
print_header "Installing dependencies"

# Use the exact same approach as conda scripts for compatibility
print_success "Installing kotaemon with exact dependency resolution..."

# Install in the exact same order as the original conda script
uv pip install -e "libs/kotaemon[all]"
uv pip install -e "libs/ktem"

# Fix known version conflicts mentioned in the README
print_success "Resolving known version conflicts..."
uv pip uninstall hnswlib chroma-hnswlib -y 2>/dev/null || true
uv pip install chroma-hnswlib

print_success "Dependencies installed successfully"
}

function setup_pdfjs() {
print_header "Setting up PDF.js viewer"

local pdfjs_dir="libs/ktem/ktem/assets/prebuilt/pdfjs-4.0.379-dist"

if [[ -d "$pdfjs_dir" ]]; then
print_warning "PDF.js already exists, skipping download"
return 0
fi

if [[ -f "scripts/download_pdfjs.sh" ]]; then
bash scripts/download_pdfjs.sh "$pdfjs_dir"
print_success "PDF.js setup completed"
else
print_warning "PDF.js download script not found. You may need to set this up manually."
fi
}

function setup_env_file() {
print_header "Setting up environment configuration"

if [[ ! -f ".env" && -f ".env.example" ]]; then
cp .env.example .env
print_success "Created .env file from template"
print_warning "Please edit .env file to configure your API keys"
elif [[ -f ".env" ]]; then
print_warning ".env file already exists"
else
print_warning "No .env.example found. You may need to configure environment variables manually."
fi
}

function launch_app() {
print_header "Launching Kotaemon"

print_success "Starting the application..."
print_warning "The app will be automatically launched in your browser"
print_warning "Default username and password are both 'admin'"

# Set PDF.js environment variable if directory exists
local pdfjs_dir="libs/ktem/ktem/assets/prebuilt/pdfjs-4.0.379-dist"
if [[ -d "$pdfjs_dir" ]]; then
export PDFJS_PREBUILT_DIR="$pdfjs_dir"
fi

python app.py
}

function main() {
print_header "Kotaemon UV-based Installation"

# Move to project root
cd "$(dirname "${BASH_SOURCE[0]}")" && cd ..

check_path_for_spaces
check_python_version
install_uv
setup_environment
install_dependencies
setup_pdfjs
setup_env_file

print_success "Installation completed successfully!"
echo
print_warning "To launch the application in the future, run:"
echo -e " ${BLUE}cd $(pwd)${NC}"
echo -e " ${BLUE}source .venv/bin/activate${NC}"
echo -e " ${BLUE}python app.py${NC}"
echo

read -p "Do you want to launch the application now? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then
launch_app
else
print_success "You can launch the application later using the commands above."
fi
}

# Run main function
main "$@"
Loading