Develop and publish a large language model (LLM)-based chatbot on Domino with the Streamlit framework. Learn how to quickly create a Domino-hosted app that takes user input to call generative artificial intelligence (AI) APIs from Hugging Face and your own Domino model API.

For more generative AI LLM sample projects, see Domino LLM Reference Projects.
To complete this how-to you must fulfill the following prerequisites.
Hugging Face API key
Get a Hugging Face API key to access models hosted on Hugging Face.
-
Create your account on Hugging Face.
-
Create a new Domino user level environment variable called
HUGGING_FACE_API_TOKENand add your API key as its value.
Jupyter server proxy
Create a compute environment in Domino with Jupyter or Jupyterlab and jupyter server proxy. If you use a Domino Standard Environment, then Jupyter, Jupyterlab, and jupyter server proxy are already installed for you.
Domino Model API
The app uses both a Hugging Face model API and a Domino model API to demonstrate how to access multiple models from a single app.
To host the model used in this how-to, follow the instructions in the Domino Streamlit app repository.
You will create an app frontend using Streamlit chat elements to interact with two different models and get answers to movie-based questions.
The app uses a model from the Hugging Face LLM Models repo to generate lists of movies, and another model deployed as a Domino Model API to classify movie summaries by genre.

Create a simple chat app that has the following elements:
-
Title.
-
Sidebar with the following:
-
A password field to add a Hugging Face API key.
-
A radio button to select between the two models.
-
-
A body with the chat interface.

You can interactively develop your Streamlit app in a Domino Workspace and see your changes live via an app URL.
Create the app title and sidebar
-
Launch a new Jupyter or Jupyterlab workspace in Domino. Make sure the jupyter server proxy package is installed.
-
Create a new file in your
/mntdirectory calledchatbot.py -
Add the following code to add a title and sidebar.
import streamlit as st import os import json import requests import pandas as pd API_TOKEN = os.environ['HUGGING_FACE_API_TOKEN'] API_URL = "https://api-inference.huggingface.co/models/microsoft/DialoGPT-large" headers = {"Authorization": f"Bearer {API_TOKEN}"} # App title st.set_page_config(page_title="🤖💬 Your Personal Chat Assistant") # App sidebar with st.sidebar: st.title('
