From a43b1d83cae04f124a73126234686a11b4f3ec31 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Fri, 24 May 2024 15:45:16 -0700 Subject: [PATCH 1/3] update for Ollama use --- README.md | 13 +++++++++++++ src/classes/engine/ChatGpt.js | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9534c5d..13aa5d3 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,19 @@ Options is stored in a JSON note with `#CHAT_OPTIONS ` label. | systemPrompt | Background prompt used for system messages, e.g., set it to: "You are a helpful assistant for Trilium note-taking." | ‘’ | | checkUpdates | Whether to automatically check for updates. If enabled, a dot will be displayed on the face icon when an update is available. | true | +### Use with Ollama + +If you want to use your own locally hosted [Ollama](https://github.com/ollama/ollama), you need to set the values of `requestUrls.completion` to `https:///api/chat`, set `stream` to `false`, and set `model` to whichever model you want to use from your Ollama: +```json + "requestUrls": { + "completion": "https://ollama.local/api/chat" + }, + "engineOptions": { + "model": "llama3", + "stream": false + }, +``` + ### Prompt The prompt supports customizable options, making it highly flexible to use. diff --git a/src/classes/engine/ChatGpt.js b/src/classes/engine/ChatGpt.js index c839704..88553f3 100644 --- a/src/classes/engine/ChatGpt.js +++ b/src/classes/engine/ChatGpt.js @@ -259,7 +259,8 @@ export default class ChatGpt extends LittleEvent { }, body: JSON.stringify(options), }); - const { content } = (await response.json()).choices[0].message; + const responseJson = await response.json(); + const { content } = responseJson.choices ? responseJson.choices[0].message : responseJson.message; return content; } From c3c10b1f9c9fe1482b80792b0e385bc729ed575e Mon Sep 17 00:00:00 2001 From: perf3ct Date: Fri, 24 May 2024 15:50:27 -0700 Subject: [PATCH 2/3] update README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 13aa5d3..e1e9072 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,16 @@ ## Introduction -The chat plugin highly integrated with Trilium. +This chat plugin is highly integrated with Trilium, and allows you to access ChatGPT right inside Trilium! + +You can even use your own locally hosted Ollama. This project is written in vanilla JavaScript, and is a frontend-only project. For those interested in developing Trilium plugins, there are some details within that can be referenced. ## Features - Normal chat +- Use Ollama - Custom prompt - Supports mustache syntax to render options. e.g. {{language:Enligsh|Chinese|Czech}} will be rendered as a select element (This can be changed in CHAT_PROMPTS) - {{message}} as your message @@ -80,7 +83,7 @@ If you want to use your own locally hosted [Ollama](https://github.com/ollama/ol "engineOptions": { "model": "llama3", "stream": false - }, + } ``` ### Prompt From ae8dc1b75f53cbbe7a1884c5f1b3601ae362fce9 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Fri, 24 May 2024 15:51:35 -0700 Subject: [PATCH 3/3] increment version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d615127..de83d42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "trilium-chat", - "version": "0.4.4", + "version": "0.4.5", "description": "The chat plugin highly integrated with Trilium.", "keywords": [], "license": "AGPL-3.0-only",