Skip to main content

🚀 HumanFirst SDK (humanfirst-module)


The HumanFirst SDK (humanfirst-module) is a Python package that simplifies the integration and interaction with the HumanFirst platform - It is a no-code tool specializing in Data Engineering, Prompt Engineering, Context Engineering, Conversational AI and NLU.

SDK provides a set of tools, helper classes, and API methods to streamline working with the HumanFirst JSON format, API endpoints, and Secure authorization.


🎯 Key Features

  • HumanFirst Objects: Helper classes to describe, validate, and manipulate the core data structures used in the HumanFirst platform.
  • HumanFirst APIs: A streamlined way to interact with the HumanFirst APIs for managing datasets, labels, prompts, pipelines and more.
  • Secure Authorization: Simplified handling of secure API authentication and token management.

📦 Installation

Install the package using pip:

pip install humanfirst

🧩 Components Overview

  1. humanfirst.objects: A set of helper classes and methods for describing, validating, and interacting with HFObjects that make up the HumanFirst JSON format.

    • Validate and manipulate HumanFirst objects.
    • Convert between Python objects and HumanFirst JSON structures.
  2. humanfirst.apis: Helper classes to interact with the HumanFirst APIs.

    • Perform CRUD operations on datasets and projects.
    • Easily integrate HumanFirst functionalities into your applications.
  3. humanfirst.authorization: Handles secure authorization for interacting with HumanFirst APIs.

    • Manage API keys and tokens.
    • Ensure secure communication with the HumanFirst platform.

📖 Usage Example

Here's a basic example of how to use the HumanFirst SDK to connect to the HumanFirst API and perform operations:

Follow the authentication steps given in the development setup below.

import humanfirst

# Step 1 : Initialize the API
hf_api = humanfirst.apis.HFAPI()

# Step 2: Perform an API call (e.g., fetching a list of projects)
playbook_list = hf_api.list_playbooks(namespace="<namespace>")

print(playbook_list)

⚙️ Development Setup

For contributors and developers, you can set up the package locally by cloning the repository and installing the necessary dependencies:

# Clone the repo
git clone https://github.com/zia-ai/humanfirst-module.git

# Navigate into the project directory
cd humanfirst-module

Create Virtual Environment to do any dev work and perform pytest work

  • Remove any previously created virtual env rm -rf ./venv
  • Create virtualenv & activate python3 -m venv venv
  • if bash shell source venv/bin/activate In case of deactivating use "deactivate"
  • Update PiP python -m pip install --upgrade pip
  • install requirements pip install -r requirements.txt --no-cache

Authentication

  1. Either use firebase authentication
    • Set your HF_USERNAME and HF_PASSWORD env variable
  2. Or use HumanFirst API Key
    • Set HF_API_KEY env variable
    • Follow the steps here to get API key

Log handling

  • HF SDK logging offers multiple options. Either can save the logs, print them in the console, do both or none
  • To store the logs in a specific directory set HF_LOG_FILE_ENABLE to 'TRUE' and set the directory in HF_LOG_DIR where the log files needs to be stored.
  • Log file management
    • Rotating File Handler is used
    • When the log file size exceeds 100MB (Hard coded). Automatically a new file is created and old one is saved
    • Can go to upto 4 additional log files
    • If the number of log files exceed the additional log file count + 1, then automatically the oldest log file is gets replaced with new log information
  • Can set log levels using HF_LOG_LEVEL. Accepts - 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'
  • To print the logs in console set exp to 'TRUE'
  • Default - the logs are neither saved nor printed onto console

Using pytest to test everything is working fine

Running on production

This is the default.

pytest --cov ./humanfirst/ --cov-report html --cov-report term

  • --cov-report html - produces a report in HTML page
  • --cov-report term - prints the report in console
  • --cov-report term:skip-covered - helps to see uncovered parts

Testing using Docker build for this module

Check docker is working with docker run hello-world or sudo docker run hello-world depending on whether you have a user or root docker setup.

  • docker build . -t humanfirst-module:latest --no-cache To run the tests for this module we pass through the necessary env variables echo $HF_ENVIRONMENT $BASE_URL_TEST $HF_USERNAME $HF_PASSWORD
docker run \
-e "HF_USERNAME=$HF_USERNAME" \
-e "HF_PASSWORD=$HF_PASSWORD" \
--name humanfirst-module-0 \
humanfirst-module \
pytest -s --cov ./humanfirst/ --cov-report term

To install humanfirst package locally

pip install dist/humanfirst-<version number>.tar.gz --no-cache

For more details on developer setup visit Developer README.md


🔧 Configuration Files

The package includes configuration files located in the config/ directory.

config/
│
├── logging.conf
└── setup.cfg
  • logging.conf - contains all the logging related configurations
  • setup.cfg - contains all important default constants

📚 API Reference

For detailed API reference, visit the official documentation:

📖 Documentation: https://docs.humanfirst.ai/docs/api/

📂 Source Code APIs: https://github.com/zia-ai/humanfirst-module/blob/master/humanfirst/apis.py


🤝 Contributing

We welcome contributions to the HumanFirst SDK! If you find a bug or have a feature request, please open an issue on GitHub.

Steps to Contribute:

  • Fork the repository.
  • Create a new branch for your feature/bugfix.
  • Submit a pull request.

📄 License

This project is licensed under the MIT License. See the LICENSE file for more details.


💬 Support

If you have any questions or need support, feel free to reach out:

📧 Email: fayaz@humanfirst.ai

💻 GitHub Issues: https://github.com/zia-ai/humanfirst-module/issues


🌐 Official Website: https://www.humanfirst.ai

📚 Documentation: https://docs.humanfirst.ai/docs

🐙 GitHub Repo: https://github.com/zia-ai/humanfirst-module

🐞 Issue Tracker: https://github.com/zia-ai/humanfirst-module/issues


Metadata

Release files for humanfirst 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for humanfirst 2.2.0
File Size Uploaded Provenance Actions
humanfirst-2.2.0.tar.gz 121.9 kB Without provenance Details for humanfirst-2.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for humanfirst 2.2.0
File Interpreter ABI Platform Actions
humanfirst-2.2.0-py3-none-any.whl Python 3 none any Details for humanfirst-2.2.0-py3-none-any.whl

Total release size: 240.8 kB

Release files / humanfirst-2.2.0.tar.gz

Download URL humanfirst-2.2.0.tar.gz
Size 121.9 kB
Tags Source
SHA-256 checksum
How to use checksums
42823a6722fa663f99ff27cbb4ea1b3e6832cc2f5b4138fab6b80398ca24ae24
BLAKE2b-256 checksum
How to use checksums
f448658596eca30714648a190af2e0bd3aff40b4671673dd4cd407da168903ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.6

Release files / humanfirst-2.2.0-py3-none-any.whl

Download URL humanfirst-2.2.0-py3-none-any.whl
Size 119.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
769fa4205b32258389460097739f8567be01bc6788bc1e1564be163fe01be946
BLAKE2b-256 checksum
How to use checksums
b08ca8dde9ff4afe4fd35e5d1e93bdd30da3bf33b3112c8ec3c5b215f2b56f26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.6

Security for humanfirst 2.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page