Skip to content

Commit

Permalink
Merge pull request #51 from kestra-io/blueprint/huggingface
Browse files Browse the repository at this point in the history
[FOR 0.21] Add HuggingFace blueprint
  • Loading branch information
anna-geller authored Feb 4, 2025
2 parents 1577a31 + 5dd6825 commit 60b9276
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions flows/huggingface_message_classification.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
id: hugging_face
namespace: blueprint

inputs:
- id: message_id
type: STRING

tasks:
- id: retrieve_data
type: io.kestra.plugin.jdbc.postgresql.Query
sql: SELECT user_id, message FROM customer.message WHERE message_id = '{{ inputs.message_id }}'
fetchType: FETCH_ONE

- id: classification
type: io.kestra.plugin.huggingface.Inference
model: facebook/bart-large-mnli
apiKey: "{{ secret('HUGGINGFACE_API_KEY') }}"
inputs: "{{ json(outputs.retrieve_data.row).message }}"
parameters:
candidate_labels:
- "support"
- "warranty"
- "upsell"
- "help"

- id: insert_category
type: io.kestra.plugin.jdbc.postgresql.Query
sql: UPDATE customer.message SET category = '{{ json(outputs.classification.output).labels[0] }}' WHERE message_id = '{{ inputs.message_id }}'


pluginDefaults:
- type: io.kestra.plugin.jdbc.postgresql
values:
url: jdbc:postgresql://"{{secret('POSTGRES_HOST')}}"
username: "{{secret('POSTGRES_USERNAME')}}"
password: "{{secret('POSTGRES_PASSWORD')}}"

extend:
title: Use HuggingFace Inference API to classify customer message
description: >-
This flow retrieve data from a Postgres database and use the HuggingFace Inference API to classify a customer message.
Documentation about the HugginFace Inference API endpoint and how to create an API key can be find [here](https://huggingface.co/docs/api-inference/index).
tags:
- AI
- SQL
- API
ee: false
demo: false
meta_description: This flow retrieve data from a Postgres database and use the HuggingFace Inference API to classify a customer message.

0 comments on commit 60b9276

Please sign in to comment.