diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fa1c44bb..45566767 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.66.0" + ".": "1.67.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 0fe8319d..a871eb2b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 69 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/structify%2Fstructify-885b7738bc5f69e484fd0738024e7560f5f5448aee76017f27e78e1fe2485ae0.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/structify%2Fstructify-6c24c5c093c6eaaba26ce7b3960df8f01ed2a9d425f92b9bae0e1bc78105bea4.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 21af9205..2047a316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## 1.67.0 (2024-12-18) + +Full Changelog: [v1.66.0...v1.67.0](https://github.com/StructifyAI/structify-python/compare/v1.66.0...v1.67.0) + +### Features + +* **api:** api update ([#720](https://github.com/StructifyAI/structify-python/issues/720)) ([342dc39](https://github.com/StructifyAI/structify-python/commit/342dc39b54d39fa56d540a4a0d21716eb2f5e8af)) + + +### Chores + +* **internal:** codegen related update ([#710](https://github.com/StructifyAI/structify-python/issues/710)) ([65820a9](https://github.com/StructifyAI/structify-python/commit/65820a953b867e79f8b0158f852c0fc0d7bf8b01)) +* **internal:** codegen related update ([#712](https://github.com/StructifyAI/structify-python/issues/712)) ([db6c1bd](https://github.com/StructifyAI/structify-python/commit/db6c1bd259dd7ec421a81eee28feb3e58c17583d)) +* **internal:** codegen related update ([#713](https://github.com/StructifyAI/structify-python/issues/713)) ([4447bbb](https://github.com/StructifyAI/structify-python/commit/4447bbb00495ecbc6fb6d5bf12f9b71174b33142)) +* **internal:** codegen related update ([#714](https://github.com/StructifyAI/structify-python/issues/714)) ([c645ed2](https://github.com/StructifyAI/structify-python/commit/c645ed2368317e33b2d4889b6fb8a2254625d0c0)) +* **internal:** codegen related update ([#716](https://github.com/StructifyAI/structify-python/issues/716)) ([2e767ef](https://github.com/StructifyAI/structify-python/commit/2e767ef91875613445b203d5b1d085941fcef3c5)) +* **internal:** codegen related update ([#717](https://github.com/StructifyAI/structify-python/issues/717)) ([3cb55f8](https://github.com/StructifyAI/structify-python/commit/3cb55f8ede12cdc1b8fc8b2ac2a9a38863c9ba75)) +* **internal:** fix some typos ([#719](https://github.com/StructifyAI/structify-python/issues/719)) ([c0ad578](https://github.com/StructifyAI/structify-python/commit/c0ad57809d5487031a41fe36c787c6a8f4e585ec)) +* **internal:** updated imports ([#715](https://github.com/StructifyAI/structify-python/issues/715)) ([8e86e32](https://github.com/StructifyAI/structify-python/commit/8e86e32cb418dfe449ce901ecf783e0fd54818eb)) + + +### Documentation + +* **readme:** example snippet for client context manager ([#718](https://github.com/StructifyAI/structify-python/issues/718)) ([be4e219](https://github.com/StructifyAI/structify-python/commit/be4e2197ee6783ccc71fdb0febe069c51ebb195d)) + ## 1.66.0 (2024-12-13) Full Changelog: [v1.65.0...v1.66.0](https://github.com/StructifyAI/structify-python/compare/v1.65.0...v1.66.0) diff --git a/README.md b/README.md index 7c06e5f9..32452a94 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,16 @@ client.with_options(http_client=DefaultHttpxClient(...)) By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting. +```py +from structify import Structify + +with Structify() as client: + # make requests here + ... + +# HTTP client is now closed +``` + ## Versioning This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: diff --git a/pyproject.toml b/pyproject.toml index 92087ec2..8a388301 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "structifyai" -version = "1.66.0" +version = "1.67.0" description = "The official Python library for the structify API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/structify/_client.py b/src/structify/_client.py index 82ddde37..9a7b57f8 100644 --- a/src/structify/_client.py +++ b/src/structify/_client.py @@ -8,7 +8,7 @@ import httpx -from . import resources, _exceptions +from . import _exceptions from ._qs import Querystring from ._types import ( NOT_GIVEN, @@ -24,6 +24,7 @@ get_async_library, ) from ._version import __version__ +from .resources import jobs, user, image, report, server, sources, datasets, entities, documents, structure from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import APIStatusError, StructifyError from ._base_client import ( @@ -31,6 +32,7 @@ SyncAPIClient, AsyncAPIClient, ) +from .resources.admin import admin __all__ = [ "ENVIRONMENTS", @@ -38,7 +40,6 @@ "Transport", "ProxiesTypes", "RequestOptions", - "resources", "Structify", "AsyncStructify", "Client", @@ -52,17 +53,17 @@ class Structify(SyncAPIClient): - user: resources.UserResource - admin: resources.AdminResource - datasets: resources.DatasetsResource - documents: resources.DocumentsResource - jobs: resources.JobsResource - server: resources.ServerResource - sources: resources.SourcesResource - entities: resources.EntitiesResource - image: resources.ImageResource - report: resources.ReportResource - structure: resources.StructureResource + user: user.UserResource + admin: admin.AdminResource + datasets: datasets.DatasetsResource + documents: documents.DocumentsResource + jobs: jobs.JobsResource + server: server.ServerResource + sources: sources.SourcesResource + entities: entities.EntitiesResource + image: image.ImageResource + report: report.ReportResource + structure: structure.StructureResource with_raw_response: StructifyWithRawResponse with_streaming_response: StructifyWithStreamedResponse @@ -144,17 +145,17 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.user = resources.UserResource(self) - self.admin = resources.AdminResource(self) - self.datasets = resources.DatasetsResource(self) - self.documents = resources.DocumentsResource(self) - self.jobs = resources.JobsResource(self) - self.server = resources.ServerResource(self) - self.sources = resources.SourcesResource(self) - self.entities = resources.EntitiesResource(self) - self.image = resources.ImageResource(self) - self.report = resources.ReportResource(self) - self.structure = resources.StructureResource(self) + self.user = user.UserResource(self) + self.admin = admin.AdminResource(self) + self.datasets = datasets.DatasetsResource(self) + self.documents = documents.DocumentsResource(self) + self.jobs = jobs.JobsResource(self) + self.server = server.ServerResource(self) + self.sources = sources.SourcesResource(self) + self.entities = entities.EntitiesResource(self) + self.image = image.ImageResource(self) + self.report = report.ReportResource(self) + self.structure = structure.StructureResource(self) self.with_raw_response = StructifyWithRawResponse(self) self.with_streaming_response = StructifyWithStreamedResponse(self) @@ -266,17 +267,17 @@ def _make_status_error( class AsyncStructify(AsyncAPIClient): - user: resources.AsyncUserResource - admin: resources.AsyncAdminResource - datasets: resources.AsyncDatasetsResource - documents: resources.AsyncDocumentsResource - jobs: resources.AsyncJobsResource - server: resources.AsyncServerResource - sources: resources.AsyncSourcesResource - entities: resources.AsyncEntitiesResource - image: resources.AsyncImageResource - report: resources.AsyncReportResource - structure: resources.AsyncStructureResource + user: user.AsyncUserResource + admin: admin.AsyncAdminResource + datasets: datasets.AsyncDatasetsResource + documents: documents.AsyncDocumentsResource + jobs: jobs.AsyncJobsResource + server: server.AsyncServerResource + sources: sources.AsyncSourcesResource + entities: entities.AsyncEntitiesResource + image: image.AsyncImageResource + report: report.AsyncReportResource + structure: structure.AsyncStructureResource with_raw_response: AsyncStructifyWithRawResponse with_streaming_response: AsyncStructifyWithStreamedResponse @@ -358,17 +359,17 @@ def __init__( _strict_response_validation=_strict_response_validation, ) - self.user = resources.AsyncUserResource(self) - self.admin = resources.AsyncAdminResource(self) - self.datasets = resources.AsyncDatasetsResource(self) - self.documents = resources.AsyncDocumentsResource(self) - self.jobs = resources.AsyncJobsResource(self) - self.server = resources.AsyncServerResource(self) - self.sources = resources.AsyncSourcesResource(self) - self.entities = resources.AsyncEntitiesResource(self) - self.image = resources.AsyncImageResource(self) - self.report = resources.AsyncReportResource(self) - self.structure = resources.AsyncStructureResource(self) + self.user = user.AsyncUserResource(self) + self.admin = admin.AsyncAdminResource(self) + self.datasets = datasets.AsyncDatasetsResource(self) + self.documents = documents.AsyncDocumentsResource(self) + self.jobs = jobs.AsyncJobsResource(self) + self.server = server.AsyncServerResource(self) + self.sources = sources.AsyncSourcesResource(self) + self.entities = entities.AsyncEntitiesResource(self) + self.image = image.AsyncImageResource(self) + self.report = report.AsyncReportResource(self) + self.structure = structure.AsyncStructureResource(self) self.with_raw_response = AsyncStructifyWithRawResponse(self) self.with_streaming_response = AsyncStructifyWithStreamedResponse(self) @@ -481,62 +482,62 @@ def _make_status_error( class StructifyWithRawResponse: def __init__(self, client: Structify) -> None: - self.user = resources.UserResourceWithRawResponse(client.user) - self.admin = resources.AdminResourceWithRawResponse(client.admin) - self.datasets = resources.DatasetsResourceWithRawResponse(client.datasets) - self.documents = resources.DocumentsResourceWithRawResponse(client.documents) - self.jobs = resources.JobsResourceWithRawResponse(client.jobs) - self.server = resources.ServerResourceWithRawResponse(client.server) - self.sources = resources.SourcesResourceWithRawResponse(client.sources) - self.entities = resources.EntitiesResourceWithRawResponse(client.entities) - self.image = resources.ImageResourceWithRawResponse(client.image) - self.report = resources.ReportResourceWithRawResponse(client.report) - self.structure = resources.StructureResourceWithRawResponse(client.structure) + self.user = user.UserResourceWithRawResponse(client.user) + self.admin = admin.AdminResourceWithRawResponse(client.admin) + self.datasets = datasets.DatasetsResourceWithRawResponse(client.datasets) + self.documents = documents.DocumentsResourceWithRawResponse(client.documents) + self.jobs = jobs.JobsResourceWithRawResponse(client.jobs) + self.server = server.ServerResourceWithRawResponse(client.server) + self.sources = sources.SourcesResourceWithRawResponse(client.sources) + self.entities = entities.EntitiesResourceWithRawResponse(client.entities) + self.image = image.ImageResourceWithRawResponse(client.image) + self.report = report.ReportResourceWithRawResponse(client.report) + self.structure = structure.StructureResourceWithRawResponse(client.structure) class AsyncStructifyWithRawResponse: def __init__(self, client: AsyncStructify) -> None: - self.user = resources.AsyncUserResourceWithRawResponse(client.user) - self.admin = resources.AsyncAdminResourceWithRawResponse(client.admin) - self.datasets = resources.AsyncDatasetsResourceWithRawResponse(client.datasets) - self.documents = resources.AsyncDocumentsResourceWithRawResponse(client.documents) - self.jobs = resources.AsyncJobsResourceWithRawResponse(client.jobs) - self.server = resources.AsyncServerResourceWithRawResponse(client.server) - self.sources = resources.AsyncSourcesResourceWithRawResponse(client.sources) - self.entities = resources.AsyncEntitiesResourceWithRawResponse(client.entities) - self.image = resources.AsyncImageResourceWithRawResponse(client.image) - self.report = resources.AsyncReportResourceWithRawResponse(client.report) - self.structure = resources.AsyncStructureResourceWithRawResponse(client.structure) + self.user = user.AsyncUserResourceWithRawResponse(client.user) + self.admin = admin.AsyncAdminResourceWithRawResponse(client.admin) + self.datasets = datasets.AsyncDatasetsResourceWithRawResponse(client.datasets) + self.documents = documents.AsyncDocumentsResourceWithRawResponse(client.documents) + self.jobs = jobs.AsyncJobsResourceWithRawResponse(client.jobs) + self.server = server.AsyncServerResourceWithRawResponse(client.server) + self.sources = sources.AsyncSourcesResourceWithRawResponse(client.sources) + self.entities = entities.AsyncEntitiesResourceWithRawResponse(client.entities) + self.image = image.AsyncImageResourceWithRawResponse(client.image) + self.report = report.AsyncReportResourceWithRawResponse(client.report) + self.structure = structure.AsyncStructureResourceWithRawResponse(client.structure) class StructifyWithStreamedResponse: def __init__(self, client: Structify) -> None: - self.user = resources.UserResourceWithStreamingResponse(client.user) - self.admin = resources.AdminResourceWithStreamingResponse(client.admin) - self.datasets = resources.DatasetsResourceWithStreamingResponse(client.datasets) - self.documents = resources.DocumentsResourceWithStreamingResponse(client.documents) - self.jobs = resources.JobsResourceWithStreamingResponse(client.jobs) - self.server = resources.ServerResourceWithStreamingResponse(client.server) - self.sources = resources.SourcesResourceWithStreamingResponse(client.sources) - self.entities = resources.EntitiesResourceWithStreamingResponse(client.entities) - self.image = resources.ImageResourceWithStreamingResponse(client.image) - self.report = resources.ReportResourceWithStreamingResponse(client.report) - self.structure = resources.StructureResourceWithStreamingResponse(client.structure) + self.user = user.UserResourceWithStreamingResponse(client.user) + self.admin = admin.AdminResourceWithStreamingResponse(client.admin) + self.datasets = datasets.DatasetsResourceWithStreamingResponse(client.datasets) + self.documents = documents.DocumentsResourceWithStreamingResponse(client.documents) + self.jobs = jobs.JobsResourceWithStreamingResponse(client.jobs) + self.server = server.ServerResourceWithStreamingResponse(client.server) + self.sources = sources.SourcesResourceWithStreamingResponse(client.sources) + self.entities = entities.EntitiesResourceWithStreamingResponse(client.entities) + self.image = image.ImageResourceWithStreamingResponse(client.image) + self.report = report.ReportResourceWithStreamingResponse(client.report) + self.structure = structure.StructureResourceWithStreamingResponse(client.structure) class AsyncStructifyWithStreamedResponse: def __init__(self, client: AsyncStructify) -> None: - self.user = resources.AsyncUserResourceWithStreamingResponse(client.user) - self.admin = resources.AsyncAdminResourceWithStreamingResponse(client.admin) - self.datasets = resources.AsyncDatasetsResourceWithStreamingResponse(client.datasets) - self.documents = resources.AsyncDocumentsResourceWithStreamingResponse(client.documents) - self.jobs = resources.AsyncJobsResourceWithStreamingResponse(client.jobs) - self.server = resources.AsyncServerResourceWithStreamingResponse(client.server) - self.sources = resources.AsyncSourcesResourceWithStreamingResponse(client.sources) - self.entities = resources.AsyncEntitiesResourceWithStreamingResponse(client.entities) - self.image = resources.AsyncImageResourceWithStreamingResponse(client.image) - self.report = resources.AsyncReportResourceWithStreamingResponse(client.report) - self.structure = resources.AsyncStructureResourceWithStreamingResponse(client.structure) + self.user = user.AsyncUserResourceWithStreamingResponse(client.user) + self.admin = admin.AsyncAdminResourceWithStreamingResponse(client.admin) + self.datasets = datasets.AsyncDatasetsResourceWithStreamingResponse(client.datasets) + self.documents = documents.AsyncDocumentsResourceWithStreamingResponse(client.documents) + self.jobs = jobs.AsyncJobsResourceWithStreamingResponse(client.jobs) + self.server = server.AsyncServerResourceWithStreamingResponse(client.server) + self.sources = sources.AsyncSourcesResourceWithStreamingResponse(client.sources) + self.entities = entities.AsyncEntitiesResourceWithStreamingResponse(client.entities) + self.image = image.AsyncImageResourceWithStreamingResponse(client.image) + self.report = report.AsyncReportResourceWithStreamingResponse(client.report) + self.structure = structure.AsyncStructureResourceWithStreamingResponse(client.structure) Client = Structify diff --git a/src/structify/_version.py b/src/structify/_version.py index e5b47a1d..a7af4995 100644 --- a/src/structify/_version.py +++ b/src/structify/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "structify" -__version__ = "1.66.0" # x-release-please-version +__version__ = "1.67.0" # x-release-please-version diff --git a/src/structify/resources/datasets.py b/src/structify/resources/datasets.py index aeb197cf..4a2dce17 100644 --- a/src/structify/resources/datasets.py +++ b/src/structify/resources/datasets.py @@ -206,6 +206,7 @@ def match( *, dataset: str, query_kg: KnowledgeGraphParam, + match_threshold: float | 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, @@ -237,6 +238,7 @@ def match( { "dataset": dataset, "query_kg": query_kg, + "match_threshold": match_threshold, }, dataset_match_params.DatasetMatchParams, ), @@ -562,6 +564,7 @@ async def match( *, dataset: str, query_kg: KnowledgeGraphParam, + match_threshold: float | 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, @@ -593,6 +596,7 @@ async def match( { "dataset": dataset, "query_kg": query_kg, + "match_threshold": match_threshold, }, dataset_match_params.DatasetMatchParams, ), diff --git a/src/structify/types/dataset_match_params.py b/src/structify/types/dataset_match_params.py index de5dccd7..45e1c113 100644 --- a/src/structify/types/dataset_match_params.py +++ b/src/structify/types/dataset_match_params.py @@ -19,3 +19,5 @@ class DatasetMatchParams(TypedDict, total=False): that the LLM outputs. Also the first representation of an LLM output in the pipeline from raw tool output to being merged into a Neo4j DB """ + + match_threshold: float diff --git a/src/structify/types/dataset_match_response.py b/src/structify/types/dataset_match_response.py index 7cc05d89..c760f5f9 100644 --- a/src/structify/types/dataset_match_response.py +++ b/src/structify/types/dataset_match_response.py @@ -1,28 +1,12 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import Dict, Union -from datetime import datetime -from typing_extensions import TypeAlias -from .image import Image from .._models import BaseModel -__all__ = ["DatasetMatchResponse", "Entity", "EntityProperties"] - -EntityProperties: TypeAlias = Union[str, bool, float, Image] - - -class Entity(BaseModel): - id: str - - creation_time: datetime - - label: str - - properties: Dict[str, EntityProperties] +__all__ = ["DatasetMatchResponse"] class DatasetMatchResponse(BaseModel): - entity: Entity + entity: str score: float diff --git a/tests/api_resources/test_datasets.py b/tests/api_resources/test_datasets.py index 66b34cb4..96329714 100644 --- a/tests/api_resources/test_datasets.py +++ b/tests/api_resources/test_datasets.py @@ -236,6 +236,7 @@ def test_method_match_with_all_params(self, client: Structify) -> None: } ], }, + match_threshold=0, ) assert_matches_type(DatasetMatchResponse, dataset, path=["response"]) @@ -617,6 +618,7 @@ async def test_method_match_with_all_params(self, async_client: AsyncStructify) } ], }, + match_threshold=0, ) assert_matches_type(DatasetMatchResponse, dataset, path=["response"]) diff --git a/tests/test_client.py b/tests/test_client.py index 06f1cf49..4fe09707 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -355,11 +355,11 @@ def test_default_query_option(self) -> None: FinalRequestOptions( method="get", url="/foo", - params={"foo": "baz", "query_param": "overriden"}, + params={"foo": "baz", "query_param": "overridden"}, ) ) url = httpx.URL(request.url) - assert dict(url.params) == {"foo": "baz", "query_param": "overriden"} + assert dict(url.params) == {"foo": "baz", "query_param": "overridden"} def test_request_extra_json(self) -> None: request = self.client._build_request( @@ -1121,11 +1121,11 @@ def test_default_query_option(self) -> None: FinalRequestOptions( method="get", url="/foo", - params={"foo": "baz", "query_param": "overriden"}, + params={"foo": "baz", "query_param": "overridden"}, ) ) url = httpx.URL(request.url) - assert dict(url.params) == {"foo": "baz", "query_param": "overriden"} + assert dict(url.params) == {"foo": "baz", "query_param": "overridden"} def test_request_extra_json(self) -> None: request = self.client._build_request(