mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-17 16:39:52 +00:00
support asyncio 3.10+
This commit is contained in:
parent
2f296549fb
commit
2e9b86a230
@ -1,3 +1,4 @@
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Any, Dict, Iterable, List, Optional
|
||||
|
||||
@ -65,17 +66,20 @@ class PineconeEmbeddings(BaseModel, Embeddings):
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
@property
|
||||
def async_client(self) -> aiohttp.ClientSession:
|
||||
"""Lazily initialize the async client."""
|
||||
if self._async_client is None:
|
||||
self._async_client = aiohttp.ClientSession(
|
||||
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
|
||||
def async_client(self) -> aiohttp.ClientSession:
|
||||
"""Lazily initialize the async client."""
|
||||
if self._async_client is None:
|
||||
self._async_client = asyncio.run(self._initialize_async_client())
|
||||
return self._async_client
|
||||
|
||||
@model_validator(mode="before")
|
||||
|
Loading…
Reference in New Issue
Block a user