in

How to create a chatbot that queries AlloyDB


Generative AI is a cutting-edge technology that harnesses the power of AI to produce original and creative content. Since SQL queries are one of the content types it can generate, it has the potential to revolutionize the way we interact with databases. By generating SQL queries from natural language, gen AI can make it easier for users to access and analyze data without having to write complex queries themselves. This is a great blog written by Andi Gutmans, GM and VP, Databases, Google Cloud on how AI changes the developer role. Let’s have a look at how a multilingual chatbot can help with querying and analyzing data stored in a database. In this blog post, we will show you how to create a multilingual chatbot that stores sample customer shopping data. We’ll use popular open source and Google Cloud technologies including Langchain, AlloyDB, Streamlit, Vertex AI, and Google Translate.

What is Langchain, and why should I use it?

LangChain is a powerful and versatile open-source library that makes it easier for developers to build applications with Large Language Models (LLMs). It provides a comprehensive set of tools and resources for connecting LLMs to multiple data sources, such as databases or documents. This allows you to string together a sequence of commands to create sophisticated applications that can access and process a wider range of information.

LangChain is a valuable tool for developers who want to build complex applications with LLMs. It offers a number of advantages, including:

  • Flexibility: LangChain provides a highly flexible and extensible framework for developers to customize their applications to meet specific needs.
  • Speed: The LangChain development team is continually working to improve the library’s speed, ensuring that users have access to the latest LLM functionalities.
  • Strong Community: LangChain has an active community of users who are always willing to help each other.
  • Agent-based reasoning: LangChain can be used to create agent-based systems that can make decisions and take actions based on the information provided by LLMs. This makes it possible to build applications that can interact with the real world in a more sophisticated way.

What is AlloyDB?

AlloyDB for PostgreSQL is a fully-managed, PostgreSQL-compatible database for demanding, enterprise-grade transactional and analytical workloads. Imagine PostgreSQL plus the best of the cloud: elastic storage and compute, intelligent caching, and AI/ML-powered management. Further, AlloyDB delivers unmatched performance: In our performance tests, it’s more than 4x faster on transactional workloads, and up to 100x faster analytical queries than standard PostgreSQL, all with simple, predictable pricing. Designed for mission-critical applications, AlloyDB offers extensive data protection and an industry leading 99.99% availability.

Here we’ll use AlloyDB as a simple database to store chat history, but in future blog posts we’ll explain how to leverage its built-in vector database and AI capabilities to build more data-aware, AI-enabled applications.

What is Streamlit?

Streamlit is an open-source Python framework that makes it easy to create and share beautiful, custom web apps for machine learning and data science. With Streamlit, you can build and deploy powerful data apps in just a few minutes, without having to rely on a team of front-end developers or learn web design languages.

Streamlit was founded in 2018 by ex-Google engineers who had first-hand experience of the challenges faced when developing and deploying machine learning models and dashboards. They wanted to create a framework that would make it easy for anyone to build and share data apps, regardless of their technical skills.

Some of the benefits of using Streamlit:

  • Rapid development: Streamlit allows you to quickly prototype and iterate on your data apps. This is because you can use Python to write the entire app, including the front-end code.
  • Low barrier to entry: Streamlit is very easy to learn and use, even if you don’t have any front-end development experience. This makes it a great option for data scientists and machine learning engineers who want to build their own data apps without having to rely on a team of developers.
  • Flexible deployment: Streamlit apps can be deployed to a variety of platforms and thus, you have the flexibility to deploy your apps to the platform that best meets your needs.

What is Vertex AI (LLM)?

Generative AI on Vertex AI (also known as genai) gives you access to Google’s large generative AI models so you can test, tune, and deploy them for use in your AI-powered applications. There are a number of different LLMs available, and you can choose the one that best suits your needs. In this example we use a PaLM 2 Model (https://ai.google/discover/palm2/)

What is Google Translate?

Google Translate is a free online translation service that can translate text, speech, and websites between over 100 languages. You may have heard of the google translate website but the model that powers the website is also available to developers via Cloud Translation API. What sets Google Translate apart is its commitment to privacy. The customer data and translations remain confidential and are not utilized to refine the model.

Thus, Google Translate elevates team efficiency, eliminating the need for manual translations or external assistance. In this demo, we streamline the responses by seamlessly incorporating translated text and thus, enable the chatbot to support customer cases in diverse languages.

Solution

A multilingual chatbot that queries a database can be used in a wide variety of industries. For example, a travel company could use it to offer flights, hotels, and rental cars booking, as well as help with other travel requirements such as visa arrangements. A financial company could use it to help customers check account balances, transfer money, and pay bills. Multilingual chatbots also offer other benefits, such as reaching a global audience, increasing efficiency, and allowing employees to query the data in their native language.

In this example we will create a chatbot that allows you to query a database storing sample customer shopping data.


Sam Altman Says Human-Tier AI Is Coming Soon

Sam Altman Says Human-Tier AI Is Coming Soon

Camanchaca innovates its employee experience with real-time generative agents

How Vertex AI helps Wayfair achieve real-time model serving