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

# Description
A previous PR (https://github.com/langchain-ai/langchain/pull/15881)
added option to pass headers to ollama endpoint, but headers are not
pass to the async method.
This commit is contained in:
Zhuoyun(John) Xu 2024-01-27 17:11:32 -07:00 committed by GitHub
parent 5e73603e8a
commit 508bde7f40
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -284,7 +284,10 @@ class _OllamaCommon(BaseLanguageModel):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.post( async with session.post(
url=api_url, url=api_url,
headers={"Content-Type": "application/json"}, headers={
"Content-Type": "application/json",
**(self.headers if isinstance(self.headers, dict) else {}),
},
json=request_payload, json=request_payload,
timeout=self.timeout, timeout=self.timeout,
) as response: ) as response: