Skip to content

Fix inference autocomplete #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 21, 2025
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
16 changes: 15 additions & 1 deletion pinecone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@
from .deprecation_warnings import *
from .pinecone import Pinecone
from .pinecone_asyncio import PineconeAsyncio
from .exceptions import *
from .exceptions import (
PineconeException,
PineconeApiTypeError,
PineconeApiValueError,
PineconeApiAttributeError,
PineconeApiKeyError,
PineconeApiException,
NotFoundException,
UnauthorizedException,
ForbiddenException,
ServiceException,
PineconeProtocolError,
PineconeConfigurationError,
ListConversionException,
)

from .utils import __version__

Expand Down
33 changes: 33 additions & 0 deletions pinecone/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
from pinecone.config import Config
from pinecone.config import ConfigBuilder
from pinecone.config import PineconeConfig
from .exceptions import (
PineconeException,
PineconeApiTypeError,
PineconeApiValueError,
PineconeApiAttributeError,
PineconeApiKeyError,
PineconeApiException,
NotFoundException,
UnauthorizedException,
ForbiddenException,
ServiceException,
PineconeProtocolError,
PineconeConfigurationError,
ListConversionException,
)
from pinecone.inference import (
Inference,
AsyncioInference,
RerankModel,
EmbedModel,
ModelInfo,
Expand Down Expand Up @@ -72,7 +89,23 @@ __all__ = [
"Config",
"ConfigBuilder",
"PineconeConfig",
# Exceptions
"PineconeException",
"PineconeApiTypeError",
"PineconeApiValueError",
"PineconeApiAttributeError",
"PineconeApiKeyError",
"PineconeApiException",
"NotFoundException",
"UnauthorizedException",
"ForbiddenException",
"ServiceException",
"PineconeProtocolError",
"PineconeConfigurationError",
"ListConversionException",
# Inference classes
"Inference",
"AsyncioInference",
"RerankModel",
"EmbedModel",
"ModelInfo",
Expand Down
6 changes: 3 additions & 3 deletions pinecone/exceptions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
)

__all__ = [
"PineconeConfigurationError",
"PineconeProtocolError",
"PineconeException",
"PineconeApiAttributeError",
"PineconeApiTypeError",
"PineconeApiValueError",
"PineconeApiAttributeError",
"PineconeApiKeyError",
"PineconeApiException",
"NotFoundException",
"UnauthorizedException",
"ForbiddenException",
"ServiceException",
"PineconeProtocolError",
"PineconeConfigurationError",
"ListConversionException",
]
31 changes: 29 additions & 2 deletions pinecone/exceptions/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def __init__(self, msg, path_to_item=None) -> None:


class PineconeApiAttributeError(PineconeException, AttributeError):
"""Raised when an attribute reference or assignment fails."""

def __init__(self, msg, path_to_item=None) -> None:
"""
Raised when an attribute reference or assignment fails.

Args:
msg (str): the exception message

Expand Down Expand Up @@ -85,6 +85,8 @@ def __init__(self, msg, path_to_item=None) -> None:


class PineconeApiException(PineconeException):
"""Raised when an API exception occurs."""

def __init__(self, status=None, reason=None, http_resp=None) -> None:
if http_resp:
self.status = http_resp.status
Expand All @@ -110,21 +112,29 @@ def __str__(self):


class NotFoundException(PineconeApiException):
"""Raised when a resource is not found."""

def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(NotFoundException, self).__init__(status, reason, http_resp)


class UnauthorizedException(PineconeApiException):
"""Raised when access to a resource is not authorized."""

def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(UnauthorizedException, self).__init__(status, reason, http_resp)


class ForbiddenException(PineconeApiException):
"""Raised when access to a resource is forbidden."""

def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ForbiddenException, self).__init__(status, reason, http_resp)


class ServiceException(PineconeApiException):
"""Raised when a service error occurs."""

def __init__(self, status=None, reason=None, http_resp=None) -> None:
super(ServiceException, self).__init__(status, reason, http_resp)

Expand All @@ -151,3 +161,20 @@ class PineconeConfigurationError(PineconeException):
class ListConversionException(PineconeException, TypeError):
def __init__(self, message):
super().__init__(message)


__all__ = [
"PineconeException",
"PineconeApiTypeError",
"PineconeApiValueError",
"PineconeApiAttributeError",
"PineconeApiKeyError",
"PineconeApiException",
"NotFoundException",
"UnauthorizedException",
"ForbiddenException",
"ServiceException",
"PineconeProtocolError",
"PineconeConfigurationError",
"ListConversionException",
]
19 changes: 7 additions & 12 deletions pinecone/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@

if TYPE_CHECKING:
from pinecone.config import Config, OpenApiConfiguration
from pinecone.db_data import (
_Index as Index,
_Inference as Inference,
_IndexAsyncio as IndexAsyncio,
)
from pinecone.db_control import DBControl
from pinecone.db_data import _Index as Index, _IndexAsyncio as IndexAsyncio
from pinecone.db_control.index_host_store import IndexHostStore
from pinecone.core.openapi.db_control.api.manage_indexes_api import ManageIndexesApi
from pinecone.db_control.types import CreateIndexForModelEmbedTypedDict
Expand Down Expand Up @@ -94,18 +89,18 @@ def __init__(
self._pool_threads = pool_threads
""" @private """

self._inference: Optional["Inference"] = None # Lazy initialization
self._inference = None # Lazy initialization
""" @private """

self._db_control: Optional["DBControl"] = None # Lazy initialization
self._db_control = None # Lazy initialization
""" @private """

super().__init__() # Initialize PluginAware

@property
def inference(self) -> "Inference":
def inference(self):
"""
Inference is a namespace where an instance of the `pinecone.data.features.inference.inference.Inference` class is lazily created and cached.
Inference is a namespace where an instance of the `pinecone.inference.Inference` class is lazily created and cached.
"""
if self._inference is None:
from pinecone.inference import Inference
Expand All @@ -118,9 +113,9 @@ def inference(self) -> "Inference":
return self._inference

@property
def db(self) -> "DBControl":
def db(self):
"""
DBControl is a namespace where an instance of the `pinecone.control.db_control.DBControl` class is lazily created and cached.
DBControl is a namespace where an instance of the `pinecone.db_control.DBControl` class is lazily created and cached.
"""
if self._db_control is None:
from pinecone.db_control import DBControl
Expand Down