diff --git a/autogpt_platform/backend/backend/blocks/llm.py b/autogpt_platform/backend/backend/blocks/llm.py index 0e56abed5..968f7d28f 100644 --- a/autogpt_platform/backend/backend/blocks/llm.py +++ b/autogpt_platform/backend/backend/blocks/llm.py @@ -109,6 +109,7 @@ class LlmModel(str, Enum, metaclass=LlmModelMeta): LLAMA3_1_70B = "llama-3.1-70b-versatile" LLAMA3_1_8B = "llama-3.1-8b-instant" # Ollama models + OLLAMA_LLAMA3_2 = "llama3.2" OLLAMA_LLAMA3_8B = "llama3" OLLAMA_LLAMA3_405B = "llama3.1:405b" OLLAMA_DOLPHIN = "dolphin-mistral:latest" @@ -163,6 +164,7 @@ MODEL_METADATA = { # Limited to 16k during preview LlmModel.LLAMA3_1_70B: ModelMetadata("groq", 131072), LlmModel.LLAMA3_1_8B: ModelMetadata("groq", 131072), + LlmModel.OLLAMA_LLAMA3_2: ModelMetadata("ollama", 8192), LlmModel.OLLAMA_LLAMA3_8B: ModelMetadata("ollama", 8192), LlmModel.OLLAMA_LLAMA3_405B: ModelMetadata("ollama", 8192), LlmModel.OLLAMA_DOLPHIN: ModelMetadata("ollama", 32768), diff --git a/autogpt_platform/backend/backend/data/block_cost_config.py b/autogpt_platform/backend/backend/data/block_cost_config.py index 4ed57b2b3..8209a2d95 100644 --- a/autogpt_platform/backend/backend/data/block_cost_config.py +++ b/autogpt_platform/backend/backend/data/block_cost_config.py @@ -51,6 +51,7 @@ MODEL_COST: dict[LlmModel, int] = { LlmModel.LLAMA3_1_405B: 1, LlmModel.LLAMA3_1_70B: 1, LlmModel.LLAMA3_1_8B: 1, + LlmModel.OLLAMA_LLAMA3_2: 1, LlmModel.OLLAMA_LLAMA3_8B: 1, LlmModel.OLLAMA_LLAMA3_405B: 1, LlmModel.OLLAMA_DOLPHIN: 1, diff --git a/docs/content/imgs/ollama/Ollama-Add-Prompts.png b/docs/content/imgs/ollama/Ollama-Add-Prompts.png new file mode 100644 index 000000000..deeddc7cc Binary files /dev/null and b/docs/content/imgs/ollama/Ollama-Add-Prompts.png differ diff --git a/docs/content/imgs/ollama/Ollama-Credentials.png b/docs/content/imgs/ollama/Ollama-Credentials.png new file mode 100644 index 000000000..769339df9 Binary files /dev/null and b/docs/content/imgs/ollama/Ollama-Credentials.png differ diff --git a/docs/content/imgs/ollama/Ollama-Enter-API-key.png b/docs/content/imgs/ollama/Ollama-Enter-API-key.png new file mode 100644 index 000000000..ab365a576 Binary files /dev/null and b/docs/content/imgs/ollama/Ollama-Enter-API-key.png differ diff --git a/docs/content/imgs/ollama/Ollama-Output.png b/docs/content/imgs/ollama/Ollama-Output.png new file mode 100644 index 000000000..06cb9f7a8 Binary files /dev/null and b/docs/content/imgs/ollama/Ollama-Output.png differ diff --git a/docs/content/imgs/ollama/Ollama-Remote-Host.png b/docs/content/imgs/ollama/Ollama-Remote-Host.png new file mode 100644 index 000000000..25a57b9ad Binary files /dev/null and b/docs/content/imgs/ollama/Ollama-Remote-Host.png differ diff --git a/docs/content/imgs/ollama/Ollama-Select-Llama32.png b/docs/content/imgs/ollama/Ollama-Select-Llama32.png new file mode 100644 index 000000000..fc9b58d6a Binary files /dev/null and b/docs/content/imgs/ollama/Ollama-Select-Llama32.png differ diff --git a/docs/content/imgs/ollama/Select-AI-block.png b/docs/content/imgs/ollama/Select-AI-block.png new file mode 100644 index 000000000..d9c41db4a Binary files /dev/null and b/docs/content/imgs/ollama/Select-AI-block.png differ diff --git a/docs/content/platform/ollama.md b/docs/content/platform/ollama.md index da8948098..3a26a6717 100644 --- a/docs/content/platform/ollama.md +++ b/docs/content/platform/ollama.md @@ -1,37 +1,78 @@ # Running Ollama with AutoGPT -Follow these steps to set up and run Ollama and your AutoGPT project: +> **Important**: Ollama integration is only available when self-hosting the AutoGPT platform. It cannot be used with the cloud-hosted version. -1. **Run Ollama** - - Open a terminal - - Execute the following command: - ``` - ollama run llama3 - ``` - - Leave this terminal running +Follow these steps to set up and run Ollama with the AutoGPT platform. -2. **Run the Backend** - - Open a new terminal - - Navigate to the backend directory in the AutoGPT project: - ``` - cd autogpt_platform/backend/ - ``` - - Start the backend using Poetry: - ``` - poetry run app - ``` +## Prerequisites -3. **Run the Frontend** - - Open another terminal - - Navigate to the frontend directory in the AutoGPT project: - ``` - cd autogpt_platform/frontend/ - ``` - - Start the frontend development server: - ``` - npm run dev - ``` +1. Make sure you have gone through and completed the [AutoGPT Setup](/platform/getting-started) steps, if not please do so before continuing with this guide. +2. Before starting, ensure you have [Ollama installed](https://ollama.com/download) on your machine. -4. **Choose the Ollama Model** - - Add LLMBlock in the UI - - Choose the last option in the model selection dropdown +## Setup Steps + +### 1. Launch Ollama +Open a new terminal and execute: +```bash +ollama run llama3.2 +``` + +> **Note**: This will download the [llama3.2](https://ollama.com/library/llama3.2) model and start the service. Keep this terminal running in the background. + +### 2. Start the Backend +Open a new terminal and navigate to the autogpt_platform directory: +```bash +cd autogpt_platform +docker compose up -d --build +``` + +### 3. Start the Frontend +Open a new terminal and navigate to the frontend directory: +```bash +cd autogpt_platform/frontend +npm run dev +``` + +Then visit [http://localhost:3000](http://localhost:3000) to see the frontend running, after registering an account/logging in, navigate to the build page at [http://localhost:3000/build](http://localhost:3000/build) + +### 4. Using Ollama with AutoGPT + +Now that both Ollama and the AutoGPT platform are running we can move onto using Ollama with AutoGPT: + +1. Add an AI Text Generator block to your workspace (it can work with any AI LLM block but for this example will be using the AI Text Generator block): + ![Add AI Text Generator Block](../imgs/ollama/Select-AI-block.png) + +2. In the "LLM Model" dropdown, select "llama3.2" (This is the model we downloaded earlier) + ![Select Ollama Model](../imgs/ollama/Ollama-Select-Llama32.png) + +3. You will see it ask for "Ollama Credentials", simply press "Enter API key" + ![Ollama Credentials](../imgs/ollama/Ollama-Enter-API-key.png) + + And you will see "Add new API key for Ollama", In the API key field you can enter anything you want as Ollama does not require an API key, I usually just enter a space, for the Name call it "Ollama" then press "Save & use this API key" + ![Ollama Credentials](../imgs/ollama/Ollama-Credentials.png) + +4. After that you will now see the block again, add your prompts then save and then run the graph: +![Add Prompt](../imgs/ollama/Ollama-Add-Prompts.png) + +That's it! You've successfully setup the AutoGPT platform and made a LLM call to Ollama. +![Ollama Output](../imgs/ollama/Ollama-Output.png) + + +### Using Ollama on a Remote Server with AutoGPT +For running Ollama on a remote server, simply make sure the Ollama server is running and is accessible from other devices on your network/remotely through the port 11434, then you can use the same steps above but you need to add the Ollama servers IP address to the "Ollama Host" field in the block settings like so: + +![Ollama Remote Host](../imgs/ollama/Ollama-Remote-Host.png) + +## Troubleshooting + +If you encounter any issues, verify that: + +- Ollama is properly installed and running +- All terminals remain open during operation +- Docker is running before starting the backend + +For common errors: + +1. **Connection Refused**: Make sure Ollama is running and the host address is correct (also make sure the port is correct, its default is 11434) +2. **Model Not Found**: Try running `ollama pull llama3.2` manually first +3. **Docker Issues**: Ensure Docker daemon is running with `docker ps` \ No newline at end of file