Skip to content

Conversation

cguess
Copy link

@cguess cguess commented Sep 19, 2024

This PR adds the ability to set basic_auth credentials for requests. This is useful if, for instance, you put an Ollama instance behind a NGROK end point and want to add a bit of security to it.

To use there's two options

  1. By setting the username and password separately in a hash
require 'ollama-ai'

client = Ollama.new(
  credentials: {
    address: 'http://localhost:11434',
    basic_auth: { username: 'usrname', password: 'passwd' }
  },
  options: { server_sent_events: true }
)
  1. By setting a string
require 'ollama-ai'

client = Ollama.new(
  credentials: {
    address: 'http://localhost:11434',
    basic_auth: 'usrname:passwd'
  },
  options: { server_sent_events: true }
)

I've updated the README as well. There doesn't seem to be any tests for this repo, but I've tested it locally in my own codebase and it works as indicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant