Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Doc: Updated documentation for Ollama (#689)

Jack Quimby0748f0b7ce56
diff --git a/docs/examples/LOCAL_LLM_GUIDE.md b/docs/examples/LOCAL_LLM_GUIDE.md
new file mode 100644
index 0000000000..ba1377d8b7
--- /dev/null
+++ b/docs/examples/LOCAL_LLM_GUIDE.md
@@ -0,0 +1,111 @@
+# Local LLM Guide with Ollama server
+
+## 0. Install Ollama:
+run the following command in a conda env with CUDA etc.
+
+Linux:
+```
+curl -fsSL https://ollama.com/install.sh | sh
+```
+Windows or macOS:
+
+- Download from [here](https://ollama.com/download/)
+
+## 1. Install Models:
+Ollama model names can be found [here](https://ollama.com/library) (See example below)
+
+![alt text](images/ollama.png)
+
+Once you have found the model you want to use copy the command and run it in your conda env.
+
+Example of llama2 q4 quantized:
+```
+conda activate <env_name>
+ollama run llama2:13b-chat-q4_K_M
+```
+
+you can check which models you have downloaded like this:
+```
+~$ ollama list
+NAME ID SIZE MODIFIED
+llama2:latest 78e26419b446 3.8 GB 6 weeks ago
+mistral:7b-instruct-v0.2-q4_K_M eb14864c7427 4.4 GB 2 weeks ago
+starcoder2:latest f67ae0f64584 1.7 GB 19 hours ago
+```
+## 2. Run Ollama in CLI:
+This command starts up the ollama server that is on port `11434`
+
+This will show the requests in CLI
+```
+conda activate <env_name>
+ollama serve
+```
+or
+
+This will run with no output in the background
+```
+sudo systemctl start ollama
+```
+
+If you see something like this:
+```
+Error: listen tcp 127.0.0.1:11434: bind: address already in use
+```
+This is not an error it just means the server is already running
+
+To stop the server use:
+```
+sudo systemctl stop ollama
+```
+
+For more info go [here](https://github.com/ollama/ollama/blob/main/docs/faq.md)
+
+## 3. Follow the default installation of OpenDevin:
+```
+git clone [email protected]:OpenDevin/OpenDevin.git
+```
+or
+```
+git clone [email protected]:<YOUR-USERNAME>/OpenDevin.git
+```
+
+then
+```
+cd OpenDevin
+```
+
+## 4. Run setup commands:
+```
+make build
+make setup-config
+```
+
+## 5. Modify config file:
+
+- After running `make setup-config` you will see a generated file `OpenDevin/config.toml`.
+- Open this file and modify it to your needs based on this template:
+
+```
+LLM_API_KEY="ollama"
+LLM_MODEL="ollama/<model_name>"
+LLM_EMBEDDING_MODEL="local"
+LLM_BASE_URL="http://localhost:<port_number>"
+WORKSPACE_DIR="./workspace"
+```
+Notes:
+- The API key should be set to `"ollama"`
+- The base url needs to be `localhost`
+- By default ollama port is `11434` unless you set it
+- `model_name` needs to be the entire model name
+ - Example: `LLM_MODEL="ollama/llama2:13b-chat-q4_K_M"`
+
+## 6. Start OpenDevin:
+
+At this point everything should be set up and working properly.
+1. Start by running the ollama server using the method outlined above
+2. Run `make build` in your terminal `~/OpenDevin/`
+3. Run `make run` in your terminal
+4. If that fails try running the server and front end in sepparate terminals:
+ - In the first terminal `make start-backend`
+ - In the second terminal `make start-frontend`
+5. you should now be able to connect to `http://localhost:3001/` with your local model running!
diff --git a/opendevin/llm/images/ollama.png b/docs/examples/images/ollama.png
similarity index 100%
rename from opendevin/llm/images/ollama.png
rename to docs/examples/images/ollama.png
diff --git a/opendevin/llm/LOCAL_LLM_GUIDE.md b/opendevin/llm/LOCAL_LLM_GUIDE.md
deleted file mode 100644
index 9893c2f811..0000000000
--- a/opendevin/llm/LOCAL_LLM_GUIDE.md
+++ /dev/null
@@ -1,73 +0,0 @@
-# Local LLM Guide with Ollama and Litellm
-
-- This is a guide to use local LLM's with Ollama and Litellm
-
-## 1. Follow the default installation:
-```
-git clone [email protected]:OpenDevin/OpenDevin.git
-```
-or
-```
-git clone [email protected]:<YOUR-USERNAME>/OpenDevin.git
-```
-
-then `cd OpenDevin`
-
-## 2. Run setup commands:
-```
-make build
-make setup-config
-```
-
-## 3. Modify config file:
-
-- after running `make setup-config` you will see a generated file called `config.toml` in `OpenDevin/`.
-
-- open this file and modify it to your needs based on this template:
-
-```
-LLM_API_KEY="0"
-LLM_MODEL="ollama/<model_name>"
-LLM_BASE_URL="http://localhost:<port_number>"
-WORKSPACE_DIR="./workspace"
-```
-`<port_number>` can be whatever you want just make sure it is not used by anything else.
-
-ollama model names can be found [here](https://ollama.com/library)
-
-Example:
-![alt text](images/ollama.png)
-
-Note: The API key does not matter and the base url needs to be `localhost` with the port number you intend to use with litellm. By default this is `11434`.
-
-## 4. Run Litellm in CLI:
-
-- there are two options for this:
-
-#### 1. Run litellm in linux terminal:
-```
-conda activate <env_name>
-litellm --model ollama/<model_name>
-```
-
-#### 2. Create a batch script:
-- The below example assumes the use of miniconda3 with default install settings, you will need to change this to the path to your `conda.sh` file if you use something else.
-```
-start /B wsl.exe -d <DISTRO_NAME> -e bash -c "source ~/miniconda3/etc/profile.d/conda.sh && conda activate <ENV_NAME> && litellm --model ollama/<MODEL_NAME> --port <PORT>"
-```
-- The above script will spawn a wsl instance in your cmd terminal, activate your conda environment and then run the litellm command with your model and port number.
-- make sure you fill in all the <> brackets with the appropriate names.
-
-Either way you do it you should see something like this to confirm you have started the server:
-![alt text](images/example.png)
-
-## 5. Start OpenDevin:
-
-At this point everything should be set up and working properly.
-1. Start by running the litellm server using one of the methods outlined above
-2. Run `make build` in your terminal `~/OpenDevin/`
-3. Run `make run` in your terminal
-4. If that fails try running the server and front end in sepparate terminals:
- - In the first terminal `make start-backend`
- - In the second terminal `make start-frontend`
-5. you should now be able to connect to `http://localhost:3001/` with your local model running!
diff --git a/opendevin/llm/images/example.png b/opendevin/llm/images/example.png
deleted file mode 100644
index 5803fb6ec6..0000000000
Binary files a/opendevin/llm/images/example.png and /dev/null differ