On running the line below for processing PDFs -
resp = s.general.partition(req)
I get the below error-
NameError: name ‘s’ is not defined
Does anyone know how to solve this?
On running the line below for processing PDFs -
resp = s.general.partition(req)
I get the below error-
NameError: name ‘s’ is not defined
Does anyone know how to solve this?
Make sure that the variable ‘s’ is properly defined and assigned a value before calling the partition method. Also, check for any misspellings or incorrect variable scopes (such as being defined within a different function or block of code) too.
I am using the code directly as given in the course notebook. I wonder if there is anything that I need to change for it to run successfully.
The code that I am trying to run -
filename = “example_files/CoT.pdf”
with open(filename, “rb”) as f:
files=shared.Files(
content=f.read(),
file_name=filename,
)
req = shared.PartitionParameters(
files=files,
strategy=‘hi_res’,
pdf_infer_table_structure=True,
languages=[“eng”],
)
try:
resp = s.general.partition(req)
print(json.dumps(resp.elements[:3], indent=2))
except SDKError as e:
print(e)
You must import the required library and define ‘s’ using the UnstructuredClient class from the unstructured_client module:
from unstructured_client import UnstructuredClient
s = UnstructuredClient(api_key_auth="YOUR_API_KEY")
Then, replace “YOUR_API_KEY” with the actual API key obtained from the website https://unstructured.io/
Documentation link: https://unstructured-io.github.io/unstructured/apis/api_sdks.html
Thanks Alireza.
This worked for me!
You’re welcome! Happy to help
Also worked for me. Thanks!