A bot that answers questions about data

 import logging
import os

from flask import Flask, render_template, session, request, jsonify
from flask_session import Session
from gunicorn.app.base import BaseApplication
import carparts_db
from carparts_db import create_connection, create_table

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

app = Flask(__name__)
# Configuring server-side session
app.config["SESSION_PERMANENT"] = False
app.config["SESSION_TYPE"] = "filesystem"
Session(app)

from abilities import llm_prompt

@app.route("/")
def root_route():
    return render_template("template.html", model_name="gpt-4-1106-preview")

About this template

Ask questions about your database via a chat bot. This chatbot connects to a SQLITE database, generates queries for it based on the schema and then runs the queries printing the response all in a nicely styled chat UI. This template is pre-loaded with sample data (car parts) to play around with - here are the sample data columns that you can query: part_number, part_name, price, units_left_in_stock, manufacturer .

Introduction to the Chatbot Service Template

Welcome to the Chatbot Service Template on Lazy! This template allows you to create a chatbot that can answer questions about data stored in a SQLite database. The chatbot is designed to generate SQL queries based on user input and return the results in a user-friendly chat interface. This template is perfect for builders who want to create a customer support bot or an interactive data query tool without worrying about the complexities of database management and frontend development.

Getting Started

To begin using this template, simply click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy or paste any code manually.

Initial Setup

There are no environment variables required for this template, so you can skip straight to testing the application.

Test: Deploying the App

Once you have the template loaded, press the "Test" button to begin the deployment of your chatbot application. The Lazy CLI will handle the deployment process, and you won't need to install any libraries or set up your environment manually.

Entering Input

After pressing the "Test" button, if the application requires any user input, the Lazy App's CLI interface will prompt you to provide it. Follow the instructions in the CLI to enter the necessary information.

Using the Chatbot Interface

After deployment, you will be provided with a dedicated server link to interact with your chatbot. The chatbot interface is a simple and intuitive web page where users can type their questions and receive responses. The chat history is displayed on the page, allowing for a seamless conversation experience.

Integrating the Chatbot into External Services

If you wish to integrate the chatbot with external services or tools, you may need to use the server link provided by Lazy. For example, if you want to embed the chatbot into an existing website, you can use an iframe or a web component to include the chatbot interface on your site. Ensure that you adjust the CORS settings on your server if necessary to allow for such integrations.

Here's a sample code snippet to embed the chatbot into an external webpage:


<iframe src="YOUR_SERVER_LINK" width="350" height="500"></iframe>

Replace "YOUR_SERVER_LINK" with the actual link provided by Lazy after deployment.

And that's it! You now have a fully functional chatbot that can answer questions about your car parts database. Enjoy interacting with your chatbot and exploring the capabilities of the Lazy platform.

Category
Technology
Last published
May 18, 2024

More templates like this

To-Do App

A great starting point for a feature-rich To-do List app. This skeleton supports adding, editing, deleting, and prioritizing tasks with due dates and reminders. It's built with Flask and SQLAlchemy, ensuring easy database management. The responsive UI is powered by Tailwind CSS, making it user-friendly and visually appealing. Perfect for creating a robust task management system with potential for further enhancements like project management and collaboration tools.

Flask

FALLBACK | Flask, HTML, JS and Tailwind Based Website

This is a good starting point for styled website. It has a header, footer. Has Tailwind and Flowbite loaded so you can build nice looking pages from here.

Flask
HTML

CSV Deduper

A webpage that dedupes a CSV based on the values in the first column and allows for downloading.

Python
Flask
Home
/
A bot that answers questions about data