Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Plugin - Hugging Face #6352

Open
Ben8t opened this issue Dec 6, 2024 · 2 comments
Open

New Plugin - Hugging Face #6352

Ben8t opened this issue Dec 6, 2024 · 2 comments
Assignees
Labels
area/plugin Plugin-related issue or feature request good first issue Great issue for new contributors kind/highlight One of the highlights of the upcoming release kind/quick-win Seems to be quick to do

Comments

@Ben8t
Copy link
Member

Ben8t commented Dec 6, 2024

Feature description

Currently the http plugins makes possible to call Hugging Face models hosted behind Inference API.

Here is an example:

  - id: llm_categorization
    type: io.kestra.plugin.core.http.Request
    uri: https://api-inference.huggingface.co/models/facebook/bart-large-mnli
    method: POST
    contentType: application/json
    headers:
      Authorization: "Bearer {{ secret('HF_API_TOKEN') }}"
    formData:
      inputs: "I want a refund"
      parameters:
        candidate_labels:
          - "legal"
          - "new feature"
          - "refund"

Most of the text models available under these API follow the same type of parameters. Here are the two main ones we can cover at first:

Simple inputs

curl https://api-inference.huggingface.co/models/meta-llama/Llama-3.2-1B \
	-X POST \
	-d '{"inputs": "Can you please let us know more details about your "}' \
	-H 'Content-Type: application/json' \
	-H 'Authorization: Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

inputs and parameters:

curl https://api-inference.huggingface.co/models/facebook/bart-large-mnli \
	-X POST \
	-d '{"inputs": "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!", "parameters": {"candidate_labels": ["refund", "legal", "faq"]}}' \
	-H 'Content-Type: application/json' \
	-H 'Authorization: Bearer hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

Task Design

Task Type: io.kestra.plugin.huggingface.Inference

Properties:

  • apiKey - STRING - required
  • model - STRING - required - /, it's what follows the main api endpoint https://api-inference.huggingface.co/models ie. meta-llama/Llama-3.2-1B
  • inputs - STRING - optional most of the time it's the prompt
  • parameters - MAP/ARRAY - optional
  • endpoint - STRING - optional, default to https://api-inference.huggingface.co/models

Example

So instead of using http like this:

  - id: llm_categorization
    type: io.kestra.plugin.core.http.Request
    uri: https://api-inference.huggingface.co/models/facebook/bart-large-mnli
    method: POST
    contentType: application/json
    headers:
      Authorization: "Bearer {{ secret('HF_API_TOKEN') }}"
    formData:
      inputs: "I want a refund"
      parameters:
        candidate_labels:
          - "legal"
          - "new feature"
          - "refund"

we simplify with Kestra DSL to:

  - id: llm_categorization
    type: io.kestra.plugin.huggingface.Inference
    model: facebook/bart-large-mnli
    apiKey: XXXX
    inputs: "I want a refund"
    parameters:
      candidate_labels:
         - "legal"
         - "new feature"
         - "refund"
@Ben8t Ben8t added area/backend Needs backend code changes enhancement New feature or request area/frontend Needs frontend code changes labels Dec 6, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Issues Dec 6, 2024
@Ben8t Ben8t added area/plugin Plugin-related issue or feature request kind/quick-win Seems to be quick to do kind/highlight One of the highlights of the upcoming release good first issue Great issue for new contributors and removed area/backend Needs backend code changes enhancement New feature or request area/frontend Needs frontend code changes labels Dec 6, 2024
@ksprabhatkumar
Copy link

ksprabhatkumar commented Dec 7, 2024

assign this issue to me i would like to work on this issue

@MilosPaunovic
Copy link
Member

Do you know how to approach it? Gone through the whole Plugin Developer Guide? If you're not certain about it, may I suggest that you check our curated list of good first issues to see if there is something you find interesting enough and think you can tackle independently. It can be further filtered by desired labels to narrow down the results (suggesting to filter by either area/backend or area/frontend ones, based on your preferences).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugin Plugin-related issue or feature request good first issue Great issue for new contributors kind/highlight One of the highlights of the upcoming release kind/quick-win Seems to be quick to do
Projects
Status: Backlog
Development

No branches or pull requests

4 participants