Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to set basic auth as an authentication option for requests #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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