feat: Add custom headers support

This commit is contained in:
n4ze3m
2024-06-30 00:21:43 +05:30
parent 86296c96b6
commit 52f9a2953a
14 changed files with 2126 additions and 1902 deletions

View File

@@ -1,6 +1,7 @@
import { Embeddings, EmbeddingsParams } from "@langchain/core/embeddings"
import type { StringWithAutocomplete } from "@langchain/core/utils/types"
import { parseKeepAlive } from "./utils/ollama"
import { getCustomOllamaHeaders } from "@/services/app"
export interface OllamaInput {
embeddingOnly?: boolean
@@ -213,12 +214,14 @@ export class OllamaEmbeddingsPageAssist extends Embeddings {
"http://127.0.0.1:"
)
}
const customHeaders = await getCustomOllamaHeaders()
const response = await fetch(`${formattedBaseUrl}/api/embeddings`, {
method: "POST",
headers: {
"Content-Type": "application/json",
...this.headers
...this.headers,
...customHeaders
},
body: JSON.stringify({
prompt,