ollama: Add Support for Custom HTTP Headers in Client 🔐 #511
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.
Hello Team,
I've made an update to the
ollama
package to enhance the functionality of theClient
struct. This update allows users to set custom HTTP headers when making requests to the Ollama server.Key Changes:
additionalHeaders
in theClient
struct to store custom headers.NewClient
function to accept custom headers as a parameter.parseHeaders
function to convert header strings to a map.do
andstream
methods of theClient
struct to include custom headers in requests.Why This Change:
Custom HTTP headers are crucial for various use cases, such as setting authentication tokens, customizing content types, or providing API keys. This flexibility is essential for users who need to interact with different types of HTTP-based services through the Ollama client.
Additional Notes:
This change is backward compatible as it adds a new feature without altering the existing functionalities. Users who don't need custom headers can continue to use the client as before.
I believe this enhancement will make the Ollama client more versatile and user-friendly. Looking forward to your feedback and suggestions.
Thank you for considering this contribution!
Best regards tuhochi!