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
55 changes: 55 additions & 0 deletions pinecone/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,59 @@ from pinecone.db_control.models import (
ServerlessSpecDefinition,
PodSpec,
PodSpecDefinition,
ByocSpec,
BackupModel,
BackupList,
RestoreJobModel,
RestoreJobList,
)
from pinecone.db_control.models.serverless_spec import (
ScalingConfigManualDict,
ReadCapacityDedicatedConfigDict,
ReadCapacityOnDemandDict,
ReadCapacityDedicatedDict,
ReadCapacityDict,
MetadataSchemaFieldConfig,
)
from pinecone.db_data.filter_builder import FilterBuilder
from pinecone.db_control.types import ConfigureIndexEmbed, CreateIndexForModelEmbedTypedDict
from pinecone.pinecone import Pinecone
from pinecone.pinecone_asyncio import PineconeAsyncio
from pinecone.admin import Admin
from pinecone.utils import __version__

# Deprecated top-level functions
def init(*args: object, **kwargs: object) -> None: ...
def create_index(*args: object, **kwargs: object) -> None: ...
def delete_index(*args: object, **kwargs: object) -> None: ...
def list_indexes(*args: object, **kwargs: object) -> None: ...
def describe_index(*args: object, **kwargs: object) -> None: ...
def configure_index(*args: object, **kwargs: object) -> None: ...
def scale_index(*args: object, **kwargs: object) -> None: ...
def create_collection(*args: object, **kwargs: object) -> None: ...
def delete_collection(*args: object, **kwargs: object) -> None: ...
def describe_collection(*args: object, **kwargs: object) -> None: ...
def list_collections(*args: object, **kwargs: object) -> None: ...

# Re-export all the types
__all__ = [
"__version__",
# Deprecated top-level functions
"init",
"create_index",
"delete_index",
"list_indexes",
"describe_index",
"configure_index",
"scale_index",
"create_collection",
"delete_collection",
"describe_collection",
"list_collections",
# Primary client classes
"Pinecone",
"PineconeAsyncio",
"Admin",
# Config classes
"Config",
"ConfigBuilder",
Expand Down Expand Up @@ -139,6 +182,7 @@ __all__ = [
"UpdateRequest",
"NamespaceDescription",
"ImportErrorMode",
"FilterBuilder",
# Error classes
"VectorDictionaryMissingKeysError",
"VectorDictionaryExcessKeysError",
Expand Down Expand Up @@ -166,7 +210,18 @@ __all__ = [
"ServerlessSpecDefinition",
"PodSpec",
"PodSpecDefinition",
"ByocSpec",
"BackupModel",
"BackupList",
"RestoreJobModel",
"RestoreJobList",
# Control plane types
"ConfigureIndexEmbed",
"CreateIndexForModelEmbedTypedDict",
"ScalingConfigManualDict",
"ReadCapacityDedicatedConfigDict",
"ReadCapacityOnDemandDict",
"ReadCapacityDedicatedDict",
"ReadCapacityDict",
"MetadataSchemaFieldConfig",
]
24 changes: 21 additions & 3 deletions pinecone/db_data/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,13 @@ class UpsertResponseTransformer:
while delegating other methods to the underlying ApplyResult.
"""

def __init__(self, apply_result: ApplyResult):
_apply_result: ApplyResult
""" :meta private: """

def __init__(self, apply_result: ApplyResult) -> None:
self._apply_result = apply_result

def get(self, timeout=None):
def get(self, timeout: float | None = None) -> UpsertResponse:
openapi_response = self._apply_result.get(timeout)
from pinecone.utils.response_info import extract_response_info

Expand All @@ -123,7 +126,7 @@ def get(self, timeout=None):
upserted_count=openapi_response.upserted_count, _response_info=response_info
)

def __getattr__(self, name):
def __getattr__(self, name: str) -> Any:
# Delegate other methods to the underlying ApplyResult
return getattr(self._apply_result, name)

Expand All @@ -134,6 +137,21 @@ class Index(PluginAware, IndexInterface):
For improved performance, use the Pinecone GRPC index client.
"""

_config: "Config"
""" :meta private: """

_openapi_config: "OpenApiConfiguration"
""" :meta private: """

_pool_threads: int
""" :meta private: """

_vector_api: VectorOperationsApi
""" :meta private: """

_api_client: ApiClient
""" :meta private: """

_bulk_import_resource: "BulkImportResource" | None
""" :meta private: """

Expand Down
13 changes: 13 additions & 0 deletions pinecone/db_data/index_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
from .query_results_aggregator import QueryNamespacesResults

if TYPE_CHECKING:
from pinecone.config import Config, OpenApiConfiguration
from .resources.asyncio.bulk_import_asyncio import BulkImportResourceAsyncio
from .resources.asyncio.namespace_asyncio import NamespaceResourceAsyncio

Expand Down Expand Up @@ -168,6 +169,18 @@ async def main():
Failing to do this may result in error messages appearing from the underlyling aiohttp library.
"""

config: "Config"
""" :meta private: """

_openapi_config: "OpenApiConfiguration"
""" :meta private: """

_vector_api: AsyncioVectorOperationsApi
""" :meta private: """

_api_client: AsyncioApiClient
""" :meta private: """

_bulk_import_resource: "BulkImportResourceAsyncio" | None
""" :meta private: """

Expand Down
2 changes: 1 addition & 1 deletion pinecone/grpc/resources/vector_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _upsert_batch(
def upsert_from_dataframe(
self,
df,
namespace: Optional[str] = None,
namespace: str | None = None,
batch_size: int = 500,
use_async_requests: bool = True,
show_progress: bool = True,
Expand Down
3 changes: 1 addition & 2 deletions pinecone/inference/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ def embed(
``n`` embeddings, where ``n`` = len(inputs). Precision of returned embeddings is either
float16 or float32, with float32 being the default. ``model`` key is the model used to generate the embeddings.
``usage`` key contains the total number of tokens used at request-time.

Example:
:rtype: EmbeddingsList

.. code-block:: python

Expand Down
3 changes: 3 additions & 0 deletions pinecone/utils/plugin_aware.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class PluginAware:
can't be changed without breaking compatibility with plugins in the wild.
"""

_plugins_loaded: bool
""" :meta private: """

def __init__(self, *args: Any, **kwargs: Any) -> None:
"""
Initialize the PluginAware class.
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["pinecone"]
include = ["pinecone/py.typed"]

[tool.pytest.ini_options]
asyncio_mode = "strict"
Expand Down
Loading