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:
parent
42c07c8e74
commit
e9cebb4810
1 changed files with 11 additions and 0 deletions
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue