From 3fd0fe8fc5884c89200b2f89eceff75ee92c2133 Mon Sep 17 00:00:00 2001 From: Sushanth Srivatsa <65614803+ssbodapati@users.noreply.github.com> Date: Wed, 19 Feb 2025 05:30:17 +0530 Subject: [PATCH] 2749 ollama client auth token (#3005) * ollama auth token provision * auth token provision * ollama auth provision * ollama auth token * ollama auth provision * token input field css fix * Fix provider handler not using key sensible fallback to not break existing installs re-order of input fields null-check for API key and header optional insert on request linting * apply header and auth to agent invocations * upgrading to ollama 5.10 for passing headers to constructor * rename Auth systemSetting key to be more descriptive linting and copy * remove untracked files + update gitignore * remove debug * patch lockfile --------- Co-authored-by: timothycarambat --- docker/.env.example | 1 + .../LLMSelection/OllamaLLMOptions/index.jsx | 262 ++++++++++-------- .../hooks/useProviderEndpointAutoDiscovery.js | 27 +- server/.env.example | 1 + server/models/systemSettings.js | 1 + server/package.json | 4 +- server/storage/models/.gitignore | 3 +- server/utils/AiProviders/ollama/index.js | 11 +- .../utils/agents/aibitat/providers/ollama.js | 8 +- server/utils/helpers/customModels.js | 11 +- server/utils/helpers/updateENV.js | 4 + server/yarn.lock | 8 +- 12 files changed, 212 insertions(+), 129 deletions(-) diff --git a/docker/.env.example b/docker/.env.example index 5f1b0e44..d3cc68e1 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -42,6 +42,7 @@ GID='1000' # OLLAMA_BASE_PATH='http://host.docker.internal:11434' # OLLAMA_MODEL_PREF='llama2' # OLLAMA_MODEL_TOKEN_LIMIT=4096 +# OLLAMA_AUTH_TOKEN='your-ollama-auth-token-here (optional, only for ollama running behind auth - Bearer token)' # LLM_PROVIDER='togetherai' # TOGETHER_AI_API_KEY='my-together-ai-key' diff --git a/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx b/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx index d04f7cb6..c98877c5 100644 --- a/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx +++ b/frontend/src/components/LLMSelection/OllamaLLMOptions/index.jsx @@ -11,12 +11,15 @@ export default function OllamaLLMOptions({ settings }) { autoDetecting: loading, basePath, basePathValue, + authToken, + authTokenValue, showAdvancedControls, setShowAdvancedControls, handleAutoDetectClick, } = useProviderEndpointAutoDiscovery({ provider: "ollama", initialBasePath: settings?.OllamaLLMBasePath, + initialAuthToken: settings?.OllamaLLMAuthToken, ENDPOINTS: OLLAMA_COMMON_URLS, }); const [performanceMode, setPerformanceMode] = useState( @@ -32,6 +35,7 @@ export default function OllamaLLMOptions({ settings }) {