Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: Prepare for breaking change in upcoming unstructured-client #379

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
## 0.5.2-dev0
## 0.5.2-dev1

### Enhancements

* **Only embed elements with text** - Only embed elements with text to avoid errors from embedders and optimize calls to APIs.

### Fixes

* **Address forward compatibility issue in unstructured-client** - As of unstructured-client==0.30.0, the `server_url` is passed to the method rather than the client instance.

## 0.5.1

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion unstructured_ingest/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.2-dev0" # pragma: no cover
__version__ = "0.5.2-dev1" # pragma: no cover
14 changes: 10 additions & 4 deletions unstructured_ingest/v2/unstructured_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,16 @@ async def call_api_async(
"""
from unstructured_client import UnstructuredClient

# Note(austin) - the sdk takes the base url, but users may pass the full endpoint
# For consistency, strip off the path when it's given
base_url = server_url[:-19] if "/general/v0/general" in server_url else server_url

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be safer to split on /general/v0/general in case there are trailing spaces or tabs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also server_url is an optional parameter, so it would make sense to check if it exists.


client = UnstructuredClient(
server_url=server_url,
api_key_auth=api_key,
)
partition_request = create_partition_request(filename=filename, parameters_dict=api_parameters)
try:
res = await client.general.partition_async(request=partition_request)
res = await client.general.partition_async(server_url=base_url, request=partition_request)
except Exception as e:
raise wrap_error(e)

Expand All @@ -115,13 +118,16 @@ def call_api(
"""
from unstructured_client import UnstructuredClient

# Note(austin) - the sdk takes the base url, but users may pass the full endpoint
# For consistency, strip off the path when it's given
base_url = server_url[:-19] if "/general/v0/general" in server_url else server_url

client = UnstructuredClient(
server_url=server_url,
api_key_auth=api_key,
)
partition_request = create_partition_request(filename=filename, parameters_dict=api_parameters)
try:
res = client.general.partition(request=partition_request)
res = client.general.partition(server_url=base_url, request=partition_request)
except Exception as e:
raise wrap_error(e)

Expand Down
Loading