diff --git a/transform/sample-code/extract_quickstart.py b/transform/sample-code/extract-quickstart.py similarity index 88% rename from transform/sample-code/extract_quickstart.py rename to transform/sample-code/extract-quickstart.py index 6d7506b..63d673e 100644 --- a/transform/sample-code/extract_quickstart.py +++ b/transform/sample-code/extract-quickstart.py @@ -7,12 +7,24 @@ from unstructured_client.models.operations import CreateJobRequest, DownloadJobOutputRequest from unstructured_client.models.shared import BodyCreateJob, InputFiles + +# Set the variables below this validation function before running this script. +def validate_inputs(api_key, input_dir, output_dir): + # Checks that the settings below have been changed from their placeholder values. + if api_key in ("YOUR_API_KEY_HERE", ""): + raise SystemExit("Set API_KEY to your Unstructured API key before running this script.") + if input_dir in ("/full/path/to/your/input/directory", ""): + raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.") + if output_dir in ("/full/path/to/your/output/directory", ""): + raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.") + + # API_KEY is included here as a local variable for ease of use in this quickstart. # This isn't best practice outside of local testing on your own machine. Once # you've added your real key, don't share this file or check it into any # repositories. -API_KEY = "" -API_URL = "https://platform-api.transform.unstructured.io" +API_KEY = "YOUR_API_KEY_HERE" +API_URL = "https://platform-api.transform.unstructured.io/api/v1" # The local directory containing the file (or files) you want to process. INPUT_DIR = "/full/path/to/your/input/directory" # The local directory where you want the results saved. @@ -23,6 +35,8 @@ # further down in this script does that. EXTRACTION_PROMPT = "Dates are in MM/DD/YYYY format on the form. Represent them as YYYY-MM-DD. Combine the home address, city, state, and ZIP code fields into a single address string." +validate_inputs(API_KEY, INPUT_DIR, OUTPUT_DIR) + client = UnstructuredClient( api_key_auth=API_KEY, server_url=API_URL diff --git a/transform/sample-code/partition_quickstart.py b/transform/sample-code/partition-quickstart.py similarity index 77% rename from transform/sample-code/partition_quickstart.py rename to transform/sample-code/partition-quickstart.py index 29a2659..cedac13 100644 --- a/transform/sample-code/partition_quickstart.py +++ b/transform/sample-code/partition-quickstart.py @@ -7,17 +7,31 @@ from unstructured_client.models.operations import CreateJobRequest, DownloadJobOutputRequest from unstructured_client.models.shared import BodyCreateJob, InputFiles + +# Set the variables below this validation function before running this script. +def validate_inputs(api_key, input_dir, output_dir): + # Checks that the settings below have been changed from their placeholder values. + if api_key in ("YOUR_API_KEY_HERE", ""): + raise SystemExit("Set API_KEY to your Unstructured API key before running this script.") + if input_dir in ("/full/path/to/your/input/directory", ""): + raise SystemExit("Set INPUT_DIR to the local directory containing the file (or files) you want to process before running this script.") + if output_dir in ("/full/path/to/your/output/directory", ""): + raise SystemExit("Set OUTPUT_DIR to the local directory where you want the results saved before running this script.") + + # API_KEY is included here as a local variable for ease of use in this quickstart. # This isn't best practice outside of local testing on your own machine. Once # you've added your real key, don't share this file or check it into any # repositories. -API_KEY = "" -API_URL = "https://platform-api.transform.unstructured.io" +API_KEY = "YOUR_API_KEY_HERE" +API_URL = "https://platform-api.transform.unstructured.io/api/v1" # The local directory containing the file (or files) you want to process. INPUT_DIR = "/full/path/to/your/input/directory" # The local directory where you want the results saved. OUTPUT_DIR = "/full/path/to/your/output/directory" +validate_inputs(API_KEY, INPUT_DIR, OUTPUT_DIR) + client = UnstructuredClient( api_key_auth=API_KEY, server_url=API_URL