mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-18 09:01:03 +00:00
support asyncio 3.10+
This commit is contained in:
parent
2f296549fb
commit
2e9b86a230
@ -1,3 +1,4 @@
|
|||||||
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Dict, Iterable, List, Optional
|
from typing import Any, Dict, Iterable, List, Optional
|
||||||
|
|
||||||
@ -65,17 +66,20 @@ class PineconeEmbeddings(BaseModel, Embeddings):
|
|||||||
protected_namespaces=(),
|
protected_namespaces=(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def _initialize_async_client(self) -> aiohttp.ClientSession:
|
||||||
|
return aiohttp.ClientSession(
|
||||||
|
headers={
|
||||||
|
"Api-Key": self.pinecone_api_key.get_secret_value(),
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"X-Pinecone-API-Version": "2024-10",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def async_client(self) -> aiohttp.ClientSession:
|
def async_client(self) -> aiohttp.ClientSession:
|
||||||
"""Lazily initialize the async client."""
|
"""Lazily initialize the async client."""
|
||||||
if self._async_client is None:
|
if self._async_client is None:
|
||||||
self._async_client = aiohttp.ClientSession(
|
self._async_client = asyncio.run(self._initialize_async_client())
|
||||||
headers={
|
|
||||||
"Api-Key": self.pinecone_api_key.get_secret_value(),
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"X-Pinecone-API-Version": "2024-10",
|
|
||||||
}
|
|
||||||
)
|
|
||||||
return self._async_client
|
return self._async_client
|
||||||
|
|
||||||
@model_validator(mode="before")
|
@model_validator(mode="before")
|
||||||
|
Loading…
Reference in New Issue
Block a user