This example uses the Unstructured Ingest Python library or the Unstructured JavaScript/TypeScript SDK to send a PDF file to Unstructured API services for processing. Unstructured processes the PDF and extracts the PDF’s content. This example then sends some of the content to HuggingChat, Hugging Face’s open-source AI chatbot, along with some queries about this content.

To run this example, you’ll need:

These environment variables:

  • UNSTRUCTURED_API_KEY - Your Unstructured API key value.
  • UNSTRUCTURED_API_URL - Your Unstructured API URL.

These environment variables:

  • HUGGING_FACE_EMAIL, representing your Hugging Face account’s email address.
  • HUGGING_FACE_PASSWORD, representing your Hugging Face account’s email address.
  • HUGGING_FACE_COOKIE_DIR_PATH, representing a login cookie cache path, typically ./cookies/ or ./login_cache/.

This example’s code is as follows: