Tutorial 2A: Build an AI-powered chatbot (model) to enhance a website's search capabilities
Overview​
This tutorial with Enterprise h2oGPTe and Python builds an AI-powered chatbot to replace the function of a website's search bar, which, in turn, builds something better to enable users to obtain better answers to their questions about the website. In this tutorial, we will create an AI-powered chatbot to enhance the search capabilities of the H2O Model Validation documentation website.
Objectives​
- Understand how to crawl a website and convert its pages into documents using Enterprise h2oGPTe.
- Learn how to create a Collection-specific API Key in Enterprise h2oGPTe and use it to chat with a Collection.
- Understand how to use Python and the Enterprise h2oGPTe client to Chat with a website and retrieve information from it.
- Learn how to create an AI-powered chatbot to enhance the search capabilities of a website.
Prerequisites​
- (Optional) Review the Enterprise h2oGPTe flow
- Complete Tutorial 1A: A quick introduction to Enterprise h2oGPTe
- Basic understanding of Python
Step 1: Crawl website​
Enterprise h2oGPTe enables you to crawl a website, which converts the specified website pages into Documents that can be associated with a Collection that you can Chat with. For this tutorial, we will crawl the H2O Model Validation documentation website.
- On the Enterprise h2oGPTe navigation menu, click Collections.
- Click + New collection.
- In the Collection name box, enter:
tutorial-2a
- In the Description box, enter:
An AI-powered chatbot (model) to enhance website search
- Click Create.
- Click + Add documents.
- In the Choose method list, select Import web pages.
- In the URL to import web pages from box, enter:
https://docs.h2o.ai/wave-apps/h2o-model-validation/
- Click Add.
The duration of website crawling is determined by its size, with Enterprise h2oGPTe processing ten pages per second. You can modify this rate at startup rather than within the user interface. Therefore, continue to step 2 until the website crawling Job reaches 100% completion.
Step 2: Create a Collection-specific API Key​
To access the Collection containing the content of the crawled website externally, you can create a Collection-specific API Key that enables you to Chat with the Collection. For this tutorial, a Collection-specific API key with Python will enable the creation of a chatbot to enhance the search capabilities of the H2O Model Validation documentation website. Let's create a Collection-specific API key.
Collection-specific API keys do not allow other API calls, such as creation, deletion, or access to other Collections or Chats. On the other hand, you can create Global API Keys to externally be able to create, delete, or interact with any of your past, current, and future Collections, Documents, Chats, and settings. To learn more, see Types of API Keys.
- On the Enterprise h2oGPTe navigation menu, click APIs.
- Click + New API Key.
- In the Key name (Optional) box, enter:
tutorial-2a
- In the Collection (Optional) list, select tutorial-2a.
- Click Generate new key.
- Click Copy.
caution
Do not share your API Key with others or expose it within the browser or other client-side code.
- Click Confirm.
Step 3: Chat with website​
Let's Chat with the H2O Model Validation documentation website using Python and the created Collection-specific API Key.
-
Create a Python environment with the Enterprise h2oGPTe client.
cautionIt's advisable to install the client version that matches the Enterprise h2oGPTe version currently in use.
python -m venv enterprise
source enterprise/bin/activate
pip install h2ogpte==1.3.11 -
Revise line 5 to indicate the URL where Enterprise h2oGPTe is operational.
-
Modify line 6 of the provided Python file with the copied/created Collection-specific API Key to establish communication with the documentation website. In particular, the file has been structured to ask the website (Collection) the following: What is H2O Model Validation? (line 15).
tutorial-2a.pyimport os
from h2ogpte import H2OGPTE
client = H2OGPTE(
address='https://playground.h2ogpte.h2o.ai',
api_key='sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
)
# Automatically connects to the Collection connected to the Collection-specific API key
chat_session_id = client.create_chat_session_on_default_collection()
# Query the Collection
with client.connect(chat_session_id) as session:
reply = session.query(
'What is H2O Model Validation?',
timeout=60,
)
print(reply.content)noteThe provided Python file was constructed using the code provided on the APIs page.
-
Run the tutorial-2a.py file.
cautionEnterprise h2oGPTe saves and displays the asked question(s) in the Enterprise h2oGPTe UI.
python3 tutorial-2a.py
Response (answer): H2O Model Validation is an application that lets you assess the robustness and stability of trained H2O Driverless AI (DAI) models. It provides various validation tests to analyze the robustness and stability of a model or dataset, helping to avoid model degradation by revealing weaknesses and vulnerabilities in the datasets. It also centralizes and visualizes how DAI models and their datasets are validated for production.
Summary​
In this tutorial, we learned how to build an AI-powered chatbot using Enterprise h2oGPTe and Python to enhance website search capabilities. The objectives of this tutorial included crawling a website, creating a Collection-specific API key, and chatting with the website using Python. By completing this tutorial, we gained the ability to develop an AI-powered chatbot to replace the function of a website's search bar, enabling users to obtain better answers to their questions about the website.
- Submit and view feedback for this page
- Send feedback about Enterprise h2oGPTe to cloud-feedback@h2o.ai