Skip to content

Instantly share code, notes, and snippets.

# import libraries
from flask import request, jsonify, Flask, abort
import transformers
from transformers import pipeline
import humingbird
# start flask app
app = Flask(__name__)
# download GPT-2/load the model
{
"prompt": "I am building a Humingbird app for everyone at 12:00 am, but I do it for the"
}
{
"generated_text": "I am building a Humingbird app for everyone at 12:00 am, but I do it for the people of the world ....",
"warning": "WARNING: This output may contain sensitive or toxic text. Please use with caution."
}
import humingbird
intent_recognition = humingbird.Text.predict(
text="I was wondering what you have on your menu? I love ice cream!",
labels=["greeting", "goodbye", "menu", "prices", "start_order"]
)
print(intent_recognition)
{
"greetings": ["Hi! Welcome to the ice cream shop.", "Welcome! What can i help you with?"],
"goodbyes": ["Goodbye!", "Nice chatting! Have a great day."],
"menu": ["Here is our menu: https://www.randomicecream.co"],
"prices": ["Our prices our affordable for all!", "We have super low prices! Pracitcally free!"],
"start_order": ["Lets start the order here: https://www.fakepaymentlink.com"]
}
import humingbird
import random
intents = {
"greeting": ["Hi! Welcome to the ice cream shop.", "Welcome! What can i help you with?"],
"goodbye": ["Goodbye!", "Nice chatting! Have a great day."],
"menu": ["Here is our menu: https://www.randomicecream.co"],
"prices": ["Our prices our affordable for all!", "We have super low prices! Pracitcally free!"],
"start_order": ["Lets start the order here: https://www.fakepaymentlink.com"]
}
import humingbird
prediction = humingbird.Image.predict(
image_path='ice-cream.jpg',
labels=["strawberry ice cream", "vanilla ice cream", "chocolate ice cream"] # add more if you'd like :)
)
print(prediction)
import humingbird
import random
intents = {
"greeting": ["Hi! Welcome to the ice cream shop.", "Welcome! What can i help you with?"],
"goodbye": ["Goodbye!", "Nice chatting! Have a great day."],
"menu": ["Here is our menu: https://www.randomicecream.co"],
"prices": ["Our prices our affordable for all!", "We have super low prices! Pracitcally free!"],
"start_order": ["Lets start the order here: https://www.fakepaymentlink.com"]
}