This commit is contained in:
Chester Curme 2025-01-10 14:39:15 -05:00
parent 2d76ef9d33
commit e3185a2212
4 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,3 @@
import asyncio
import logging
from typing import Any, Dict, Iterable, List, Optional
@ -66,7 +65,7 @@ class PineconeEmbeddings(BaseModel, Embeddings):
protected_namespaces=(),
)
async def _get_async_client(self) -> aiohttp.ClientSession:
async def get_async_client(self) -> aiohttp.ClientSession:
"""Lazily initialize the async client."""
if self._async_client is None:
self._async_client = aiohttp.ClientSession(
@ -186,7 +185,7 @@ class PineconeEmbeddings(BaseModel, Embeddings):
"inputs": [{"text": text} for text in texts],
"parameters": parameters,
}
client = await self._get_async_client()
client = await self.get_async_client()
async with client.post("https://api.pinecone.io/embed", json=data) as response:
response_data = await response.json(content_type=None)
return response_data

View File

@ -698,7 +698,7 @@ url = "../../core"
[[package]]
name = "langchain-openai"
version = "0.2.14"
version = "0.3.0"
description = "An integration package connecting OpenAI and LangChain"
optional = false
python-versions = ">=3.9,<4.0"
@ -706,7 +706,7 @@ files = []
develop = true
[package.dependencies]
langchain-core = "^0.3.27"
langchain-core = "^0.3.29"
openai = "^1.58.1"
tiktoken = ">=0.7,<1"
@ -2154,4 +2154,4 @@ propcache = ">=0.2.0"
[metadata]
lock-version = "2.0"
python-versions = ">=3.9,<3.13"
content-hash = "c6bfaf9d0fdb71fc6aa80ee07d08a558c6ae414481e47f1feb56edcbd0d16bb1"
content-hash = "244a891a2ad8dd02d0264d86a356e6e5074e2d04830faa93722c8e92fbddb8d3"

View File

@ -18,7 +18,8 @@ NAMESPACE_NAME = "test_namespace"
async def embd_client() -> AsyncGenerator[PineconeEmbeddings, None]:
client = PineconeEmbeddings(model=MODEL)
yield client
await client.async_client.close()
async_client = await client.get_async_client()
await async_client.close()
@pytest.fixture

View File

@ -70,7 +70,7 @@ class TestPineconeEmbeddingsConfig:
assert embeddings._async_client is None
# Access async_client property
client = embeddings.async_client
client = await embeddings.get_async_client()
assert client is not None
assert isinstance(client, aiohttp.ClientSession)