BIGmama-technology / Hyko-toolkit

Collection of APIs/Models/Functions definitions in Hyko 📦
5 stars 1 forks source link

Static Badge

Hyko toolkit

Table of contents

Description

Hyko Toolkit stands as a robust repository housing a diverse collection of tools. From a curated selection of functions and APIs to state-of-the-art AI models, each component has been meticulously crafted to empower developers in constructing versatile blueprints effortlessly.

Toolkit components

The Hyko Toolkit consists of three primary categories of components: functions, models, and APIs. Let's delve into functions and models first, as they share many similarities.

Adding new function/model to the toolkit

All components of the Hyko Toolkit functions, models, and APIs—are centralized within the hyko_toolkit directory. This directory is further organized into the aforementioned categories: functions, models, and apis. Within each category directory, a structured hierarchy based on tasks (e.g., downloaders, utils, computer vision) ensures systematic organization. To integrate a new tool into the toolkit, the following steps are essential:

Adding new api to the toolkit

Adding an API to the Hyko Toolkit is a streamlined process compared to functions and models, requiring only one file: the metadata.py file. In this file, we follow a similar approach as with functions and models, documenting essential metadata such as inputs, parameters, outputs, name, description, and task. However, for APIs, we include an additional step: making the call to the API using httpx while adhering to the API specification.

Here's a breakdown of the steps involved:

  1. Create metadata.py File:

    • Develop a metadata.py file within the designated category directory (e.g., apis).
    • Document key metadata for the API, including inputs, parameters, outputs, name, description, and task.
  2. API Call Implementation:

    • Incorporate the API call within the metadata.py file, utilizing httpx.
    • Ensure that the API call conforms to the specifications outlined by the respective API.
  3. Import your API in __init__.py

    • By importing the API in the __init__.py it will be registered and discoverable by the backend.

The toolkit_builder.py script

The toolkit_builder script, written in Python, serves as a crucial tool for the Hyko Toolkit, facilitating two primary functions:

  1. Docker Image Building: For functions and models found within the hyko_toolkit directory, the script first builds the Docker image specific to each tool.

  2. Metadata Extraction and Database Writing: Subsequently, the script traverses through all categories (functions, models, and APIs), extracting metadata for each tool. This includes JSON schema information for inputs, parameters, and outputs defined in the metadata.py file. The extracted metadata is then written to the Hyko database, utilizing credentials specified in the .env file.

Building the toolkit

Follow these steps to set up and build the Hyko Toolkit:

  1. Ensure you have Poetry and pyenv installed on your system. You can refer to the following links for installation guidance:
  1. Clone the repository:

    git clone https://github.com/BIGmama-technology/Hyko-toolkit.git toolkit
    cd toolkit
  2. Execute the setup script to install the Python version used with the Hyko Toolkit (3.11.6) and install the required dependencies using Poetry. This script also activates the new virtual environment.

    make setup
  3. Copy the .env.example file and rename it to .env.

    cp .env.example .env
  4. Build the toolkit: Use the build command to execute the toolkit_builder.py script. You can specify optional parameters:

    dir (default: hyko_toolkit): the directory you want the toolkit_builder.py script to go through (Make sure to only specify directories that have Dockerfile in them since the script right now can't go backwards when traversing the tree, only down.)

    host (default: traefik.me): this is used to specify which running backend to write to it the toolkit metadata (At this point you should have your credentials in the .env file else the api will return a 401 response).

    make build dir=hyko_toolkit/functions/utils host=stage.hyko.ai