Skip to content

The agent engineering platform.

community[patch]: Ollama - Pass headers to post request in async method (#16660)

Zhuoyun(John) Xu508bde7f40ec
diff --git a/libs/community/langchain_community/llms/ollama.py b/libs/community/langchain_community/llms/ollama.py
index 2d12dd1322..a06ab72641 100644
--- a/libs/community/langchain_community/llms/ollama.py
+++ b/libs/community/langchain_community/llms/ollama.py
@@ -284,7 +284,10 @@ class _OllamaCommon(BaseLanguageModel):
async with aiohttp.ClientSession() as session:
async with session.post(
url=api_url,
- headers={"Content-Type": "application/json"},
+ headers={
+ "Content-Type": "application/json",
+ **(self.headers if isinstance(self.headers, dict) else {}),
+ },
json=request_payload,
timeout=self.timeout,
) as response: