From 17c0ce3c251583db638ffdf1f2b183648fb57c2d Mon Sep 17 00:00:00 2001 From: Radnos Date: Fri, 5 Apr 2024 23:41:28 +0200 Subject: [PATCH] added ollama --- README.md | 9 ++++++++- src/agent/prompter.js | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 17c5c02..9670932 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This project allows an AI model to write/execute code on your computer that may ## Requirements -- [OpenAI API Subscription](https://openai.com/blog/openai-api), [Gemini API Subscription](https://aistudio.google.com/app/apikey), or [Anthropic API Subscription](https://docs.anthropic.com/claude/docs/getting-access-to-claude) +- [OpenAI API Subscription](https://openai.com/blog/openai-api), [Gemini API Subscription](https://aistudio.google.com/app/apikey), [Anthropic API Subscription](https://docs.anthropic.com/claude/docs/getting-access-to-claude), or [Ollama](https://ollama.com/download) - [Minecraft Java Edition](https://www.minecraft.net/en-us/store/minecraft-java-bedrock-edition-pc) - [Node.js](https://nodejs.org/) (at least v14) @@ -19,6 +19,10 @@ Add one of these environment variables: - `GEMINI_API_KEY` - `ANTHROPIC_API_KEY` (and optionally `OPENAI_API_KEY` for embeddings. not necessary, but without embeddings performance will suffer) + You can also use Ollama instead. + To install the models used by default (generation and embedding), execute the following script: + `ollama pull mistral && ollama pull nomic-embed-text` + Clone/Download this repository Run `npm install` @@ -33,6 +37,7 @@ Run `node main.js` You can configure the agent's name, model, and prompts in their profile like `andy.json`. +You can configure ollama in `ollama-config.json`. You can configure project details in `settings.json`. Here is an example settings for connecting to a non-local server: ``` @@ -45,6 +50,8 @@ You can configure project details in `settings.json`. Here is an example setting } ``` + + ## Patches Some of the node modules that we depend on have bugs in them. To add a patch, change your local node module file and run `npx patch-package [package-name]` diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 0794247..797ac56 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -8,6 +8,7 @@ import { getCommand } from './commands/index.js'; import { Gemini } from '../models/gemini.js'; import { GPT } from '../models/gpt.js'; import { Claude } from '../models/claude.js'; +import { Ollama } from '../models/ollama.js'; export class Prompter { @@ -30,6 +31,8 @@ export class Prompter { this.model = new GPT(model_name); else if (model_name.includes('claude')) this.model = new Claude(model_name); + else if (model_name.includes('ollama')) + this.model = new Ollama(model_name); else throw new Error('Unknown model ' + model_name); }