hoarder-app / hoarder

A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
https://hoarder.app
GNU Affero General Public License v3.0
6.47k stars 235 forks source link

Access Ollama with an API Key #639

Open genobi opened 2 weeks ago

genobi commented 2 weeks ago

Describe the feature you'd like

I currently use Ollama via Open-WebUI in Docker. That provides a Ollama API but behind a per-user API key. That is more secure that having an open, unauthenticated API to our LLM server and I prefer that than trusting a closed network within Docker.

The request is to add a environmental variable within the Docker Compose to use an API key with the Ollama API.

Describe the benefits this would bring to existing Hoarder users

Allow secure access to Ollama instances that are secured with an API key

Can the goal of this request already be achieved via other means?

Not within Docker, that I know of.

Have you searched for an existing open/closed issue?

Additional context

No response

kamtschatka commented 1 week ago

any documentation you can provide so we can see what you have set up? This? https://docs.openwebui.com/getting-started/advanced-topics/api-endpoints So we would need to provide a "bearer \\" Authorization header?

genobi commented 1 week ago

Yes! I have been looking over those very docs (and using their search) and totally missed that. I tried the OpenAI compatible version using the docker env to set the base URL and ran into issues (generic 400 bad request errors). Since I could not easily see the traffic, I couldn't figure out what was going on. So I tried the Ollama end point and got a 401 error. When I tried with my API client, using the bearer header, it worked as intended. So I was hoping to just get that working

On that note, the ollama library I think Hoarder uses doesn't document any way to include an API key. That being said according to the source:37, it should be able to take a "headers" property on the initialization call along with the host property.

I was going to try to try and implement this and pitch a fix, but I have no yet had time.