Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion pinecone/control/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from .langchain_import_warnings import _build_langchain_attribute_error_message
from pinecone.utils import docslinks

from pinecone.data import _Index, _Inference
from pinecone.data import _Index, _Inference, _AsyncioIndex
from pinecone.enums import (
Metric,
VectorType,
Expand Down Expand Up @@ -314,6 +314,24 @@ def Index(self, name: str = "", host: str = "", **kwargs):
**kwargs,
)

def IndexAsyncio(self, host: str, **kwargs):
api_key = self.config.api_key
openapi_config = self.openapi_config

if host is None or host == "":
raise ValueError("A host must be specified")

check_realistic_host(host)
index_host = normalize_host(host)

return _AsyncioIndex(
host=index_host,
api_key=api_key,
openapi_config=openapi_config,
source_tag=self.config.source_tag,
**kwargs,
)


def check_realistic_host(host: str) -> None:
"""@private
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/data_asyncio/test_client_instantiation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import pytest
from pinecone import Pinecone
from ..helpers import random_string, embedding_values


@pytest.mark.asyncio
async def test_instantiation_through_non_async_client(index_host, dimension):
asyncio_idx = Pinecone().IndexAsyncio(host=index_host)

def emb():
return embedding_values(dimension)

# Upsert with tuples
await asyncio_idx.upsert(
vectors=[("1", emb()), ("2", emb()), ("3", emb())], namespace=random_string(10)
)

await asyncio_idx.close()