mirror of
https://github.com/hwchase17/langchain
synced 2024-11-13 19:10:52 +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)
|
||||
|
||||
# Request
|
||||
if self.aiosession is None:
|
||||
self.aiosession = aiohttp.ClientSession(
|
||||
trust_env=True, connector=aiohttp.TCPConnector(limit=32)
|
||||
)
|
||||
async with self.aiosession as session:
|
||||
async with aiohttp.ClientSession(
|
||||
trust_env=True, connector=aiohttp.TCPConnector(limit=32)
|
||||
) as session:
|
||||
embeddings_batch_perm = await asyncio.gather(
|
||||
*[
|
||||
self._async_request(
|
||||
|
Loading…
Reference in New Issue
Block a user