From e07ccb77be3fa462a4d98e6673b6e1ad71b947d4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 4 Jan 2025 21:21:11 +0000 Subject: [PATCH] feat(api): update via SDK Studio --- .stats.yml | 2 +- api.md | 36 -- .../resources/document_ai/__init__.py | 14 - .../resources/document_ai/document_ai.py | 32 -- .../resources/document_ai/extract/__init__.py | 33 -- .../resources/document_ai/extract/extract.py | 452 ------------------ .../resources/document_ai/extract/schema.py | 356 -------------- src/mixedbread/types/document_ai/__init__.py | 5 - .../types/document_ai/extract/__init__.py | 10 - .../extract/created_json_schema.py | 11 - .../extract/enhanced_json_schema.py | 11 - .../extract/schema_create_params.py | 12 - .../extract/schema_enhance_params.py | 12 - .../extract/schema_validate_params.py | 12 - .../extract/validated_json_schema.py | 18 - .../document_ai/extract_content_params.py | 15 - .../document_ai/extract_create_job_params.py | 15 - .../extract_create_job_response.py | 83 ---- .../extract_retrieve_job_response.py | 83 ---- src/mixedbread/types/document_ai/result.py | 11 - .../document_ai/extract/__init__.py | 1 - .../document_ai/extract/test_schema.py | 212 -------- .../api_resources/document_ai/test_extract.py | 238 --------- 23 files changed, 1 insertion(+), 1673 deletions(-) delete mode 100644 src/mixedbread/resources/document_ai/extract/__init__.py delete mode 100644 src/mixedbread/resources/document_ai/extract/extract.py delete mode 100644 src/mixedbread/resources/document_ai/extract/schema.py delete mode 100644 src/mixedbread/types/document_ai/extract/__init__.py delete mode 100644 src/mixedbread/types/document_ai/extract/created_json_schema.py delete mode 100644 src/mixedbread/types/document_ai/extract/enhanced_json_schema.py delete mode 100644 src/mixedbread/types/document_ai/extract/schema_create_params.py delete mode 100644 src/mixedbread/types/document_ai/extract/schema_enhance_params.py delete mode 100644 src/mixedbread/types/document_ai/extract/schema_validate_params.py delete mode 100644 src/mixedbread/types/document_ai/extract/validated_json_schema.py delete mode 100644 src/mixedbread/types/document_ai/extract_content_params.py delete mode 100644 src/mixedbread/types/document_ai/extract_create_job_params.py delete mode 100644 src/mixedbread/types/document_ai/extract_create_job_response.py delete mode 100644 src/mixedbread/types/document_ai/extract_retrieve_job_response.py delete mode 100644 src/mixedbread/types/document_ai/result.py delete mode 100644 tests/api_resources/document_ai/extract/__init__.py delete mode 100644 tests/api_resources/document_ai/extract/test_schema.py delete mode 100644 tests/api_resources/document_ai/test_extract.py diff --git a/.stats.yml b/.stats.yml index e5769bf4..06d05485 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 29 +configured_endpoints: 23 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-650f7cc87f2d7ce09046fff9ce81bb72053420165b687d1c5ef13a30ff9b4073.yml diff --git a/api.md b/api.md index 4cc72df4..0b4fe96a 100644 --- a/api.md +++ b/api.md @@ -27,42 +27,6 @@ Methods: - client.document_ai.parse.create_job(\*\*params) -> ParseCreateJobResponse - client.document_ai.parse.retrieve_job(job_id) -> ParseRetrieveJobResponse -## Extract - -Types: - -```python -from mixedbread.types.document_ai import ( - Result, - ExtractCreateJobResponse, - ExtractRetrieveJobResponse, -) -``` - -Methods: - -- client.document_ai.extract.content(\*\*params) -> Result -- client.document_ai.extract.create_job(\*\*params) -> ExtractCreateJobResponse -- client.document_ai.extract.retrieve_job(job_id) -> ExtractRetrieveJobResponse - -### Schema - -Types: - -```python -from mixedbread.types.document_ai.extract import ( - CreatedJsonSchema, - EnhancedJsonSchema, - ValidatedJsonSchema, -) -``` - -Methods: - -- client.document_ai.extract.schema.create(\*\*params) -> CreatedJsonSchema -- client.document_ai.extract.schema.enhance(\*\*params) -> EnhancedJsonSchema -- client.document_ai.extract.schema.validate(\*\*params) -> ValidatedJsonSchema - # Embeddings Types: diff --git a/src/mixedbread/resources/document_ai/__init__.py b/src/mixedbread/resources/document_ai/__init__.py index 2816c85d..93d2f9d0 100644 --- a/src/mixedbread/resources/document_ai/__init__.py +++ b/src/mixedbread/resources/document_ai/__init__.py @@ -8,14 +8,6 @@ ParseResourceWithStreamingResponse, AsyncParseResourceWithStreamingResponse, ) -from .extract import ( - ExtractResource, - AsyncExtractResource, - ExtractResourceWithRawResponse, - AsyncExtractResourceWithRawResponse, - ExtractResourceWithStreamingResponse, - AsyncExtractResourceWithStreamingResponse, -) from .document_ai import ( DocumentAIResource, AsyncDocumentAIResource, @@ -32,12 +24,6 @@ "AsyncParseResourceWithRawResponse", "ParseResourceWithStreamingResponse", "AsyncParseResourceWithStreamingResponse", - "ExtractResource", - "AsyncExtractResource", - "ExtractResourceWithRawResponse", - "AsyncExtractResourceWithRawResponse", - "ExtractResourceWithStreamingResponse", - "AsyncExtractResourceWithStreamingResponse", "DocumentAIResource", "AsyncDocumentAIResource", "DocumentAIResourceWithRawResponse", diff --git a/src/mixedbread/resources/document_ai/document_ai.py b/src/mixedbread/resources/document_ai/document_ai.py index ca0cb048..af35dce6 100644 --- a/src/mixedbread/resources/document_ai/document_ai.py +++ b/src/mixedbread/resources/document_ai/document_ai.py @@ -12,14 +12,6 @@ ) from ..._compat import cached_property from ..._resource import SyncAPIResource, AsyncAPIResource -from .extract.extract import ( - ExtractResource, - AsyncExtractResource, - ExtractResourceWithRawResponse, - AsyncExtractResourceWithRawResponse, - ExtractResourceWithStreamingResponse, - AsyncExtractResourceWithStreamingResponse, -) __all__ = ["DocumentAIResource", "AsyncDocumentAIResource"] @@ -29,10 +21,6 @@ class DocumentAIResource(SyncAPIResource): def parse(self) -> ParseResource: return ParseResource(self._client) - @cached_property - def extract(self) -> ExtractResource: - return ExtractResource(self._client) - @cached_property def with_raw_response(self) -> DocumentAIResourceWithRawResponse: """ @@ -58,10 +46,6 @@ class AsyncDocumentAIResource(AsyncAPIResource): def parse(self) -> AsyncParseResource: return AsyncParseResource(self._client) - @cached_property - def extract(self) -> AsyncExtractResource: - return AsyncExtractResource(self._client) - @cached_property def with_raw_response(self) -> AsyncDocumentAIResourceWithRawResponse: """ @@ -90,10 +74,6 @@ def __init__(self, document_ai: DocumentAIResource) -> None: def parse(self) -> ParseResourceWithRawResponse: return ParseResourceWithRawResponse(self._document_ai.parse) - @cached_property - def extract(self) -> ExtractResourceWithRawResponse: - return ExtractResourceWithRawResponse(self._document_ai.extract) - class AsyncDocumentAIResourceWithRawResponse: def __init__(self, document_ai: AsyncDocumentAIResource) -> None: @@ -103,10 +83,6 @@ def __init__(self, document_ai: AsyncDocumentAIResource) -> None: def parse(self) -> AsyncParseResourceWithRawResponse: return AsyncParseResourceWithRawResponse(self._document_ai.parse) - @cached_property - def extract(self) -> AsyncExtractResourceWithRawResponse: - return AsyncExtractResourceWithRawResponse(self._document_ai.extract) - class DocumentAIResourceWithStreamingResponse: def __init__(self, document_ai: DocumentAIResource) -> None: @@ -116,10 +92,6 @@ def __init__(self, document_ai: DocumentAIResource) -> None: def parse(self) -> ParseResourceWithStreamingResponse: return ParseResourceWithStreamingResponse(self._document_ai.parse) - @cached_property - def extract(self) -> ExtractResourceWithStreamingResponse: - return ExtractResourceWithStreamingResponse(self._document_ai.extract) - class AsyncDocumentAIResourceWithStreamingResponse: def __init__(self, document_ai: AsyncDocumentAIResource) -> None: @@ -128,7 +100,3 @@ def __init__(self, document_ai: AsyncDocumentAIResource) -> None: @cached_property def parse(self) -> AsyncParseResourceWithStreamingResponse: return AsyncParseResourceWithStreamingResponse(self._document_ai.parse) - - @cached_property - def extract(self) -> AsyncExtractResourceWithStreamingResponse: - return AsyncExtractResourceWithStreamingResponse(self._document_ai.extract) diff --git a/src/mixedbread/resources/document_ai/extract/__init__.py b/src/mixedbread/resources/document_ai/extract/__init__.py deleted file mode 100644 index 7d586e28..00000000 --- a/src/mixedbread/resources/document_ai/extract/__init__.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from .schema import ( - SchemaResource, - AsyncSchemaResource, - SchemaResourceWithRawResponse, - AsyncSchemaResourceWithRawResponse, - SchemaResourceWithStreamingResponse, - AsyncSchemaResourceWithStreamingResponse, -) -from .extract import ( - ExtractResource, - AsyncExtractResource, - ExtractResourceWithRawResponse, - AsyncExtractResourceWithRawResponse, - ExtractResourceWithStreamingResponse, - AsyncExtractResourceWithStreamingResponse, -) - -__all__ = [ - "SchemaResource", - "AsyncSchemaResource", - "SchemaResourceWithRawResponse", - "AsyncSchemaResourceWithRawResponse", - "SchemaResourceWithStreamingResponse", - "AsyncSchemaResourceWithStreamingResponse", - "ExtractResource", - "AsyncExtractResource", - "ExtractResourceWithRawResponse", - "AsyncExtractResourceWithRawResponse", - "ExtractResourceWithStreamingResponse", - "AsyncExtractResourceWithStreamingResponse", -] diff --git a/src/mixedbread/resources/document_ai/extract/extract.py b/src/mixedbread/resources/document_ai/extract/extract.py deleted file mode 100644 index 40343986..00000000 --- a/src/mixedbread/resources/document_ai/extract/extract.py +++ /dev/null @@ -1,452 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Any, cast - -import httpx - -from .schema import ( - SchemaResource, - AsyncSchemaResource, - SchemaResourceWithRawResponse, - AsyncSchemaResourceWithRawResponse, - SchemaResourceWithStreamingResponse, - AsyncSchemaResourceWithStreamingResponse, -) -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.document_ai import extract_content_params, extract_create_job_params -from ....types.document_ai.result import Result -from ....types.document_ai.extract_create_job_response import ExtractCreateJobResponse -from ....types.document_ai.extract_retrieve_job_response import ExtractRetrieveJobResponse - -__all__ = ["ExtractResource", "AsyncExtractResource"] - - -class ExtractResource(SyncAPIResource): - @cached_property - def schema(self) -> SchemaResource: - return SchemaResource(self._client) - - @cached_property - def with_raw_response(self) -> ExtractResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#accessing-raw-response-data-eg-headers - """ - return ExtractResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> ExtractResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#with_streaming_response - """ - return ExtractResourceWithStreamingResponse(self) - - def content( - self, - *, - content: str, - json_schema: object, - # 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, - ) -> Result: - """ - Extract content from a string using the provided schema. - - Args: params: ExtractContentCreateParams The parameters for extracting content - from a string. - - Returns: ExtractionResult: The extracted content. - - Args: - content: The text content to extract structured data from - - json_schema: The schema definition to use for extraction - - 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( - "/v1/document-ai/extract/content", - body=maybe_transform( - { - "content": content, - "json_schema": json_schema, - }, - extract_content_params.ExtractContentParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Result, - ) - - def create_job( - self, - *, - file_id: str, - json_schema: object, - # 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, - ) -> ExtractCreateJobResponse: - """ - Start an extraction job for the provided file and schema. - - Args: params: ExtractJobCreateParams The parameters for creating an extraction - job. - - Returns: ExtractionJob: The created extraction job. - - Args: - file_id: The file ID to extract data from - - json_schema: The schema definition to use for extraction - - 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 cast( - ExtractCreateJobResponse, - self._post( - "/v1/document-ai/extract", - body=maybe_transform( - { - "file_id": file_id, - "json_schema": json_schema, - }, - extract_create_job_params.ExtractCreateJobParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, ExtractCreateJobResponse - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def retrieve_job( - self, - job_id: 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, - ) -> ExtractRetrieveJobResponse: - """ - Get detailed information about a specific extraction job. - - Args: job_id: The ID of the extraction job. - - Returns: ExtractionJob: Detailed information about the extraction job. - - Args: - job_id: The ID of the extraction job to retrieve - - 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 - """ - if not job_id: - raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") - return cast( - ExtractRetrieveJobResponse, - self._get( - f"/v1/document-ai/extract/{job_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, ExtractRetrieveJobResponse - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class AsyncExtractResource(AsyncAPIResource): - @cached_property - def schema(self) -> AsyncSchemaResource: - return AsyncSchemaResource(self._client) - - @cached_property - def with_raw_response(self) -> AsyncExtractResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#accessing-raw-response-data-eg-headers - """ - return AsyncExtractResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncExtractResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#with_streaming_response - """ - return AsyncExtractResourceWithStreamingResponse(self) - - async def content( - self, - *, - content: str, - json_schema: object, - # 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, - ) -> Result: - """ - Extract content from a string using the provided schema. - - Args: params: ExtractContentCreateParams The parameters for extracting content - from a string. - - Returns: ExtractionResult: The extracted content. - - Args: - content: The text content to extract structured data from - - json_schema: The schema definition to use for extraction - - 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( - "/v1/document-ai/extract/content", - body=await async_maybe_transform( - { - "content": content, - "json_schema": json_schema, - }, - extract_content_params.ExtractContentParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=Result, - ) - - async def create_job( - self, - *, - file_id: str, - json_schema: object, - # 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, - ) -> ExtractCreateJobResponse: - """ - Start an extraction job for the provided file and schema. - - Args: params: ExtractJobCreateParams The parameters for creating an extraction - job. - - Returns: ExtractionJob: The created extraction job. - - Args: - file_id: The file ID to extract data from - - json_schema: The schema definition to use for extraction - - 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 cast( - ExtractCreateJobResponse, - await self._post( - "/v1/document-ai/extract", - body=await async_maybe_transform( - { - "file_id": file_id, - "json_schema": json_schema, - }, - extract_create_job_params.ExtractCreateJobParams, - ), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, ExtractCreateJobResponse - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - async def retrieve_job( - self, - job_id: 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, - ) -> ExtractRetrieveJobResponse: - """ - Get detailed information about a specific extraction job. - - Args: job_id: The ID of the extraction job. - - Returns: ExtractionJob: Detailed information about the extraction job. - - Args: - job_id: The ID of the extraction job to retrieve - - 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 - """ - if not job_id: - raise ValueError(f"Expected a non-empty value for `job_id` but received {job_id!r}") - return cast( - ExtractRetrieveJobResponse, - await self._get( - f"/v1/document-ai/extract/{job_id}", - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=cast( - Any, ExtractRetrieveJobResponse - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - -class ExtractResourceWithRawResponse: - def __init__(self, extract: ExtractResource) -> None: - self._extract = extract - - self.content = to_raw_response_wrapper( - extract.content, - ) - self.create_job = to_raw_response_wrapper( - extract.create_job, - ) - self.retrieve_job = to_raw_response_wrapper( - extract.retrieve_job, - ) - - @cached_property - def schema(self) -> SchemaResourceWithRawResponse: - return SchemaResourceWithRawResponse(self._extract.schema) - - -class AsyncExtractResourceWithRawResponse: - def __init__(self, extract: AsyncExtractResource) -> None: - self._extract = extract - - self.content = async_to_raw_response_wrapper( - extract.content, - ) - self.create_job = async_to_raw_response_wrapper( - extract.create_job, - ) - self.retrieve_job = async_to_raw_response_wrapper( - extract.retrieve_job, - ) - - @cached_property - def schema(self) -> AsyncSchemaResourceWithRawResponse: - return AsyncSchemaResourceWithRawResponse(self._extract.schema) - - -class ExtractResourceWithStreamingResponse: - def __init__(self, extract: ExtractResource) -> None: - self._extract = extract - - self.content = to_streamed_response_wrapper( - extract.content, - ) - self.create_job = to_streamed_response_wrapper( - extract.create_job, - ) - self.retrieve_job = to_streamed_response_wrapper( - extract.retrieve_job, - ) - - @cached_property - def schema(self) -> SchemaResourceWithStreamingResponse: - return SchemaResourceWithStreamingResponse(self._extract.schema) - - -class AsyncExtractResourceWithStreamingResponse: - def __init__(self, extract: AsyncExtractResource) -> None: - self._extract = extract - - self.content = async_to_streamed_response_wrapper( - extract.content, - ) - self.create_job = async_to_streamed_response_wrapper( - extract.create_job, - ) - self.retrieve_job = async_to_streamed_response_wrapper( - extract.retrieve_job, - ) - - @cached_property - def schema(self) -> AsyncSchemaResourceWithStreamingResponse: - return AsyncSchemaResourceWithStreamingResponse(self._extract.schema) diff --git a/src/mixedbread/resources/document_ai/extract/schema.py b/src/mixedbread/resources/document_ai/extract/schema.py deleted file mode 100644 index 45f127d7..00000000 --- a/src/mixedbread/resources/document_ai/extract/schema.py +++ /dev/null @@ -1,356 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import httpx - -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.document_ai.extract import schema_create_params, schema_enhance_params, schema_validate_params -from ....types.document_ai.extract.created_json_schema import CreatedJsonSchema -from ....types.document_ai.extract.enhanced_json_schema import EnhancedJsonSchema -from ....types.document_ai.extract.validated_json_schema import ValidatedJsonSchema - -__all__ = ["SchemaResource", "AsyncSchemaResource"] - - -class SchemaResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> SchemaResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#accessing-raw-response-data-eg-headers - """ - return SchemaResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> SchemaResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#with_streaming_response - """ - return SchemaResourceWithStreamingResponse(self) - - def create( - self, - *, - description: 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, - ) -> CreatedJsonSchema: - """ - Create a schema with the provided parameters. - - Args: params: JsonSchemaCreateParams The parameters for creating a schema. - - Returns: CreatedJsonSchema: The created schema. - - Args: - description: Natural language description of the schema to create - - 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( - "/v1/document-ai/extract/schema", - body=maybe_transform({"description": description}, schema_create_params.SchemaCreateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=CreatedJsonSchema, - ) - - def enhance( - self, - *, - json_schema: object, - # 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, - ) -> EnhancedJsonSchema: - """ - Enhance a schema by enriching the descriptions to aid extraction. - - Args: params: JsonSchemaEnhanceParams The parameters for enhancing a schema. - - Returns: EnhancedJsonSchema: The enhanced schema. - - Args: - json_schema: The base schema to enhance - - 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( - "/v1/document-ai/extract/schema/enhance", - body=maybe_transform({"json_schema": json_schema}, schema_enhance_params.SchemaEnhanceParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=EnhancedJsonSchema, - ) - - def validate( - self, - *, - json_schema: object, - # 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, - ) -> ValidatedJsonSchema: - """ - Validate a schema. - - Args: params: JsonSchemaValidateParams The parameters for validating a schema. - - Returns: ValidatedJsonSchema: The validation result. - - Args: - json_schema: The schema definition to validate - - 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( - "/v1/document-ai/extract/schema/validate", - body=maybe_transform({"json_schema": json_schema}, schema_validate_params.SchemaValidateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ValidatedJsonSchema, - ) - - -class AsyncSchemaResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncSchemaResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#accessing-raw-response-data-eg-headers - """ - return AsyncSchemaResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncSchemaResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#with_streaming_response - """ - return AsyncSchemaResourceWithStreamingResponse(self) - - async def create( - self, - *, - description: 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, - ) -> CreatedJsonSchema: - """ - Create a schema with the provided parameters. - - Args: params: JsonSchemaCreateParams The parameters for creating a schema. - - Returns: CreatedJsonSchema: The created schema. - - Args: - description: Natural language description of the schema to create - - 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( - "/v1/document-ai/extract/schema", - body=await async_maybe_transform({"description": description}, schema_create_params.SchemaCreateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=CreatedJsonSchema, - ) - - async def enhance( - self, - *, - json_schema: object, - # 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, - ) -> EnhancedJsonSchema: - """ - Enhance a schema by enriching the descriptions to aid extraction. - - Args: params: JsonSchemaEnhanceParams The parameters for enhancing a schema. - - Returns: EnhancedJsonSchema: The enhanced schema. - - Args: - json_schema: The base schema to enhance - - 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( - "/v1/document-ai/extract/schema/enhance", - body=await async_maybe_transform({"json_schema": json_schema}, schema_enhance_params.SchemaEnhanceParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=EnhancedJsonSchema, - ) - - async def validate( - self, - *, - json_schema: object, - # 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, - ) -> ValidatedJsonSchema: - """ - Validate a schema. - - Args: params: JsonSchemaValidateParams The parameters for validating a schema. - - Returns: ValidatedJsonSchema: The validation result. - - Args: - json_schema: The schema definition to validate - - 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( - "/v1/document-ai/extract/schema/validate", - body=await async_maybe_transform({"json_schema": json_schema}, schema_validate_params.SchemaValidateParams), - options=make_request_options( - extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout - ), - cast_to=ValidatedJsonSchema, - ) - - -class SchemaResourceWithRawResponse: - def __init__(self, schema: SchemaResource) -> None: - self._schema = schema - - self.create = to_raw_response_wrapper( - schema.create, - ) - self.enhance = to_raw_response_wrapper( - schema.enhance, - ) - self.validate = to_raw_response_wrapper( - schema.validate, - ) - - -class AsyncSchemaResourceWithRawResponse: - def __init__(self, schema: AsyncSchemaResource) -> None: - self._schema = schema - - self.create = async_to_raw_response_wrapper( - schema.create, - ) - self.enhance = async_to_raw_response_wrapper( - schema.enhance, - ) - self.validate = async_to_raw_response_wrapper( - schema.validate, - ) - - -class SchemaResourceWithStreamingResponse: - def __init__(self, schema: SchemaResource) -> None: - self._schema = schema - - self.create = to_streamed_response_wrapper( - schema.create, - ) - self.enhance = to_streamed_response_wrapper( - schema.enhance, - ) - self.validate = to_streamed_response_wrapper( - schema.validate, - ) - - -class AsyncSchemaResourceWithStreamingResponse: - def __init__(self, schema: AsyncSchemaResource) -> None: - self._schema = schema - - self.create = async_to_streamed_response_wrapper( - schema.create, - ) - self.enhance = async_to_streamed_response_wrapper( - schema.enhance, - ) - self.validate = async_to_streamed_response_wrapper( - schema.validate, - ) diff --git a/src/mixedbread/types/document_ai/__init__.py b/src/mixedbread/types/document_ai/__init__.py index 3c4fb9a8..709be7be 100644 --- a/src/mixedbread/types/document_ai/__init__.py +++ b/src/mixedbread/types/document_ai/__init__.py @@ -2,11 +2,6 @@ from __future__ import annotations -from .result import Result as Result -from .extract_content_params import ExtractContentParams as ExtractContentParams from .parse_create_job_params import ParseCreateJobParams as ParseCreateJobParams -from .extract_create_job_params import ExtractCreateJobParams as ExtractCreateJobParams from .parse_create_job_response import ParseCreateJobResponse as ParseCreateJobResponse -from .extract_create_job_response import ExtractCreateJobResponse as ExtractCreateJobResponse from .parse_retrieve_job_response import ParseRetrieveJobResponse as ParseRetrieveJobResponse -from .extract_retrieve_job_response import ExtractRetrieveJobResponse as ExtractRetrieveJobResponse diff --git a/src/mixedbread/types/document_ai/extract/__init__.py b/src/mixedbread/types/document_ai/extract/__init__.py deleted file mode 100644 index 6a7f3dcd..00000000 --- a/src/mixedbread/types/document_ai/extract/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from .created_json_schema import CreatedJsonSchema as CreatedJsonSchema -from .enhanced_json_schema import EnhancedJsonSchema as EnhancedJsonSchema -from .schema_create_params import SchemaCreateParams as SchemaCreateParams -from .schema_enhance_params import SchemaEnhanceParams as SchemaEnhanceParams -from .validated_json_schema import ValidatedJsonSchema as ValidatedJsonSchema -from .schema_validate_params import SchemaValidateParams as SchemaValidateParams diff --git a/src/mixedbread/types/document_ai/extract/created_json_schema.py b/src/mixedbread/types/document_ai/extract/created_json_schema.py deleted file mode 100644 index 80cdd8f6..00000000 --- a/src/mixedbread/types/document_ai/extract/created_json_schema.py +++ /dev/null @@ -1,11 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -from ...._models import BaseModel - -__all__ = ["CreatedJsonSchema"] - - -class CreatedJsonSchema(BaseModel): - json_schema: object - """The created schema definition""" diff --git a/src/mixedbread/types/document_ai/extract/enhanced_json_schema.py b/src/mixedbread/types/document_ai/extract/enhanced_json_schema.py deleted file mode 100644 index ee63a179..00000000 --- a/src/mixedbread/types/document_ai/extract/enhanced_json_schema.py +++ /dev/null @@ -1,11 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -from ...._models import BaseModel - -__all__ = ["EnhancedJsonSchema"] - - -class EnhancedJsonSchema(BaseModel): - json_schema: object - """The enhanced schema with enriched descriptions""" diff --git a/src/mixedbread/types/document_ai/extract/schema_create_params.py b/src/mixedbread/types/document_ai/extract/schema_create_params.py deleted file mode 100644 index 656efaf9..00000000 --- a/src/mixedbread/types/document_ai/extract/schema_create_params.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["SchemaCreateParams"] - - -class SchemaCreateParams(TypedDict, total=False): - description: Required[str] - """Natural language description of the schema to create""" diff --git a/src/mixedbread/types/document_ai/extract/schema_enhance_params.py b/src/mixedbread/types/document_ai/extract/schema_enhance_params.py deleted file mode 100644 index ba69d8f3..00000000 --- a/src/mixedbread/types/document_ai/extract/schema_enhance_params.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["SchemaEnhanceParams"] - - -class SchemaEnhanceParams(TypedDict, total=False): - json_schema: Required[object] - """The base schema to enhance""" diff --git a/src/mixedbread/types/document_ai/extract/schema_validate_params.py b/src/mixedbread/types/document_ai/extract/schema_validate_params.py deleted file mode 100644 index c3d98a4f..00000000 --- a/src/mixedbread/types/document_ai/extract/schema_validate_params.py +++ /dev/null @@ -1,12 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["SchemaValidateParams"] - - -class SchemaValidateParams(TypedDict, total=False): - json_schema: Required[object] - """The schema definition to validate""" diff --git a/src/mixedbread/types/document_ai/extract/validated_json_schema.py b/src/mixedbread/types/document_ai/extract/validated_json_schema.py deleted file mode 100644 index 974d1243..00000000 --- a/src/mixedbread/types/document_ai/extract/validated_json_schema.py +++ /dev/null @@ -1,18 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional - -from ...._models import BaseModel - -__all__ = ["ValidatedJsonSchema"] - - -class ValidatedJsonSchema(BaseModel): - is_valid: bool - """Whether the schema is valid""" - - json_schema: object - """The schema definition""" - - errors: Optional[List[str]] = None - """List of validation errors if any""" diff --git a/src/mixedbread/types/document_ai/extract_content_params.py b/src/mixedbread/types/document_ai/extract_content_params.py deleted file mode 100644 index aaf0b3f2..00000000 --- a/src/mixedbread/types/document_ai/extract_content_params.py +++ /dev/null @@ -1,15 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["ExtractContentParams"] - - -class ExtractContentParams(TypedDict, total=False): - content: Required[str] - """The text content to extract structured data from""" - - json_schema: Required[object] - """The schema definition to use for extraction""" diff --git a/src/mixedbread/types/document_ai/extract_create_job_params.py b/src/mixedbread/types/document_ai/extract_create_job_params.py deleted file mode 100644 index bfa0c148..00000000 --- a/src/mixedbread/types/document_ai/extract_create_job_params.py +++ /dev/null @@ -1,15 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Required, TypedDict - -__all__ = ["ExtractCreateJobParams"] - - -class ExtractCreateJobParams(TypedDict, total=False): - file_id: Required[str] - """The file ID to extract data from""" - - json_schema: Required[object] - """The schema definition to use for extraction""" diff --git a/src/mixedbread/types/document_ai/extract_create_job_response.py b/src/mixedbread/types/document_ai/extract_create_job_response.py deleted file mode 100644 index 1bbebef0..00000000 --- a/src/mixedbread/types/document_ai/extract_create_job_response.py +++ /dev/null @@ -1,83 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias - -from .result import Result -from ..._models import BaseModel - -__all__ = ["ExtractCreateJobResponse", "RunningJob", "FailedJob", "SuccessfulExtractionJob"] - - -class RunningJob(BaseModel): - id: str - """The ID of the job""" - - created_at: Optional[datetime] = None - """The creation time of the job""" - - errors: Optional[List[str]] = None - """The errors of the job""" - - finished_at: Optional[datetime] = None - """The finished time of the job""" - - object: Optional[Literal["job"]] = None - """The type of the object""" - - result: Optional[builtins.object] = None - """The result of the job""" - - status: Optional[Literal["pending", "running"]] = None - """The status of the job""" - - -class FailedJob(BaseModel): - id: str - """The ID of the job""" - - errors: List[str] - """The errors of the job""" - - created_at: Optional[datetime] = None - """The creation time of the job""" - - finished_at: Optional[datetime] = None - """The finished time of the job""" - - object: Optional[Literal["job"]] = None - """The type of the object""" - - result: Optional[builtins.object] = None - """The result of the job""" - - status: Optional[Literal["failed"]] = None - """The status of the job""" - - -class SuccessfulExtractionJob(BaseModel): - id: str - """The ID of the job""" - - result: Result - """The extracted data from the extraction operation""" - - created_at: Optional[datetime] = None - """The creation time of the job""" - - errors: Optional[List[str]] = None - """The errors of the job""" - - finished_at: Optional[datetime] = None - """The finished time of the job""" - - object: Optional[Literal["job"]] = None - """The type of the object""" - - status: Optional[Literal["successful"]] = None - """The status of the job""" - - -ExtractCreateJobResponse: TypeAlias = Union[RunningJob, FailedJob, SuccessfulExtractionJob] diff --git a/src/mixedbread/types/document_ai/extract_retrieve_job_response.py b/src/mixedbread/types/document_ai/extract_retrieve_job_response.py deleted file mode 100644 index bcbb12f2..00000000 --- a/src/mixedbread/types/document_ai/extract_retrieve_job_response.py +++ /dev/null @@ -1,83 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import builtins -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias - -from .result import Result -from ..._models import BaseModel - -__all__ = ["ExtractRetrieveJobResponse", "RunningJob", "FailedJob", "SuccessfulExtractionJob"] - - -class RunningJob(BaseModel): - id: str - """The ID of the job""" - - created_at: Optional[datetime] = None - """The creation time of the job""" - - errors: Optional[List[str]] = None - """The errors of the job""" - - finished_at: Optional[datetime] = None - """The finished time of the job""" - - object: Optional[Literal["job"]] = None - """The type of the object""" - - result: Optional[builtins.object] = None - """The result of the job""" - - status: Optional[Literal["pending", "running"]] = None - """The status of the job""" - - -class FailedJob(BaseModel): - id: str - """The ID of the job""" - - errors: List[str] - """The errors of the job""" - - created_at: Optional[datetime] = None - """The creation time of the job""" - - finished_at: Optional[datetime] = None - """The finished time of the job""" - - object: Optional[Literal["job"]] = None - """The type of the object""" - - result: Optional[builtins.object] = None - """The result of the job""" - - status: Optional[Literal["failed"]] = None - """The status of the job""" - - -class SuccessfulExtractionJob(BaseModel): - id: str - """The ID of the job""" - - result: Result - """The extracted data from the extraction operation""" - - created_at: Optional[datetime] = None - """The creation time of the job""" - - errors: Optional[List[str]] = None - """The errors of the job""" - - finished_at: Optional[datetime] = None - """The finished time of the job""" - - object: Optional[Literal["job"]] = None - """The type of the object""" - - status: Optional[Literal["successful"]] = None - """The status of the job""" - - -ExtractRetrieveJobResponse: TypeAlias = Union[RunningJob, FailedJob, SuccessfulExtractionJob] diff --git a/src/mixedbread/types/document_ai/result.py b/src/mixedbread/types/document_ai/result.py deleted file mode 100644 index 643a1d6e..00000000 --- a/src/mixedbread/types/document_ai/result.py +++ /dev/null @@ -1,11 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -from ..._models import BaseModel - -__all__ = ["Result"] - - -class Result(BaseModel): - data: object - """The extracted data from the extraction operation""" diff --git a/tests/api_resources/document_ai/extract/__init__.py b/tests/api_resources/document_ai/extract/__init__.py deleted file mode 100644 index fd8019a9..00000000 --- a/tests/api_resources/document_ai/extract/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. diff --git a/tests/api_resources/document_ai/extract/test_schema.py b/tests/api_resources/document_ai/extract/test_schema.py deleted file mode 100644 index 79e5a3ed..00000000 --- a/tests/api_resources/document_ai/extract/test_schema.py +++ /dev/null @@ -1,212 +0,0 @@ -# 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 mixedbread import Mixedbread, AsyncMixedbread -from tests.utils import assert_matches_type -from mixedbread.types.document_ai.extract import ( - CreatedJsonSchema, - EnhancedJsonSchema, - ValidatedJsonSchema, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestSchema: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create(self, client: Mixedbread) -> None: - schema = client.document_ai.extract.schema.create( - description="description", - ) - assert_matches_type(CreatedJsonSchema, schema, path=["response"]) - - @parametrize - def test_raw_response_create(self, client: Mixedbread) -> None: - response = client.document_ai.extract.schema.with_raw_response.create( - description="description", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema = response.parse() - assert_matches_type(CreatedJsonSchema, schema, path=["response"]) - - @parametrize - def test_streaming_response_create(self, client: Mixedbread) -> None: - with client.document_ai.extract.schema.with_streaming_response.create( - description="description", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema = response.parse() - assert_matches_type(CreatedJsonSchema, schema, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_enhance(self, client: Mixedbread) -> None: - schema = client.document_ai.extract.schema.enhance( - json_schema={}, - ) - assert_matches_type(EnhancedJsonSchema, schema, path=["response"]) - - @parametrize - def test_raw_response_enhance(self, client: Mixedbread) -> None: - response = client.document_ai.extract.schema.with_raw_response.enhance( - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema = response.parse() - assert_matches_type(EnhancedJsonSchema, schema, path=["response"]) - - @parametrize - def test_streaming_response_enhance(self, client: Mixedbread) -> None: - with client.document_ai.extract.schema.with_streaming_response.enhance( - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema = response.parse() - assert_matches_type(EnhancedJsonSchema, schema, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_validate(self, client: Mixedbread) -> None: - schema = client.document_ai.extract.schema.validate( - json_schema={}, - ) - assert_matches_type(ValidatedJsonSchema, schema, path=["response"]) - - @parametrize - def test_raw_response_validate(self, client: Mixedbread) -> None: - response = client.document_ai.extract.schema.with_raw_response.validate( - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema = response.parse() - assert_matches_type(ValidatedJsonSchema, schema, path=["response"]) - - @parametrize - def test_streaming_response_validate(self, client: Mixedbread) -> None: - with client.document_ai.extract.schema.with_streaming_response.validate( - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema = response.parse() - assert_matches_type(ValidatedJsonSchema, schema, path=["response"]) - - assert cast(Any, response.is_closed) is True - - -class TestAsyncSchema: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_create(self, async_client: AsyncMixedbread) -> None: - schema = await async_client.document_ai.extract.schema.create( - description="description", - ) - assert_matches_type(CreatedJsonSchema, schema, path=["response"]) - - @parametrize - async def test_raw_response_create(self, async_client: AsyncMixedbread) -> None: - response = await async_client.document_ai.extract.schema.with_raw_response.create( - description="description", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema = await response.parse() - assert_matches_type(CreatedJsonSchema, schema, path=["response"]) - - @parametrize - async def test_streaming_response_create(self, async_client: AsyncMixedbread) -> None: - async with async_client.document_ai.extract.schema.with_streaming_response.create( - description="description", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema = await response.parse() - assert_matches_type(CreatedJsonSchema, schema, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_enhance(self, async_client: AsyncMixedbread) -> None: - schema = await async_client.document_ai.extract.schema.enhance( - json_schema={}, - ) - assert_matches_type(EnhancedJsonSchema, schema, path=["response"]) - - @parametrize - async def test_raw_response_enhance(self, async_client: AsyncMixedbread) -> None: - response = await async_client.document_ai.extract.schema.with_raw_response.enhance( - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema = await response.parse() - assert_matches_type(EnhancedJsonSchema, schema, path=["response"]) - - @parametrize - async def test_streaming_response_enhance(self, async_client: AsyncMixedbread) -> None: - async with async_client.document_ai.extract.schema.with_streaming_response.enhance( - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema = await response.parse() - assert_matches_type(EnhancedJsonSchema, schema, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_validate(self, async_client: AsyncMixedbread) -> None: - schema = await async_client.document_ai.extract.schema.validate( - json_schema={}, - ) - assert_matches_type(ValidatedJsonSchema, schema, path=["response"]) - - @parametrize - async def test_raw_response_validate(self, async_client: AsyncMixedbread) -> None: - response = await async_client.document_ai.extract.schema.with_raw_response.validate( - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - schema = await response.parse() - assert_matches_type(ValidatedJsonSchema, schema, path=["response"]) - - @parametrize - async def test_streaming_response_validate(self, async_client: AsyncMixedbread) -> None: - async with async_client.document_ai.extract.schema.with_streaming_response.validate( - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - schema = await response.parse() - assert_matches_type(ValidatedJsonSchema, schema, path=["response"]) - - assert cast(Any, response.is_closed) is True diff --git a/tests/api_resources/document_ai/test_extract.py b/tests/api_resources/document_ai/test_extract.py deleted file mode 100644 index 97b0f7f6..00000000 --- a/tests/api_resources/document_ai/test_extract.py +++ /dev/null @@ -1,238 +0,0 @@ -# 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 mixedbread import Mixedbread, AsyncMixedbread -from tests.utils import assert_matches_type -from mixedbread.types.document_ai import ( - Result, - ExtractCreateJobResponse, - ExtractRetrieveJobResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestExtract: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_content(self, client: Mixedbread) -> None: - extract = client.document_ai.extract.content( - content="content", - json_schema={}, - ) - assert_matches_type(Result, extract, path=["response"]) - - @parametrize - def test_raw_response_content(self, client: Mixedbread) -> None: - response = client.document_ai.extract.with_raw_response.content( - content="content", - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - extract = response.parse() - assert_matches_type(Result, extract, path=["response"]) - - @parametrize - def test_streaming_response_content(self, client: Mixedbread) -> None: - with client.document_ai.extract.with_streaming_response.content( - content="content", - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - extract = response.parse() - assert_matches_type(Result, extract, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_create_job(self, client: Mixedbread) -> None: - extract = client.document_ai.extract.create_job( - file_id="file_id", - json_schema={}, - ) - assert_matches_type(ExtractCreateJobResponse, extract, path=["response"]) - - @parametrize - def test_raw_response_create_job(self, client: Mixedbread) -> None: - response = client.document_ai.extract.with_raw_response.create_job( - file_id="file_id", - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - extract = response.parse() - assert_matches_type(ExtractCreateJobResponse, extract, path=["response"]) - - @parametrize - def test_streaming_response_create_job(self, client: Mixedbread) -> None: - with client.document_ai.extract.with_streaming_response.create_job( - file_id="file_id", - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - extract = response.parse() - assert_matches_type(ExtractCreateJobResponse, extract, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_method_retrieve_job(self, client: Mixedbread) -> None: - extract = client.document_ai.extract.retrieve_job( - "job_id", - ) - assert_matches_type(ExtractRetrieveJobResponse, extract, path=["response"]) - - @parametrize - def test_raw_response_retrieve_job(self, client: Mixedbread) -> None: - response = client.document_ai.extract.with_raw_response.retrieve_job( - "job_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - extract = response.parse() - assert_matches_type(ExtractRetrieveJobResponse, extract, path=["response"]) - - @parametrize - def test_streaming_response_retrieve_job(self, client: Mixedbread) -> None: - with client.document_ai.extract.with_streaming_response.retrieve_job( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - extract = response.parse() - assert_matches_type(ExtractRetrieveJobResponse, extract, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_retrieve_job(self, client: Mixedbread) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - client.document_ai.extract.with_raw_response.retrieve_job( - "", - ) - - -class TestAsyncExtract: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_content(self, async_client: AsyncMixedbread) -> None: - extract = await async_client.document_ai.extract.content( - content="content", - json_schema={}, - ) - assert_matches_type(Result, extract, path=["response"]) - - @parametrize - async def test_raw_response_content(self, async_client: AsyncMixedbread) -> None: - response = await async_client.document_ai.extract.with_raw_response.content( - content="content", - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - extract = await response.parse() - assert_matches_type(Result, extract, path=["response"]) - - @parametrize - async def test_streaming_response_content(self, async_client: AsyncMixedbread) -> None: - async with async_client.document_ai.extract.with_streaming_response.content( - content="content", - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - extract = await response.parse() - assert_matches_type(Result, extract, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_create_job(self, async_client: AsyncMixedbread) -> None: - extract = await async_client.document_ai.extract.create_job( - file_id="file_id", - json_schema={}, - ) - assert_matches_type(ExtractCreateJobResponse, extract, path=["response"]) - - @parametrize - async def test_raw_response_create_job(self, async_client: AsyncMixedbread) -> None: - response = await async_client.document_ai.extract.with_raw_response.create_job( - file_id="file_id", - json_schema={}, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - extract = await response.parse() - assert_matches_type(ExtractCreateJobResponse, extract, path=["response"]) - - @parametrize - async def test_streaming_response_create_job(self, async_client: AsyncMixedbread) -> None: - async with async_client.document_ai.extract.with_streaming_response.create_job( - file_id="file_id", - json_schema={}, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - extract = await response.parse() - assert_matches_type(ExtractCreateJobResponse, extract, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_method_retrieve_job(self, async_client: AsyncMixedbread) -> None: - extract = await async_client.document_ai.extract.retrieve_job( - "job_id", - ) - assert_matches_type(ExtractRetrieveJobResponse, extract, path=["response"]) - - @parametrize - async def test_raw_response_retrieve_job(self, async_client: AsyncMixedbread) -> None: - response = await async_client.document_ai.extract.with_raw_response.retrieve_job( - "job_id", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - extract = await response.parse() - assert_matches_type(ExtractRetrieveJobResponse, extract, path=["response"]) - - @parametrize - async def test_streaming_response_retrieve_job(self, async_client: AsyncMixedbread) -> None: - async with async_client.document_ai.extract.with_streaming_response.retrieve_job( - "job_id", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - extract = await response.parse() - assert_matches_type(ExtractRetrieveJobResponse, extract, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_retrieve_job(self, async_client: AsyncMixedbread) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await async_client.document_ai.extract.with_raw_response.retrieve_job( - "", - )