mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 21:33:51 +00:00
community: Fix closed session in Infinity (#26933)
**Description:**
The `aiohttp.ClientSession` is closed at the end of the with statement,
which causes an error during a second call.
The implemented fix is to define the session directly within the with
block, exactly like in the textembed code:
c6350d636e/libs/community/langchain_community/embeddings/textembed.py (L335-L346)
**Issue:** Fix #26932
Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
parent
8895d468cb
commit
440c162b8b
@ -306,11 +306,9 @@ class TinyAsyncOpenAIInfinityEmbeddingClient: #: :meta private:
|
|||||||
perm_texts_batched = self._batch(perm_texts)
|
perm_texts_batched = self._batch(perm_texts)
|
||||||
|
|
||||||
# Request
|
# Request
|
||||||
if self.aiosession is None:
|
async with aiohttp.ClientSession(
|
||||||
self.aiosession = aiohttp.ClientSession(
|
trust_env=True, connector=aiohttp.TCPConnector(limit=32)
|
||||||
trust_env=True, connector=aiohttp.TCPConnector(limit=32)
|
) as session:
|
||||||
)
|
|
||||||
async with self.aiosession as session:
|
|
||||||
embeddings_batch_perm = await asyncio.gather(
|
embeddings_batch_perm = await asyncio.gather(
|
||||||
*[
|
*[
|
||||||
self._async_request(
|
self._async_request(
|
||||||
|
Loading…
Reference in New Issue
Block a user