-
Notifications
You must be signed in to change notification settings - Fork 203
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
Added optional headers to Ollama initialisation #138
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. This is looking good, nice and simple. Just the one comment about removing the yarn.lock
and we will get this in.
@BruceMacD is this good enough to be merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks again for the contribution
how do you use the headers? Does it needs something like? constructor(config?: Partial<Config>) {
this.config = {
host: '',
}
if (!config?.proxy) {
this.config.host = utils.formatHost(config?.host ?? 'http://127.0.0.1:11434')
}
+ if (!config?.headers {
+ this.config.headers = config.headers
+ }
this.fetch = fetch
if (config?.fetch != null) {
this.fetch = config.fetch
}
} |
headers option is still not working. |
@felixdrp Here's my solution. return new Ollama({
host: env.OLLAMA_URL,
fetch: (
input: string | URL | globalThis.Request,
init?: RequestInit,
): Promise<Response> => {
if (!init) {
init = {};
}
if (!init.headers) {
init.headers = {};
}
init.headers['Authorization'] = `Bearer ${env.OLLAMA_KEY}`;
return fetch(input, init);
},
}); |
This continues on the work done by @kpotter-m2 from this issue: #70
Usage example: