Add bearer token support to API requests - #46
Draft
gromer wants to merge 1 commit into
Draft
Conversation
Owner
|
Suggestion, instead of creating a specific header for the bearer token, we can implement custom HTTP headers. You can check my implementation at swift-llm-chat-openai or swift-llm-chat-anthropic |
Author
I agree. After making this PR, I got thinking about it. Since Ollama doesn't natively support an auth header, a more general header solution does seem the best route. I'll poke around at your other repos, and update this PR soon 🤘 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the use of bearer tokens for authentication in the OllamaKit API requests. The changes include adding a new
bearerTokenproperty to theOllamaKitstruct and updating various methods to include this token when making API requests.Key changes include:
Authentication Enhancement
bearerTokenproperty to theOllamaKitstruct and updated the initializer to accept this token. (Sources/OllamaKit/OllamaKit.swift) [1] [2]asURLRequestmethod inOKRouterto include the bearer token in the request headers if provided. (Sources/OllamaKit/Utils/OKRouter.swift)API Request Updates
chatmethod inOllamaKit+Chat.swift[1] [2]copyModelmethod inOllamaKit+CopyModel.swift[1] [2]deleteModelmethod inOllamaKit+DeleteModel.swift[1] [2]embeddingsmethod inOllamaKit+Embeddings.swift[1] [2]generatemethod inOllamaKit+Generate.swift[1] [2]modelInfomethod inOllamaKit+ModelInfo.swift[1] [2]modelsmethod inOllamaKit+Models.swift[1] [2]pullModelmethod inOllamaKit+PullModel.swift[1] [2]reachablemethod inOllamaKit+Reachable.swift[1] [2]I'm still looking at this, and working on testing it, just wanted to get the initial code into PR form.