Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ccurme committed Jan 10, 2025
1 parent 2d76ef9 commit e3185a2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
5 changes: 2 additions & 3 deletions libs/partners/pinecone/langchain_pinecone/embeddings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import asyncio
import logging
from typing import Any, Dict, Iterable, List, Optional

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -186,7 +185,7 @@ async def _aembed_texts(
"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
6 changes: 3 additions & 3 deletions libs/partners/pinecone/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion libs/partners/pinecone/tests/unit_tests/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def test_async_client_initialization(self) -> None:
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)

Expand Down

0 comments on commit e3185a2

Please sign in to comment.