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

Misc fixes #203

Merged
merged 2 commits into from
Nov 22, 2023
Merged
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
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,25 @@ print(result.document)
```python
from mindee import Client, product

# Init a new client and add your custom endpoint (document)
# Init a new client
mindee_client = Client(api_key="my-api-key")
custom_endpoint = mindee_client.create_endpoint(
account_name="john",
endpoint_name="wnine",

# Add your custom endpoint (document)
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
)

# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")

# Parse the file.
# The endpoint must be specified since it can't be determined from the class.
result = parse(product.CustomV1, endpoint=custom_endpoint)
# The endpoint must be specified since it cannot be determined from the class.
result = mindee_client.parse(
product.CustomV1,
input_doc,
endpoint=my_endpoint
)

# Print a brief summary of the parsed data
print(result.document)
Expand All @@ -109,12 +115,14 @@ Allows sending only certain pages in a PDF.
In this example we only send the first, penultimate and last pages:

```python
api_response = mindee_client.parse(
mindee.product.InvoiceV4,
from mindee import Client, product, PageOptions

result = mindee_client.parse(
product.InvoiceV4,
input_source,
page_options=mindee.PageOptions(
page_options=PageOptions(
page_indexes=[0, -2, -1],
operation: mindee.PageOptions.KEEP_ONLY,
operation=PageOptions.KEEP_ONLY,
on_min_pages=2
)
)
Expand Down
16 changes: 12 additions & 4 deletions docs/extras/code_samples/custom_v1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,22 @@ from mindee import Client, PredictResponse, product
# Init a new client
mindee_client = Client(api_key="my-api-key")

custom_endpoint = mindee_client.create_endpoint("my-endpoint", "my-account")
# Add your custom endpoint (document)
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
)

# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")

# Load a file from disk and parse it.
# The endpoint name must be specified since it cannot be determined from the class.
result: PredictResponse = mindee_client.parse(product.CustomV1, input_doc, endpoint=custom_endpoint)
# Parse the file.
# The endpoint must be specified since it cannot be determined from the class.
result: PredictResponse = mindee_client.parse(
product.CustomV1,
input_doc,
endpoint=my_endpoint
)

# Print a brief summary of the parsed data
print(result.document)
Expand Down
17 changes: 11 additions & 6 deletions docs/extras/guide/custom_v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ from mindee import Client, product
# Init a new client
mindee_client = Client(api_key="my-api-key")

# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")
# Add your custom endpoint (document)
my_endpoint = mindee_client.create_endpoint(
account_name="my-account",
endpoint_name="my-endpoint",
account_name="my-account-name",
version="my-version",
)

# Parse the document as an invoice by passing the appropriate type
# Load a file from disk
input_doc = mindee_client.source_from_path("/path/to/the/file.ext")

# Parse the file.
# The endpoint must be specified since it cannot be determined from the class.
result = mindee_client.parse(
product.CustomV1,
input_doc,
Expand All @@ -29,6 +31,10 @@ result = mindee_client.parse(

# Print a brief summary of the parsed data
print(result.document)

# Iterate over all the fields in the document
for field_name, field_values in result.document.fields.items():
print(field_name, "=", field_values)
```

# Custom Endpoints
Expand All @@ -47,7 +53,6 @@ If it is not set, it will default to "1".

A `ListField` is a special type of custom list that implements the following:


* **confidence** (`float`): the confidence score of the field prediction.
* **reconstructed** (`bool`): indicates whether or not an object was reconstructed (not extracted as the API gave it).
* **values** (`List[`[ListFieldValue](#list-field-value)`]`): list of value fields
Expand Down
2 changes: 1 addition & 1 deletion mindee/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class CommandConfig(Generic[TypeInference]):
help="Custom document type from API builder",
doc_class=product.CustomV1,
is_sync=True,
is_async=True,
is_async=False,
sebastianMindee marked this conversation as resolved.
Show resolved Hide resolved
),
"eu-license-plate": CommandConfig(
help="EU License Plate",
Expand Down
Loading