mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-12 12:59:07 +00:00
community[patch]: OllamaEmbeddings - Pass headers to post request (#16880)
## Feature - Set additional headers in constructor - Headers will be sent in post request This feature is useful if deploying Ollama on a cloud service such as hugging face, which requires authentication tokens to be passed in the request header. ## Tests - Test if header is passed - Test if header is not passed Similar to https://github.com/langchain-ai/langchain/pull/15881 --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
@@ -25,7 +25,7 @@ def test_pass_headers_if_provided(monkeypatch: MonkeyPatch) -> None:
|
||||
base_url="https://ollama-hostname:8000",
|
||||
model="foo",
|
||||
headers={
|
||||
"Authentication": "Bearer TEST-TOKEN-VALUE",
|
||||
"Authorization": "Bearer TEST-TOKEN-VALUE",
|
||||
"Referer": "https://application-host",
|
||||
},
|
||||
timeout=300,
|
||||
@@ -35,7 +35,7 @@ def test_pass_headers_if_provided(monkeypatch: MonkeyPatch) -> None:
|
||||
assert url == "https://ollama-hostname:8000/api/generate"
|
||||
assert headers == {
|
||||
"Content-Type": "application/json",
|
||||
"Authentication": "Bearer TEST-TOKEN-VALUE",
|
||||
"Authorization": "Bearer TEST-TOKEN-VALUE",
|
||||
"Referer": "https://application-host",
|
||||
}
|
||||
assert json is not None
|
||||
|
Reference in New Issue
Block a user