Skip to main content

A framework for writing Unstract Tools/Apps

Project description

Unstract

No-code LLM Platform to launch APIs and ETL Pipelines to structure unstructured documents

Unstract SDK

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.

Installation

  • 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
      

Tools

Create a scaffolding for a new tool

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

Environment variables required for all Tools

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

Llama Index support

Unstract SDK 0.3.2 uses the following version of Llama Index Version 0.9.28 as on January 14th, 2024

Developing with the SDK

Ensure that you have all the required dependencies and pre-commit hooks installed

uv sync
pre-commit install

Once the changes have been made, it can be tested with Unstract through the following means.

With UV

Specify the SDK as a dependency to a project using a tool like uv by adding the following to your pyproject.toml

dependencies = [
    "unstract-sdk"
]

[dependency-groups]
dev = [
"unstract-sdk"
]

[tool.uv.sources]
unstract-sdk = { path = "${UNSTRACT_SDK_PATH", editable = true  }

With pip

  • If the project is using pip it might be possible to add it as a dependency in requirements.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 = ["hatchling"]
build-backend = "hatchling.build"
  • 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 run apt install git within the Dockerfile for this
[tool.uv.sources]
unstract-sdk = { git = "git+https://github.com/Zipstack/unstract-sdk@feature-branch" }
  • Or try installing a local PyPI server and upload / download your package from this server

Additonal dependencies for tool

Tools may need to be backed up by a file storage. unstract.sdk.file_storage contains the required interfaces for the same. fsspec 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 needs 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

Documentation generation

Follow this README.md for generating documentation.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unstract_sdk-0.70.1.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

unstract_sdk-0.70.1-py3-none-any.whl (263.8 kB view details)

Uploaded Python 3

File details

Details for the file unstract_sdk-0.70.1.tar.gz.

File metadata

  • Download URL: unstract_sdk-0.70.1.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.11

File hashes

Hashes for unstract_sdk-0.70.1.tar.gz
Algorithm Hash digest
SHA256 ef3d1fcdae046f709d09e8b6726c4f5b5877b6c16bff9dae183e8c80b664e943
MD5 bca13ef82706cb32662322e85b2c10ef
BLAKE2b-256 d5bc9db03d95493b39dfd3fb1249b1966cb38c481c1c2893ac71f4f08a3749b6

See more details on using hashes here.

File details

Details for the file unstract_sdk-0.70.1-py3-none-any.whl.

File metadata

File hashes

Hashes for unstract_sdk-0.70.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf1339959abde599f3c3112f73145b93cb9558a4aa267e4e5514f5149898cd72
MD5 2e59afb2885e795e11e8edc9eb0d21a5
BLAKE2b-256 eb6372a2662972bc740fbc650b746fbbfa0a89d9d757b66a6041eaf559907b35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page