The unstract-sdk
package helps with developing tools that are meant to be run on the Unstract platform. This includes
modules to help with tool development and execution, caching, making calls to LLMs / vectorDBs / embeddings .etc.
They also contain helper methods/classes to aid with other tasks such as indexing and auditing the LLM calls.
- The below libraries need to be installed to run the SDK
-
Linux
sudo apt install build-essential pkg-config libmagic-dev
-
Mac
brew install pkg-config libmagic pandoc tesseract-ocr
-
Example
unstract-tool-gen --command NEW --tool-name <name of tool> \
--location ~/path_to_repository/unstract-tools/ --overwrite false
Supported commands:
NEW
- Create a new tool
Variable | Description |
---|---|
PLATFORM_SERVICE_HOST |
The host in which the platform service is running |
PLATFORM_SERVICE_PORT |
The port in which the service is listening |
PLATFORM_SERVICE_API_KEY |
The API key for the platform |
TOOL_DATA_DIR |
The directory in the filesystem which has contents for tool execution |
Unstract SDK 0.3.2 uses the following version of Llama Index Version 0.9.28 as on January 14th, 2024
Ensure that you have all the required dependencies and pre-commit hooks installed
pdm install
pre-commit install
Once the changes have been made, it can be tested with Unstract through the following means.
Specify the SDK as a dependency to a project using a tool like pdm
by adding the following to your pyproject.toml
[tool.pdm.dev-dependencies]
local_copies = [
"-e unstract-adapters @ file:///${UNSTRACT_ADAPTERS_PATH}",
"-e unstract-sdk @ file:///${UNSTRACT_SDK_PATH}",
]
Or by running the below command
pdm add -e /path/to/unstract-sdk --dev
- If the project is using
pip
it might be possible to add it as a dependency inrequirements.txt
-e /path/to/unstract-sdk
NOTE: Building locally might require the below section to be replaced in the unstract-sdk
's build system configuration
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
- Another option is to provide a git URL in
requirements.txt
, this can come in handy while building tool docker images. Don't forget to runapt install git
within theDockerfile
for this
unstract-sdk @ git+https://github.com/Zipstack/unstract-sdk@feature-branch
- Or try installing a local PyPI server and upload / download your package from this server
Tools may need to be backed up by a file storage. unstract.sdk.file_storage contains the required interfaces for the same. fssepc is being used underneath to implement these interfaces. Hence, one can choose to use a file_system supported by fsspec for this. However, the required dependencies need to be added in the tool dependency manager. Eg. If the tool is using Minio as the underlying file storage, then s3fs can be added to support it. Similarly, for Google Cloud Storage, gcsfs is to be added. The following versions are tested in the SDK using unit test cases for the above package. gcsfs==2024.10.0 s3fs==2024.10.0
Follow this README.md for generating documentation.