From 49d2593eed33a13300e66aeb9ed538936a14c740 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Sat, 26 Aug 2023 07:15:38 +0000 Subject: [PATCH] Release 0.0.18 --- pyproject.toml | 2 +- src/vocode/__init__.py | 5 +- src/vocode/client.py | 3 + src/vocode/core/client_wrapper.py | 2 +- src/vocode/resources/__init__.py | 4 +- .../resources/vector_databases/__init__.py | 2 + .../resources/vector_databases/client.py | 223 ++++++++++++++++++ src/vocode/types/__init__.py | 2 + src/vocode/types/vector_database_page.py | 29 +++ 9 files changed, 267 insertions(+), 5 deletions(-) create mode 100644 src/vocode/resources/vector_databases/__init__.py create mode 100644 src/vocode/resources/vector_databases/client.py create mode 100644 src/vocode/types/vector_database_page.py diff --git a/pyproject.toml b/pyproject.toml index fba5102..cb4d209 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "vocode-api" -version = "0.0.17" +version = "0.0.18" description = "" readme = "README.md" authors = [] diff --git a/src/vocode/__init__.py b/src/vocode/__init__.py index 81c03e3..4f43a69 100644 --- a/src/vocode/__init__.py +++ b/src/vocode/__init__.py @@ -153,6 +153,7 @@ Usage, ValidationError, ValidationErrorLocItem, + VectorDatabasePage, VoicePage, VoicePageItemsItem, VoicePageItemsItem_VoiceAzure, @@ -183,7 +184,7 @@ WebhookUpdateParamsUrl, ) from .errors import UnprocessableEntityError -from .resources import actions, agents, calls, numbers, prompts, usage, voices, webhooks +from .resources import actions, agents, calls, numbers, prompts, usage, vector_databases, voices, webhooks from .environment import VocodeEnvironment __all__ = [ @@ -340,6 +341,7 @@ "Usage", "ValidationError", "ValidationErrorLocItem", + "VectorDatabasePage", "VocodeEnvironment", "VoicePage", "VoicePageItemsItem", @@ -375,6 +377,7 @@ "numbers", "prompts", "usage", + "vector_databases", "voices", "webhooks", ] diff --git a/src/vocode/client.py b/src/vocode/client.py index 170f807..4dd1982 100644 --- a/src/vocode/client.py +++ b/src/vocode/client.py @@ -12,6 +12,7 @@ from .resources.numbers.client import AsyncNumbersClient, NumbersClient from .resources.prompts.client import AsyncPromptsClient, PromptsClient from .resources.usage.client import AsyncUsageClient, UsageClient +from .resources.vector_databases.client import AsyncVectorDatabasesClient, VectorDatabasesClient from .resources.voices.client import AsyncVoicesClient, VoicesClient from .resources.webhooks.client import AsyncWebhooksClient, WebhooksClient @@ -38,6 +39,7 @@ def __init__( self.voices = VoicesClient(client_wrapper=self._client_wrapper) self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper) self.prompts = PromptsClient(client_wrapper=self._client_wrapper) + self.vector_databases = VectorDatabasesClient(client_wrapper=self._client_wrapper) class AsyncVocode: @@ -62,6 +64,7 @@ def __init__( self.voices = AsyncVoicesClient(client_wrapper=self._client_wrapper) self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper) self.prompts = AsyncPromptsClient(client_wrapper=self._client_wrapper) + self.vector_databases = AsyncVectorDatabasesClient(client_wrapper=self._client_wrapper) def _get_base_url(*, base_url: typing.Optional[str] = None, environment: VocodeEnvironment) -> str: diff --git a/src/vocode/core/client_wrapper.py b/src/vocode/core/client_wrapper.py index e89b6d6..410aa8f 100644 --- a/src/vocode/core/client_wrapper.py +++ b/src/vocode/core/client_wrapper.py @@ -14,7 +14,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "vocode-api", - "X-Fern-SDK-Version": "0.0.17", + "X-Fern-SDK-Version": "0.0.18", } headers["Authorization"] = f"Bearer {self._get_token()}" return headers diff --git a/src/vocode/resources/__init__.py b/src/vocode/resources/__init__.py index 39a757b..8395e09 100644 --- a/src/vocode/resources/__init__.py +++ b/src/vocode/resources/__init__.py @@ -1,5 +1,5 @@ # This file was auto-generated by Fern from our API Definition. -from . import actions, agents, calls, numbers, prompts, usage, voices, webhooks +from . import actions, agents, calls, numbers, prompts, usage, vector_databases, voices, webhooks -__all__ = ["actions", "agents", "calls", "numbers", "prompts", "usage", "voices", "webhooks"] +__all__ = ["actions", "agents", "calls", "numbers", "prompts", "usage", "vector_databases", "voices", "webhooks"] diff --git a/src/vocode/resources/vector_databases/__init__.py b/src/vocode/resources/vector_databases/__init__.py new file mode 100644 index 0000000..f3ea265 --- /dev/null +++ b/src/vocode/resources/vector_databases/__init__.py @@ -0,0 +1,2 @@ +# This file was auto-generated by Fern from our API Definition. + diff --git a/src/vocode/resources/vector_databases/client.py b/src/vocode/resources/vector_databases/client.py new file mode 100644 index 0000000..0e77ea3 --- /dev/null +++ b/src/vocode/resources/vector_databases/client.py @@ -0,0 +1,223 @@ +# This file was auto-generated by Fern from our API Definition. + +import typing +import urllib.parse +from json.decoder import JSONDecodeError + +import pydantic + +from ...core.api_error import ApiError +from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper +from ...core.jsonable_encoder import jsonable_encoder +from ...core.remove_none_from_dict import remove_none_from_dict +from ...errors.unprocessable_entity_error import UnprocessableEntityError +from ...types.http_validation_error import HttpValidationError +from ...types.pinecone_vector_database import PineconeVectorDatabase +from ...types.pinecone_vector_database_params import PineconeVectorDatabaseParams +from ...types.pinecone_vector_database_update_params import PineconeVectorDatabaseUpdateParams +from ...types.vector_database_page import VectorDatabasePage + +# this is used as the default value for optional parameters +OMIT = typing.cast(typing.Any, ...) + + +class VectorDatabasesClient: + def __init__(self, *, client_wrapper: SyncClientWrapper): + self._client_wrapper = client_wrapper + + def get_vector_database(self, *, id: str) -> PineconeVectorDatabase: + """ + Parameters: + - id: str. + """ + _response = self._client_wrapper.httpx_client.request( + "GET", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases"), + params=remove_none_from_dict({"id": id}), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def list_vector_databases( + self, *, page: typing.Optional[int] = None, size: typing.Optional[int] = None + ) -> VectorDatabasePage: + """ + Parameters: + - page: typing.Optional[int]. + + - size: typing.Optional[int]. + """ + _response = self._client_wrapper.httpx_client.request( + "GET", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/list"), + params=remove_none_from_dict({"page": page, "size": size}), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(VectorDatabasePage, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def create_vector_database(self, *, request: PineconeVectorDatabaseParams) -> PineconeVectorDatabase: + """ + Parameters: + - request: PineconeVectorDatabaseParams. + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/create"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + def update_vector_database(self, *, id: str, request: PineconeVectorDatabaseUpdateParams) -> PineconeVectorDatabase: + """ + Parameters: + - id: str. + + - request: PineconeVectorDatabaseUpdateParams. + """ + _response = self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/update"), + params=remove_none_from_dict({"id": id}), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + +class AsyncVectorDatabasesClient: + def __init__(self, *, client_wrapper: AsyncClientWrapper): + self._client_wrapper = client_wrapper + + async def get_vector_database(self, *, id: str) -> PineconeVectorDatabase: + """ + Parameters: + - id: str. + """ + _response = await self._client_wrapper.httpx_client.request( + "GET", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases"), + params=remove_none_from_dict({"id": id}), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def list_vector_databases( + self, *, page: typing.Optional[int] = None, size: typing.Optional[int] = None + ) -> VectorDatabasePage: + """ + Parameters: + - page: typing.Optional[int]. + + - size: typing.Optional[int]. + """ + _response = await self._client_wrapper.httpx_client.request( + "GET", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/list"), + params=remove_none_from_dict({"page": page, "size": size}), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(VectorDatabasePage, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def create_vector_database(self, *, request: PineconeVectorDatabaseParams) -> PineconeVectorDatabase: + """ + Parameters: + - request: PineconeVectorDatabaseParams. + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/create"), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + + async def update_vector_database( + self, *, id: str, request: PineconeVectorDatabaseUpdateParams + ) -> PineconeVectorDatabase: + """ + Parameters: + - id: str. + + - request: PineconeVectorDatabaseUpdateParams. + """ + _response = await self._client_wrapper.httpx_client.request( + "POST", + urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "v1/vector_databases/update"), + params=remove_none_from_dict({"id": id}), + json=jsonable_encoder(request), + headers=self._client_wrapper.get_headers(), + timeout=60, + ) + if 200 <= _response.status_code < 300: + return pydantic.parse_obj_as(PineconeVectorDatabase, _response.json()) # type: ignore + if _response.status_code == 422: + raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore + try: + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) diff --git a/src/vocode/types/__init__.py b/src/vocode/types/__init__.py index 375a0ba..8a0bc07 100644 --- a/src/vocode/types/__init__.py +++ b/src/vocode/types/__init__.py @@ -176,6 +176,7 @@ from .usage import Usage from .validation_error import ValidationError from .validation_error_loc_item import ValidationErrorLocItem +from .vector_database_page import VectorDatabasePage from .voice_page import VoicePage from .voice_page_items_item import ( VoicePageItemsItem, @@ -366,6 +367,7 @@ "Usage", "ValidationError", "ValidationErrorLocItem", + "VectorDatabasePage", "VoicePage", "VoicePageItemsItem", "VoicePageItemsItem_VoiceAzure", diff --git a/src/vocode/types/vector_database_page.py b/src/vocode/types/vector_database_page.py new file mode 100644 index 0000000..a7a8ccc --- /dev/null +++ b/src/vocode/types/vector_database_page.py @@ -0,0 +1,29 @@ +# This file was auto-generated by Fern from our API Definition. + +import datetime as dt +import typing + +import pydantic + +from ..core.datetime_utils import serialize_datetime +from .pinecone_vector_database import PineconeVectorDatabase + + +class VectorDatabasePage(pydantic.BaseModel): + items: typing.List[PineconeVectorDatabase] + page: int + size: int + has_more: bool + + def json(self, **kwargs: typing.Any) -> str: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().json(**kwargs_with_defaults) + + def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]: + kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs} + return super().dict(**kwargs_with_defaults) + + class Config: + frozen = True + smart_union = True + json_encoders = {dt.datetime: serialize_datetime}