Closed ronneldavis closed 2 months ago
@BruceMacD is this good enough to be merged?
how do you use the headers? I'm using the version 0.5.9
Does it needs something like? ollama-js/src /browser.ts
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: https://github.com/ollama/ollama-js/pull/70
Usage example: