From 034754c5f44a25db5a61b6c7ca5a3e8434686f80 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 12 May 2024 19:17:38 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20send=20Bearer=20token=20to=20Ollama?= =?UTF-8?q?=20if=20apiKey=20set?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/llm/llms/Ollama.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/llm/llms/Ollama.ts b/core/llm/llms/Ollama.ts index 39ed723bb..951135090 100644 --- a/core/llm/llms/Ollama.ts +++ b/core/llm/llms/Ollama.ts @@ -1,4 +1,3 @@ -import { BaseLLM } from "../index.js"; import { ChatMessage, CompletionOptions, @@ -6,6 +5,7 @@ import { ModelProvider, } from "../../index.js"; import { stripImages } from "../countTokens.js"; +import { BaseLLM } from "../index.js"; import { streamResponse } from "../stream.js"; class Ollama extends BaseLLM { @@ -23,7 +23,9 @@ class Ollama extends BaseLLM { } this.fetch(this.getEndpoint("api/show"), { method: "POST", - headers: {}, + headers: { + "Authorization": `Bearer ${this.apiKey}` + }, body: JSON.stringify({ name: this._getModel() }), }) .then(async (response) => { @@ -163,6 +165,7 @@ class Ollama extends BaseLLM { method: "POST", headers: { "Content-Type": "application/json", + "Authorization": `Bearer ${this.apiKey}` }, body: JSON.stringify(this._convertArgs(options, prompt)), }); @@ -201,6 +204,7 @@ class Ollama extends BaseLLM { method: "POST", headers: { "Content-Type": "application/json", + "Authorization": `Bearer ${this.apiKey}` }, body: JSON.stringify(this._convertArgs(options, messages)), });