Ollama-JS Request Headers Fix (#830)

* add basic auth to ollama llm

* revert btoa api-key change in favor of request headers

* remove unnecessary async

---------

Co-authored-by: Collin Cashio <collin.cashio@cgi.com>
This commit is contained in:
Collin 2024-02-09 13:25:29 -06:00 • committed by GitHub
parent 42c07c8e74
commit e9cebb4810
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,6 +24,7 @@ class Ollama extends BaseLLM {
}
this.fetch(`${this.apiBase}/api/show`, {
method: "POST",
headers: {},
body: JSON.stringify({ name: this._getModel() }),
}).then(async (response) => {
if (response.status !== 200) {
@ -177,6 +178,16 @@ class Ollama extends BaseLLM {
): AsyncGenerator<ChatMessage> {
const client = new ollama.Ollama({
host: this.apiBase,
fetch: (input, config) => {
return fetch(input, {
...config,
headers: {
...(config?.headers || {}),
...(this.requestOptions?.headers || {})
}
});
}
});
const response = await client.chat({
...this._convertArgs(options, messages),