diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4029396..c8a8a4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,6 @@ jobs: lint: name: lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 @@ -30,6 +29,7 @@ jobs: - name: Run lints run: ./scripts/lint + test: name: test runs-on: ubuntu-latest @@ -50,4 +50,3 @@ jobs: - name: Run tests run: ./scripts/test - diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f14b480..aaf968a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.2" + ".": "0.1.0-alpha.3" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 5b5b50e..d9064ff 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 13 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-79503f9599a8cf36cc6b746114d49c484fc8615cf4d8ef979dc299a88d3045d0.yml +configured_endpoints: 15 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/zeroentropy%2Fzeroentropy-99a41bb73e432cb47fe1937219b3c7b109ae534456e8dd019cc00cc1e6018a16.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index b7f01a0..b830f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.3 (2025-01-28) + +Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/zeroentropy-ai/zeroentropy-python/compare/v0.1.0-alpha.2...v0.1.0-alpha.3) + +### Chores + +* go live ([#15](https://github.com/zeroentropy-ai/zeroentropy-python/issues/15)) ([94648e3](https://github.com/zeroentropy-ai/zeroentropy-python/commit/94648e31f00197387695a5b5d0f832f179f6bd99)) + ## 0.1.0-alpha.2 (2025-01-18) Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/zeroentropy-ai/zeroentropy-python/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) diff --git a/api.md b/api.md index efe193f..8c93fa7 100644 --- a/api.md +++ b/api.md @@ -1,3 +1,15 @@ +# Admin + +Types: + +```python +from zeroentropy.types import AdminCreateOrganizationResponse +``` + +Methods: + +- client.admin.create_organization(\*\*params) -> AdminCreateOrganizationResponse + # Status Types: @@ -34,6 +46,7 @@ Types: ```python from zeroentropy.types import ( + DocumentUpdateResponse, DocumentDeleteResponse, DocumentAddResponse, DocumentGetInfoResponse, @@ -44,6 +57,7 @@ from zeroentropy.types import ( Methods: +- client.documents.update(\*\*params) -> DocumentUpdateResponse - client.documents.delete(\*\*params) -> DocumentDeleteResponse - client.documents.add(\*\*params) -> DocumentAddResponse - client.documents.get_info(\*\*params) -> DocumentGetInfoResponse diff --git a/pyproject.toml b/pyproject.toml index c165760..164fad7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "zeroentropy" -version = "0.1.0-alpha.2" +version = "0.1.0-alpha.3" description = "The official Python library for the ZeroEntropy API" dynamic = ["readme"] license = "Apache-2.0" @@ -129,6 +129,7 @@ testpaths = ["tests"] addopts = "--tb=short" xfail_strict = true asyncio_mode = "auto" +asyncio_default_fixture_loop_scope = "session" filterwarnings = [ "error" ] diff --git a/scripts/bootstrap b/scripts/bootstrap index 8c5c60e..e84fe62 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,7 +4,7 @@ set -e cd "$(dirname "$0")/.." -if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then brew bundle check >/dev/null 2>&1 || { echo "==> Installing Homebrew dependencies…" brew bundle diff --git a/scripts/lint b/scripts/lint index 7a34bc9..8958b25 100755 --- a/scripts/lint +++ b/scripts/lint @@ -9,4 +9,3 @@ rye run lint echo "==> Making sure it imports" rye run python -c 'import zeroentropy' - diff --git a/src/zeroentropy/_client.py b/src/zeroentropy/_client.py index d1188b3..9b3dc0f 100644 --- a/src/zeroentropy/_client.py +++ b/src/zeroentropy/_client.py @@ -24,7 +24,7 @@ get_async_library, ) from ._version import __version__ -from .resources import status, parsers, queries, documents, collections +from .resources import admin, status, parsers, queries, documents, collections from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import APIStatusError, ZeroEntropyError from ._base_client import ( @@ -46,6 +46,7 @@ class ZeroEntropy(SyncAPIClient): + admin: admin.AdminResource status: status.StatusResource collections: collections.CollectionsResource documents: documents.DocumentsResource @@ -108,6 +109,7 @@ def __init__( _strict_response_validation=_strict_response_validation, ) + self.admin = admin.AdminResource(self) self.status = status.StatusResource(self) self.collections = collections.CollectionsResource(self) self.documents = documents.DocumentsResource(self) @@ -222,6 +224,7 @@ def _make_status_error( class AsyncZeroEntropy(AsyncAPIClient): + admin: admin.AsyncAdminResource status: status.AsyncStatusResource collections: collections.AsyncCollectionsResource documents: documents.AsyncDocumentsResource @@ -284,6 +287,7 @@ def __init__( _strict_response_validation=_strict_response_validation, ) + self.admin = admin.AsyncAdminResource(self) self.status = status.AsyncStatusResource(self) self.collections = collections.AsyncCollectionsResource(self) self.documents = documents.AsyncDocumentsResource(self) @@ -399,6 +403,7 @@ def _make_status_error( class ZeroEntropyWithRawResponse: def __init__(self, client: ZeroEntropy) -> None: + self.admin = admin.AdminResourceWithRawResponse(client.admin) self.status = status.StatusResourceWithRawResponse(client.status) self.collections = collections.CollectionsResourceWithRawResponse(client.collections) self.documents = documents.DocumentsResourceWithRawResponse(client.documents) @@ -408,6 +413,7 @@ def __init__(self, client: ZeroEntropy) -> None: class AsyncZeroEntropyWithRawResponse: def __init__(self, client: AsyncZeroEntropy) -> None: + self.admin = admin.AsyncAdminResourceWithRawResponse(client.admin) self.status = status.AsyncStatusResourceWithRawResponse(client.status) self.collections = collections.AsyncCollectionsResourceWithRawResponse(client.collections) self.documents = documents.AsyncDocumentsResourceWithRawResponse(client.documents) @@ -417,6 +423,7 @@ def __init__(self, client: AsyncZeroEntropy) -> None: class ZeroEntropyWithStreamedResponse: def __init__(self, client: ZeroEntropy) -> None: + self.admin = admin.AdminResourceWithStreamingResponse(client.admin) self.status = status.StatusResourceWithStreamingResponse(client.status) self.collections = collections.CollectionsResourceWithStreamingResponse(client.collections) self.documents = documents.DocumentsResourceWithStreamingResponse(client.documents) @@ -426,6 +433,7 @@ def __init__(self, client: ZeroEntropy) -> None: class AsyncZeroEntropyWithStreamedResponse: def __init__(self, client: AsyncZeroEntropy) -> None: + self.admin = admin.AsyncAdminResourceWithStreamingResponse(client.admin) self.status = status.AsyncStatusResourceWithStreamingResponse(client.status) self.collections = collections.AsyncCollectionsResourceWithStreamingResponse(client.collections) self.documents = documents.AsyncDocumentsResourceWithStreamingResponse(client.documents) diff --git a/src/zeroentropy/_response.py b/src/zeroentropy/_response.py index 29cc579..e23a0c7 100644 --- a/src/zeroentropy/_response.py +++ b/src/zeroentropy/_response.py @@ -136,6 +136,8 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: if cast_to and is_annotated_type(cast_to): cast_to = extract_type_arg(cast_to, 0) + origin = get_origin(cast_to) or cast_to + if self._is_sse_stream: if to: if not is_stream_class_type(to): @@ -195,8 +197,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T: if cast_to == bool: return cast(R, response.text.lower() == "true") - origin = get_origin(cast_to) or cast_to - if origin == APIResponse: raise RuntimeError("Unexpected state - cast_to is `APIResponse`") diff --git a/src/zeroentropy/_version.py b/src/zeroentropy/_version.py index 772aa09..f43d082 100644 --- a/src/zeroentropy/_version.py +++ b/src/zeroentropy/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "zeroentropy" -__version__ = "0.1.0-alpha.2" # x-release-please-version +__version__ = "0.1.0-alpha.3" # x-release-please-version diff --git a/src/zeroentropy/resources/__init__.py b/src/zeroentropy/resources/__init__.py index 5ff78db..d4929d1 100644 --- a/src/zeroentropy/resources/__init__.py +++ b/src/zeroentropy/resources/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .admin import ( + AdminResource, + AsyncAdminResource, + AdminResourceWithRawResponse, + AsyncAdminResourceWithRawResponse, + AdminResourceWithStreamingResponse, + AsyncAdminResourceWithStreamingResponse, +) from .status import ( StatusResource, AsyncStatusResource, @@ -42,6 +50,12 @@ ) __all__ = [ + "AdminResource", + "AsyncAdminResource", + "AdminResourceWithRawResponse", + "AsyncAdminResourceWithRawResponse", + "AdminResourceWithStreamingResponse", + "AsyncAdminResourceWithStreamingResponse", "StatusResource", "AsyncStatusResource", "StatusResourceWithRawResponse", diff --git a/src/zeroentropy/resources/admin.py b/src/zeroentropy/resources/admin.py new file mode 100644 index 0000000..21bc16e --- /dev/null +++ b/src/zeroentropy/resources/admin.py @@ -0,0 +1,184 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from ..types import admin_create_organization_params +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._utils import ( + maybe_transform, + async_maybe_transform, +) +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options +from ..types.admin_create_organization_response import AdminCreateOrganizationResponse + +__all__ = ["AdminResource", "AsyncAdminResource"] + + +class AdminResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> AdminResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers + """ + return AdminResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AdminResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#with_streaming_response + """ + return AdminResourceWithStreamingResponse(self) + + def create_organization( + self, + *, + organization_name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AdminCreateOrganizationResponse: + """Creates or updates an organization with the provided organization name. + + An API + Key will be returned. + + Returns 201 if a new organization was created, 200 if an existing organization + was found. + + Args: + organization_name: The orgniazation name to create. Must be unique. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/admin/create-organization", + body=maybe_transform( + {"organization_name": organization_name}, admin_create_organization_params.AdminCreateOrganizationParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AdminCreateOrganizationResponse, + ) + + +class AsyncAdminResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncAdminResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers + """ + return AsyncAdminResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncAdminResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#with_streaming_response + """ + return AsyncAdminResourceWithStreamingResponse(self) + + async def create_organization( + self, + *, + organization_name: str, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> AdminCreateOrganizationResponse: + """Creates or updates an organization with the provided organization name. + + An API + Key will be returned. + + Returns 201 if a new organization was created, 200 if an existing organization + was found. + + Args: + organization_name: The orgniazation name to create. Must be unique. + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/admin/create-organization", + body=await async_maybe_transform( + {"organization_name": organization_name}, admin_create_organization_params.AdminCreateOrganizationParams + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=AdminCreateOrganizationResponse, + ) + + +class AdminResourceWithRawResponse: + def __init__(self, admin: AdminResource) -> None: + self._admin = admin + + self.create_organization = to_raw_response_wrapper( + admin.create_organization, + ) + + +class AsyncAdminResourceWithRawResponse: + def __init__(self, admin: AsyncAdminResource) -> None: + self._admin = admin + + self.create_organization = async_to_raw_response_wrapper( + admin.create_organization, + ) + + +class AdminResourceWithStreamingResponse: + def __init__(self, admin: AdminResource) -> None: + self._admin = admin + + self.create_organization = to_streamed_response_wrapper( + admin.create_organization, + ) + + +class AsyncAdminResourceWithStreamingResponse: + def __init__(self, admin: AsyncAdminResource) -> None: + self._admin = admin + + self.create_organization = async_to_streamed_response_wrapper( + admin.create_organization, + ) diff --git a/src/zeroentropy/resources/collections.py b/src/zeroentropy/resources/collections.py index e0a1bac..17809e2 100644 --- a/src/zeroentropy/resources/collections.py +++ b/src/zeroentropy/resources/collections.py @@ -30,7 +30,7 @@ class CollectionsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> CollectionsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -145,7 +145,7 @@ class AsyncCollectionsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncCollectionsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers diff --git a/src/zeroentropy/resources/documents.py b/src/zeroentropy/resources/documents.py index 89fd552..0d195a2 100644 --- a/src/zeroentropy/resources/documents.py +++ b/src/zeroentropy/resources/documents.py @@ -9,6 +9,7 @@ from ..types import ( document_add_params, document_delete_params, + document_update_params, document_get_info_params, document_get_info_list_params, document_get_page_info_params, @@ -30,6 +31,7 @@ from .._base_client import AsyncPaginator, make_request_options from ..types.document_add_response import DocumentAddResponse from ..types.document_delete_response import DocumentDeleteResponse +from ..types.document_update_response import DocumentUpdateResponse from ..types.document_get_info_response import DocumentGetInfoResponse from ..types.document_get_info_list_response import DocumentGetInfoListResponse from ..types.document_get_page_info_response import DocumentGetPageInfoResponse @@ -41,7 +43,7 @@ class DocumentsResource(SyncAPIResource): @cached_property def with_raw_response(self) -> DocumentsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -57,6 +59,70 @@ def with_streaming_response(self) -> DocumentsResourceWithStreamingResponse: """ return DocumentsResourceWithStreamingResponse(self) + def update( + self, + *, + collection_name: str, + path: str, + metadata: Optional[Dict[str, Union[str, List[str]]]] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DocumentUpdateResponse: + """Updates a document. + + This endpoint is atomic. + + The only attribute currently supported for update is `metadata`. This endpoint + can only be called with a non-null `metadata` if the document status is + `indexed`. + + Sometimes, when updating a document, a new document ID will be assigned and the + previous will be deleted. For this reason, the previous and the new document ID + will both be returned in the response. If the document ID was not updated, then + these two IDs will be identical. + + A `404 Not Found` status code will be returned, if the provided collection name + or document path does not exist. + + Args: + collection_name: The name of the collection. + + path: The filepath of the document that you are updating. A `404 Not Found` status + code will be returned if no document with this path was found. + + metadata: If this field is provided, the given metadata json will replace the document's + existing metadata json. In other words, if you want to add a new field, you will + need to provide the entire metadata object (Both the original fields, and the + new field). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return self._post( + "/documents/update-document", + body=maybe_transform( + { + "collection_name": collection_name, + "path": path, + "metadata": metadata, + }, + document_update_params.DocumentUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DocumentUpdateResponse, + ) + def delete( self, *, @@ -305,7 +371,6 @@ def get_page_info( page_index: int, path: str, include_content: bool | NotGiven = NOT_GIVEN, - include_image: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -336,14 +401,6 @@ def get_page_info( include_content: If `true`, then the response will have the `content` attribute be a `string`, rather than `null`. This string will contain the full contents of the page. - include_image: If `true`, then the response will have the `image_base64_data` attribute be a - `string`\\**, rather than `null`. This string will contain the image data of the - document, as a base64-encoded string. Currently, this data is guaranteed to be a - JPEG-encoded image. - - \\**Note that the response may still be `null`, if the page has no image data, - such as if the document was uploaded with raw text rather than as a PDF. - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -360,7 +417,6 @@ def get_page_info( "page_index": page_index, "path": path, "include_content": include_content, - "include_image": include_image, }, document_get_page_info_params.DocumentGetPageInfoParams, ), @@ -375,7 +431,7 @@ class AsyncDocumentsResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncDocumentsResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -391,6 +447,70 @@ def with_streaming_response(self) -> AsyncDocumentsResourceWithStreamingResponse """ return AsyncDocumentsResourceWithStreamingResponse(self) + async def update( + self, + *, + collection_name: str, + path: str, + metadata: Optional[Dict[str, Union[str, List[str]]]] | NotGiven = NOT_GIVEN, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> DocumentUpdateResponse: + """Updates a document. + + This endpoint is atomic. + + The only attribute currently supported for update is `metadata`. This endpoint + can only be called with a non-null `metadata` if the document status is + `indexed`. + + Sometimes, when updating a document, a new document ID will be assigned and the + previous will be deleted. For this reason, the previous and the new document ID + will both be returned in the response. If the document ID was not updated, then + these two IDs will be identical. + + A `404 Not Found` status code will be returned, if the provided collection name + or document path does not exist. + + Args: + collection_name: The name of the collection. + + path: The filepath of the document that you are updating. A `404 Not Found` status + code will be returned if no document with this path was found. + + metadata: If this field is provided, the given metadata json will replace the document's + existing metadata json. In other words, if you want to add a new field, you will + need to provide the entire metadata object (Both the original fields, and the + new field). + + extra_headers: Send extra headers + + extra_query: Add additional query parameters to the request + + extra_body: Add additional JSON properties to the request + + timeout: Override the client-level default timeout for this request, in seconds + """ + return await self._post( + "/documents/update-document", + body=await async_maybe_transform( + { + "collection_name": collection_name, + "path": path, + "metadata": metadata, + }, + document_update_params.DocumentUpdateParams, + ), + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=DocumentUpdateResponse, + ) + async def delete( self, *, @@ -639,7 +759,6 @@ async def get_page_info( page_index: int, path: str, include_content: bool | NotGiven = NOT_GIVEN, - include_image: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -670,14 +789,6 @@ async def get_page_info( include_content: If `true`, then the response will have the `content` attribute be a `string`, rather than `null`. This string will contain the full contents of the page. - include_image: If `true`, then the response will have the `image_base64_data` attribute be a - `string`\\**, rather than `null`. This string will contain the image data of the - document, as a base64-encoded string. Currently, this data is guaranteed to be a - JPEG-encoded image. - - \\**Note that the response may still be `null`, if the page has no image data, - such as if the document was uploaded with raw text rather than as a PDF. - extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -694,7 +805,6 @@ async def get_page_info( "page_index": page_index, "path": path, "include_content": include_content, - "include_image": include_image, }, document_get_page_info_params.DocumentGetPageInfoParams, ), @@ -709,6 +819,9 @@ class DocumentsResourceWithRawResponse: def __init__(self, documents: DocumentsResource) -> None: self._documents = documents + self.update = to_raw_response_wrapper( + documents.update, + ) self.delete = to_raw_response_wrapper( documents.delete, ) @@ -730,6 +843,9 @@ class AsyncDocumentsResourceWithRawResponse: def __init__(self, documents: AsyncDocumentsResource) -> None: self._documents = documents + self.update = async_to_raw_response_wrapper( + documents.update, + ) self.delete = async_to_raw_response_wrapper( documents.delete, ) @@ -751,6 +867,9 @@ class DocumentsResourceWithStreamingResponse: def __init__(self, documents: DocumentsResource) -> None: self._documents = documents + self.update = to_streamed_response_wrapper( + documents.update, + ) self.delete = to_streamed_response_wrapper( documents.delete, ) @@ -772,6 +891,9 @@ class AsyncDocumentsResourceWithStreamingResponse: def __init__(self, documents: AsyncDocumentsResource) -> None: self._documents = documents + self.update = async_to_streamed_response_wrapper( + documents.update, + ) self.delete = async_to_streamed_response_wrapper( documents.delete, ) diff --git a/src/zeroentropy/resources/parsers.py b/src/zeroentropy/resources/parsers.py index 1b0891a..9fccea6 100644 --- a/src/zeroentropy/resources/parsers.py +++ b/src/zeroentropy/resources/parsers.py @@ -28,7 +28,7 @@ class ParsersResource(SyncAPIResource): @cached_property def with_raw_response(self) -> ParsersResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -90,7 +90,7 @@ class AsyncParsersResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncParsersResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers diff --git a/src/zeroentropy/resources/queries.py b/src/zeroentropy/resources/queries.py index 7111d21..3ae0187 100644 --- a/src/zeroentropy/resources/queries.py +++ b/src/zeroentropy/resources/queries.py @@ -3,6 +3,7 @@ from __future__ import annotations from typing import Dict, Optional +from typing_extensions import Literal import httpx @@ -32,7 +33,7 @@ class QueriesResource(SyncAPIResource): @cached_property def with_raw_response(self) -> QueriesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -56,6 +57,7 @@ def top_documents( query: str, filter: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, include_metadata: bool | NotGiven = NOT_GIVEN, + latency_mode: Literal["low", "high"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -82,6 +84,12 @@ def top_documents( include_metadata: Whether or not to include the metadata in the top documents response. If not provided, then the default will be `False`. + latency_mode: This option selects between our two latency modes. The higher latency mode takes + longer, but can allow for more accurate responses. If desired, test both to + customize your search experience for your particular use-case, or use the + default of "low" and only swap if you need an additional improvement in search + result quality. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -99,6 +107,7 @@ def top_documents( "query": query, "filter": filter, "include_metadata": include_metadata, + "latency_mode": latency_mode, }, query_top_documents_params.QueryTopDocumentsParams, ), @@ -116,6 +125,7 @@ def top_pages( query: str, filter: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, include_content: bool | NotGiven = NOT_GIVEN, + latency_mode: Literal["low", "high"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -141,6 +151,12 @@ def top_pages( include_content: If set to true, then the content of all pages will be returned. + latency_mode: This option selects between our two latency modes. The higher latency mode takes + longer, but can allow for more accurate responses. If desired, test both to + customize your search experience for your particular use-case, or use the + default of "low" and only swap if you need an additional improvement in search + result quality. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -158,6 +174,7 @@ def top_pages( "query": query, "filter": filter, "include_content": include_content, + "latency_mode": latency_mode, }, query_top_pages_params.QueryTopPagesParams, ), @@ -174,6 +191,7 @@ def top_snippets( k: int, query: str, filter: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + latency_mode: Literal["low"] | NotGiven = NOT_GIVEN, precise_responses: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -202,6 +220,12 @@ def top_snippets( filter: The query filter to apply. Please read [Metadata Filtering](/metadata-filtering) for more information. If not provided, then all documents will be searched. + latency_mode: Note that for Top K Snippets, only latency_mode "low" is available. This option + selects between our latency modes. The higher latency mode takes longer, but can + allow for more accurate responses. If desired, test both to customize your + search experience for your particular use-case, or use the default of "low" and + only swap if you need an additional improvement in search result quality. + precise_responses: Enable precise responses. Precise responses will have higher latency, but provide much more precise snippets. When `precise_responses` is set to `true`, the responses will average 200 characters. If set to `false`, the responses will @@ -223,6 +247,7 @@ def top_snippets( "k": k, "query": query, "filter": filter, + "latency_mode": latency_mode, "precise_responses": precise_responses, }, query_top_snippets_params.QueryTopSnippetsParams, @@ -238,7 +263,7 @@ class AsyncQueriesResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncQueriesResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -262,6 +287,7 @@ async def top_documents( query: str, filter: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, include_metadata: bool | NotGiven = NOT_GIVEN, + latency_mode: Literal["low", "high"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -288,6 +314,12 @@ async def top_documents( include_metadata: Whether or not to include the metadata in the top documents response. If not provided, then the default will be `False`. + latency_mode: This option selects between our two latency modes. The higher latency mode takes + longer, but can allow for more accurate responses. If desired, test both to + customize your search experience for your particular use-case, or use the + default of "low" and only swap if you need an additional improvement in search + result quality. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -305,6 +337,7 @@ async def top_documents( "query": query, "filter": filter, "include_metadata": include_metadata, + "latency_mode": latency_mode, }, query_top_documents_params.QueryTopDocumentsParams, ), @@ -322,6 +355,7 @@ async def top_pages( query: str, filter: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, include_content: bool | NotGiven = NOT_GIVEN, + latency_mode: Literal["low", "high"] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -347,6 +381,12 @@ async def top_pages( include_content: If set to true, then the content of all pages will be returned. + latency_mode: This option selects between our two latency modes. The higher latency mode takes + longer, but can allow for more accurate responses. If desired, test both to + customize your search experience for your particular use-case, or use the + default of "low" and only swap if you need an additional improvement in search + result quality. + extra_headers: Send extra headers extra_query: Add additional query parameters to the request @@ -364,6 +404,7 @@ async def top_pages( "query": query, "filter": filter, "include_content": include_content, + "latency_mode": latency_mode, }, query_top_pages_params.QueryTopPagesParams, ), @@ -380,6 +421,7 @@ async def top_snippets( k: int, query: str, filter: Optional[Dict[str, object]] | NotGiven = NOT_GIVEN, + latency_mode: Literal["low"] | NotGiven = NOT_GIVEN, precise_responses: bool | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -408,6 +450,12 @@ async def top_snippets( filter: The query filter to apply. Please read [Metadata Filtering](/metadata-filtering) for more information. If not provided, then all documents will be searched. + latency_mode: Note that for Top K Snippets, only latency_mode "low" is available. This option + selects between our latency modes. The higher latency mode takes longer, but can + allow for more accurate responses. If desired, test both to customize your + search experience for your particular use-case, or use the default of "low" and + only swap if you need an additional improvement in search result quality. + precise_responses: Enable precise responses. Precise responses will have higher latency, but provide much more precise snippets. When `precise_responses` is set to `true`, the responses will average 200 characters. If set to `false`, the responses will @@ -429,6 +477,7 @@ async def top_snippets( "k": k, "query": query, "filter": filter, + "latency_mode": latency_mode, "precise_responses": precise_responses, }, query_top_snippets_params.QueryTopSnippetsParams, diff --git a/src/zeroentropy/resources/status.py b/src/zeroentropy/resources/status.py index fca817c..fe605b0 100644 --- a/src/zeroentropy/resources/status.py +++ b/src/zeroentropy/resources/status.py @@ -30,7 +30,7 @@ class StatusResource(SyncAPIResource): @cached_property def with_raw_response(self) -> StatusResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers @@ -93,7 +93,7 @@ class AsyncStatusResource(AsyncAPIResource): @cached_property def with_raw_response(self) -> AsyncStatusResourceWithRawResponse: """ - This property can be used as a prefix for any HTTP method call to return the + This property can be used as a prefix for any HTTP method call to return the raw response object instead of the parsed content. For more information, see https://www.github.com/zeroentropy-ai/zeroentropy-python#accessing-raw-response-data-eg-headers diff --git a/src/zeroentropy/types/__init__.py b/src/zeroentropy/types/__init__.py index f6eed1a..637283b 100644 --- a/src/zeroentropy/types/__init__.py +++ b/src/zeroentropy/types/__init__.py @@ -6,11 +6,13 @@ from .collection_add_params import CollectionAddParams as CollectionAddParams from .document_add_response import DocumentAddResponse as DocumentAddResponse from .document_delete_params import DocumentDeleteParams as DocumentDeleteParams +from .document_update_params import DocumentUpdateParams as DocumentUpdateParams from .query_top_pages_params import QueryTopPagesParams as QueryTopPagesParams from .collection_add_response import CollectionAddResponse as CollectionAddResponse from .collection_delete_params import CollectionDeleteParams as CollectionDeleteParams from .document_delete_response import DocumentDeleteResponse as DocumentDeleteResponse from .document_get_info_params import DocumentGetInfoParams as DocumentGetInfoParams +from .document_update_response import DocumentUpdateResponse as DocumentUpdateResponse from .query_top_pages_response import QueryTopPagesResponse as QueryTopPagesResponse from .status_get_status_params import StatusGetStatusParams as StatusGetStatusParams from .query_top_snippets_params import QueryTopSnippetsParams as QueryTopSnippetsParams @@ -27,3 +29,5 @@ from .parser_parse_document_response import ParserParseDocumentResponse as ParserParseDocumentResponse from .document_get_info_list_response import DocumentGetInfoListResponse as DocumentGetInfoListResponse from .document_get_page_info_response import DocumentGetPageInfoResponse as DocumentGetPageInfoResponse +from .admin_create_organization_params import AdminCreateOrganizationParams as AdminCreateOrganizationParams +from .admin_create_organization_response import AdminCreateOrganizationResponse as AdminCreateOrganizationResponse diff --git a/src/zeroentropy/types/admin_create_organization_params.py b/src/zeroentropy/types/admin_create_organization_params.py new file mode 100644 index 0000000..f1345b4 --- /dev/null +++ b/src/zeroentropy/types/admin_create_organization_params.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Required, TypedDict + +__all__ = ["AdminCreateOrganizationParams"] + + +class AdminCreateOrganizationParams(TypedDict, total=False): + organization_name: Required[str] + """The orgniazation name to create. Must be unique.""" diff --git a/src/zeroentropy/types/admin_create_organization_response.py b/src/zeroentropy/types/admin_create_organization_response.py new file mode 100644 index 0000000..b1d4b8d --- /dev/null +++ b/src/zeroentropy/types/admin_create_organization_response.py @@ -0,0 +1,14 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from .._models import BaseModel + +__all__ = ["AdminCreateOrganizationResponse"] + + +class AdminCreateOrganizationResponse(BaseModel): + api_key: str + """The API Key for this organization.""" + + organization_name: str + """The name of the organization""" diff --git a/src/zeroentropy/types/document_get_info_list_response.py b/src/zeroentropy/types/document_get_info_list_response.py index 0b91bb1..a8f1189 100644 --- a/src/zeroentropy/types/document_get_info_list_response.py +++ b/src/zeroentropy/types/document_get_info_list_response.py @@ -13,7 +13,9 @@ class DocumentGetInfoListResponse(BaseModel): collection_name: str - index_status: Literal["parsing_failed", "not_parsed", "not_indexed", "indexing", "indexed"] + index_status: Literal[ + "not_parsed", "parsing", "not_indexed", "indexing", "indexed", "parsing_failed", "indexing_failed" + ] metadata: Dict[str, Union[str, List[str]]] diff --git a/src/zeroentropy/types/document_get_info_response.py b/src/zeroentropy/types/document_get_info_response.py index 4c829db..7880c75 100644 --- a/src/zeroentropy/types/document_get_info_response.py +++ b/src/zeroentropy/types/document_get_info_response.py @@ -13,7 +13,9 @@ class Document(BaseModel): collection_name: str - index_status: Literal["parsing_failed", "not_parsed", "not_indexed", "indexing", "indexed"] + index_status: Literal[ + "not_parsed", "parsing", "not_indexed", "indexing", "indexed", "parsing_failed", "indexing_failed" + ] metadata: Dict[str, Union[str, List[str]]] diff --git a/src/zeroentropy/types/document_get_page_info_params.py b/src/zeroentropy/types/document_get_page_info_params.py index 73060a4..dee2c66 100644 --- a/src/zeroentropy/types/document_get_page_info_params.py +++ b/src/zeroentropy/types/document_get_page_info_params.py @@ -32,14 +32,3 @@ class DocumentGetPageInfoParams(TypedDict, total=False): If `true`, then the response will have the `content` attribute be a `string`, rather than `null`. This string will contain the full contents of the page. """ - - include_image: bool - """ - If `true`, then the response will have the `image_base64_data` attribute be a - `string`\\**, rather than `null`. This string will contain the image data of the - document, as a base64-encoded string. Currently, this data is guaranteed to be a - JPEG-encoded image. - - \\**Note that the response may still be `null`, if the page has no image data, - such as if the document was uploaded with raw text rather than as a PDF. - """ diff --git a/src/zeroentropy/types/document_get_page_info_response.py b/src/zeroentropy/types/document_get_page_info_response.py index b5c68d6..69ec809 100644 --- a/src/zeroentropy/types/document_get_page_info_response.py +++ b/src/zeroentropy/types/document_get_page_info_response.py @@ -13,6 +13,14 @@ class Page(BaseModel): collection_name: str """The name of the collection.""" + image_url: Optional[str] = None + """A URL to an image of the page. + + This field will only be provided if the document has finished parsing, and if it + is a filetype that is capable of producing images (e.g. PDF, DOCX, PPT, etc). In + all other cases, this field will be `null`. + """ + page_index: int """The specific page index of this page. @@ -29,16 +37,6 @@ class Page(BaseModel): document has finished parsing. Otherwise, this field will be set to `null`. """ - image_base64_data: Optional[str] = None - """An image of the page. - - This will be a base64-encoded string. Currently, this data is guaranteed to be a - JPEG-encoded image. This field will only be provided if `include_image` was set - to `true`, and the document has finished parsing. Also, the document must be a - datatype that supports images (PDF, DOCX, PPT, but not .txt). In all other - cases, this field will be `null`. - """ - class DocumentGetPageInfoResponse(BaseModel): page: Page diff --git a/src/zeroentropy/types/document_update_params.py b/src/zeroentropy/types/document_update_params.py new file mode 100644 index 0000000..ae49ffe --- /dev/null +++ b/src/zeroentropy/types/document_update_params.py @@ -0,0 +1,28 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Dict, List, Union, Optional +from typing_extensions import Required, TypedDict + +__all__ = ["DocumentUpdateParams"] + + +class DocumentUpdateParams(TypedDict, total=False): + collection_name: Required[str] + """The name of the collection.""" + + path: Required[str] + """The filepath of the document that you are updating. + + A `404 Not Found` status code will be returned if no document with this path was + found. + """ + + metadata: Optional[Dict[str, Union[str, List[str]]]] + """ + If this field is provided, the given metadata json will replace the document's + existing metadata json. In other words, if you want to add a new field, you will + need to provide the entire metadata object (Both the original fields, and the + new field). + """ diff --git a/src/zeroentropy/types/document_update_response.py b/src/zeroentropy/types/document_update_response.py new file mode 100644 index 0000000..f3e3cb3 --- /dev/null +++ b/src/zeroentropy/types/document_update_response.py @@ -0,0 +1,12 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + + +from .._models import BaseModel + +__all__ = ["DocumentUpdateResponse"] + + +class DocumentUpdateResponse(BaseModel): + new_id: str + + previous_id: str diff --git a/src/zeroentropy/types/query_top_documents_params.py b/src/zeroentropy/types/query_top_documents_params.py index 13273f9..d5b3e10 100644 --- a/src/zeroentropy/types/query_top_documents_params.py +++ b/src/zeroentropy/types/query_top_documents_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["QueryTopDocumentsParams"] @@ -38,3 +38,12 @@ class QueryTopDocumentsParams(TypedDict, total=False): If not provided, then the default will be `False`. """ + + latency_mode: Literal["low", "high"] + """This option selects between our two latency modes. + + The higher latency mode takes longer, but can allow for more accurate responses. + If desired, test both to customize your search experience for your particular + use-case, or use the default of "low" and only swap if you need an additional + improvement in search result quality. + """ diff --git a/src/zeroentropy/types/query_top_pages_params.py b/src/zeroentropy/types/query_top_pages_params.py index 764b7e1..6c7024f 100644 --- a/src/zeroentropy/types/query_top_pages_params.py +++ b/src/zeroentropy/types/query_top_pages_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["QueryTopPagesParams"] @@ -35,3 +35,12 @@ class QueryTopPagesParams(TypedDict, total=False): include_content: bool """If set to true, then the content of all pages will be returned.""" + + latency_mode: Literal["low", "high"] + """This option selects between our two latency modes. + + The higher latency mode takes longer, but can allow for more accurate responses. + If desired, test both to customize your search experience for your particular + use-case, or use the default of "low" and only swap if you need an additional + improvement in search result quality. + """ diff --git a/src/zeroentropy/types/query_top_pages_response.py b/src/zeroentropy/types/query_top_pages_response.py index 93af934..66ca7bf 100644 --- a/src/zeroentropy/types/query_top_pages_response.py +++ b/src/zeroentropy/types/query_top_pages_response.py @@ -15,6 +15,14 @@ class Result(BaseModel): `include_content` is `true`. """ + image_url: Optional[str] = None + """A URL to an image of the page. + + This field will only be provided if the document has finished parsing, and if it + is a filetype that is capable of producing images (e.g. PDF, DOCX, PPT, etc). In + all other cases, this field will be `null`. + """ + page_index: int """The index of this page in the document. diff --git a/src/zeroentropy/types/query_top_snippets_params.py b/src/zeroentropy/types/query_top_snippets_params.py index 0d75e2d..23a7e95 100644 --- a/src/zeroentropy/types/query_top_snippets_params.py +++ b/src/zeroentropy/types/query_top_snippets_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Dict, Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["QueryTopSnippetsParams"] @@ -33,6 +33,16 @@ class QueryTopSnippetsParams(TypedDict, total=False): not provided, then all documents will be searched. """ + latency_mode: Literal["low"] + """Note that for Top K Snippets, only latency_mode "low" is available. + + This option selects between our latency modes. The higher latency mode takes + longer, but can allow for more accurate responses. If desired, test both to + customize your search experience for your particular use-case, or use the + default of "low" and only swap if you need an additional improvement in search + result quality. + """ + precise_responses: bool """Enable precise responses. diff --git a/tests/api_resources/test_admin.py b/tests/api_resources/test_admin.py new file mode 100644 index 0000000..32d06b9 --- /dev/null +++ b/tests/api_resources/test_admin.py @@ -0,0 +1,84 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from tests.utils import assert_matches_type +from zeroentropy import ZeroEntropy, AsyncZeroEntropy +from zeroentropy.types import AdminCreateOrganizationResponse + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestAdmin: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create_organization(self, client: ZeroEntropy) -> None: + admin = client.admin.create_organization( + organization_name="organization_name", + ) + assert_matches_type(AdminCreateOrganizationResponse, admin, path=["response"]) + + @parametrize + def test_raw_response_create_organization(self, client: ZeroEntropy) -> None: + response = client.admin.with_raw_response.create_organization( + organization_name="organization_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + admin = response.parse() + assert_matches_type(AdminCreateOrganizationResponse, admin, path=["response"]) + + @parametrize + def test_streaming_response_create_organization(self, client: ZeroEntropy) -> None: + with client.admin.with_streaming_response.create_organization( + organization_name="organization_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + admin = response.parse() + assert_matches_type(AdminCreateOrganizationResponse, admin, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncAdmin: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create_organization(self, async_client: AsyncZeroEntropy) -> None: + admin = await async_client.admin.create_organization( + organization_name="organization_name", + ) + assert_matches_type(AdminCreateOrganizationResponse, admin, path=["response"]) + + @parametrize + async def test_raw_response_create_organization(self, async_client: AsyncZeroEntropy) -> None: + response = await async_client.admin.with_raw_response.create_organization( + organization_name="organization_name", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + admin = await response.parse() + assert_matches_type(AdminCreateOrganizationResponse, admin, path=["response"]) + + @parametrize + async def test_streaming_response_create_organization(self, async_client: AsyncZeroEntropy) -> None: + async with async_client.admin.with_streaming_response.create_organization( + organization_name="organization_name", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + admin = await response.parse() + assert_matches_type(AdminCreateOrganizationResponse, admin, path=["response"]) + + assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/test_documents.py b/tests/api_resources/test_documents.py index 1317b83..2e9a3cd 100644 --- a/tests/api_resources/test_documents.py +++ b/tests/api_resources/test_documents.py @@ -12,6 +12,7 @@ from zeroentropy.types import ( DocumentAddResponse, DocumentDeleteResponse, + DocumentUpdateResponse, DocumentGetInfoResponse, DocumentGetInfoListResponse, DocumentGetPageInfoResponse, @@ -24,6 +25,49 @@ class TestDocuments: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + def test_method_update(self, client: ZeroEntropy) -> None: + document = client.documents.update( + collection_name="collection_name", + path="path", + ) + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + @parametrize + def test_method_update_with_all_params(self, client: ZeroEntropy) -> None: + document = client.documents.update( + collection_name="collection_name", + path="path", + metadata={"foo": "string"}, + ) + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + @parametrize + def test_raw_response_update(self, client: ZeroEntropy) -> None: + response = client.documents.with_raw_response.update( + collection_name="collection_name", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = response.parse() + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + @parametrize + def test_streaming_response_update(self, client: ZeroEntropy) -> None: + with client.documents.with_streaming_response.update( + collection_name="collection_name", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + document = response.parse() + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize def test_method_delete(self, client: ZeroEntropy) -> None: document = client.documents.delete( @@ -217,7 +261,6 @@ def test_method_get_page_info_with_all_params(self, client: ZeroEntropy) -> None page_index=0, path="path", include_content=True, - include_image=True, ) assert_matches_type(DocumentGetPageInfoResponse, document, path=["response"]) @@ -253,6 +296,49 @@ def test_streaming_response_get_page_info(self, client: ZeroEntropy) -> None: class TestAsyncDocuments: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + @parametrize + async def test_method_update(self, async_client: AsyncZeroEntropy) -> None: + document = await async_client.documents.update( + collection_name="collection_name", + path="path", + ) + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + @parametrize + async def test_method_update_with_all_params(self, async_client: AsyncZeroEntropy) -> None: + document = await async_client.documents.update( + collection_name="collection_name", + path="path", + metadata={"foo": "string"}, + ) + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + @parametrize + async def test_raw_response_update(self, async_client: AsyncZeroEntropy) -> None: + response = await async_client.documents.with_raw_response.update( + collection_name="collection_name", + path="path", + ) + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + document = await response.parse() + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + @parametrize + async def test_streaming_response_update(self, async_client: AsyncZeroEntropy) -> None: + async with async_client.documents.with_streaming_response.update( + collection_name="collection_name", + path="path", + ) as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + document = await response.parse() + assert_matches_type(DocumentUpdateResponse, document, path=["response"]) + + assert cast(Any, response.is_closed) is True + @parametrize async def test_method_delete(self, async_client: AsyncZeroEntropy) -> None: document = await async_client.documents.delete( @@ -448,7 +534,6 @@ async def test_method_get_page_info_with_all_params(self, async_client: AsyncZer page_index=0, path="path", include_content=True, - include_image=True, ) assert_matches_type(DocumentGetPageInfoResponse, document, path=["response"]) diff --git a/tests/api_resources/test_queries.py b/tests/api_resources/test_queries.py index fda2e2a..0fe62a7 100644 --- a/tests/api_resources/test_queries.py +++ b/tests/api_resources/test_queries.py @@ -38,6 +38,7 @@ def test_method_top_documents_with_all_params(self, client: ZeroEntropy) -> None query="query", filter={"foo": "bar"}, include_metadata=True, + latency_mode="low", ) assert_matches_type(QueryTopDocumentsResponse, query, path=["response"]) @@ -86,6 +87,7 @@ def test_method_top_pages_with_all_params(self, client: ZeroEntropy) -> None: query="query", filter={"foo": "bar"}, include_content=True, + latency_mode="low", ) assert_matches_type(QueryTopPagesResponse, query, path=["response"]) @@ -133,6 +135,7 @@ def test_method_top_snippets_with_all_params(self, client: ZeroEntropy) -> None: k=0, query="query", filter={"foo": "bar"}, + latency_mode="low", precise_responses=True, ) assert_matches_type(QueryTopSnippetsResponse, query, path=["response"]) @@ -186,6 +189,7 @@ async def test_method_top_documents_with_all_params(self, async_client: AsyncZer query="query", filter={"foo": "bar"}, include_metadata=True, + latency_mode="low", ) assert_matches_type(QueryTopDocumentsResponse, query, path=["response"]) @@ -234,6 +238,7 @@ async def test_method_top_pages_with_all_params(self, async_client: AsyncZeroEnt query="query", filter={"foo": "bar"}, include_content=True, + latency_mode="low", ) assert_matches_type(QueryTopPagesResponse, query, path=["response"]) @@ -281,6 +286,7 @@ async def test_method_top_snippets_with_all_params(self, async_client: AsyncZero k=0, query="query", filter={"foo": "bar"}, + latency_mode="low", precise_responses=True, ) assert_matches_type(QueryTopSnippetsResponse, query, path=["response"]) diff --git a/tests/test_client.py b/tests/test_client.py index 7d30770..7f1603b 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,6 +6,7 @@ import os import sys import json +import time import asyncio import inspect import subprocess @@ -1631,10 +1632,20 @@ async def test_main() -> None: [sys.executable, "-c", test_code], text=True, ) as process: - try: - process.wait(2) - if process.returncode: - raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") - except subprocess.TimeoutExpired as e: - process.kill() - raise AssertionError("calling get_platform using asyncify resulted in a hung process") from e + timeout = 10 # seconds + + start_time = time.monotonic() + while True: + return_code = process.poll() + if return_code is not None: + if return_code != 0: + raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") + + # success + break + + if time.monotonic() - start_time > timeout: + process.kill() + raise AssertionError("calling get_platform using asyncify resulted in a hung process") + + time.sleep(0.1)