1 of 14

SFBU Customer Support System

TEXT

2 of 14

Content Table

Environment Setup

Data Processing and Embeddings

Conversational Retrieval Chain Setup

Business Logic

Web-based User Interfaces

Appendix

3 of 14

Environment Setup

Importing libraries and dependencies, including langchain, dotenv, and more.

Initializing API keys for OpenAI and Google, allowing secure access to external services.

Defining example sentences, such as queries for educational program information.

Introduction to the OpenAI API, which powers conversational AI in the code.

4 of 14

Environment Setup - packages

from langchain.embeddings.openai import OpenAIEmbeddings

import openai

import os

import sys

import requests

sys.path.append('../..')

from dotenv import load_dotenv, find_dotenv

_ = load_dotenv(find_dotenv()) # read local .env file

openai.api_key = os.environ['API_KEY']

goog_api_key = os.environ['GOOG_API_KEY']

5 of 14

Data Processing and Embeddings

  • Creating embeddings for example sentences.
  • Calculating dot products to measure similarity.

sentence1 = "What are the application requirements for the MSCS program at SFBU?"

sentence2 = "Can you outline the core curriculum for the SFBU MSCS program?"

6 of 14

Data Processing and Embeddings

SETTING UP A VECTOR STORE (CHROMA) FOR ENHANCED RETRIEVAL

7 of 14

ConversationalRetrievalChain

What is a Conversational Retrieval Chain?

A Conversational Retrieval Chain is a crucial component in our project.

It enables our system to provide dynamic and context-aware responses in conversations.

Key Features:

Memory Integration: The chain incorporates a memory component for storing and retrieving conversation history.

Chat Model: It employs a powerful chat model, GPT-3.5 Turbo from OpenAI, for generating responses.

Retriever: Utilizes a vector store (Chroma) for enhanced context retrieval.

8 of 14

ConversationalRetrievalChain - Customization

Our conversational AI is powered by GPT-3.5 Turbo, an advanced language model from OpenAI.

It's a versatile and highly capable model known for its natural language understanding.

Our AI taps into the extensive knowledge of our pretrained ChromaDB vector store.

Sourced from official school documents and videos, this database enriches our responses with context-aware insights.

This ensures the accuracy and reliability of the information we provide.

9 of 14

ConversationalRetrievalChain - Testing

10 of 14

Business Logic

Initialization and Loading Data

Constructor sets up parameters and loads conversational data.

Resetting the Database

call_load_db() clears history and reloads the conversational chain.

User Interaction and Responses

convchain(query) handles queries and updates conversation history.

Clearing Conversation History

clr_history() resets the chat history, maintaining a clean slate.

11 of 14

User interface

Flask Web Application

Utilizes Flask to create a web-based interface for user interaction.

Chatbot Integration

Interacts with the chatbot logic implemented in the 'cbfs' module.

Submitting Questions

Users can submit questions via a web form.

Viewing Replies

Replies are displayed on the web interface for user feedback.

Starting New Chats

Option to clear conversation history and begin a fresh chat.

12 of 14

User interface - Effect

13 of 14

User interface – Start new chat(forget context)

14 of 14

Appendix

  • Github link:

https://github.com/pupilRui/BayUniversityServiceBot