Currently I have a Database with Questions on column A and answers on column B.
I Want to create a chatbot that takes the user’s question, searches the most similar question on Column A and outputs its correspondent answer.
I tried doing this with Vector, keyword and tree indexes. but when I ask for example question 1, it outputs answer 2.
or sometimes it combines answer 1 and 3 for example.
I tried to create a pandas index and it works very well only if the user’s question is exactly the same as a question from column A.
if i change a word only a little, an error appears and says that I am trying to look outside the range of the table.
So my question is:
Is a pandas index the right index for this kind of cases?
if not? what is the most suited index format in this case? and how can I ensure to reply always right?
my code for the pandas index is:
import logging import sys import os logging.basicConfig(stream=sys.stdout, level=logging.INFO) logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout)) from llama_index import SimpleDirectoryReader from IPython.display import Markdown, display from llama_index.indices.struct_store import GPTPandasIndex import pandas as pd os.environ["OPENAI_API_KEY"] = '' col_names = ['Question','Answer'] df = pd.read_csv("Q&A.csv", names = col_names) df.reset_index(inplace = True) index = GPTPandasIndex(df=df) query_engine = index.as_query_engine( verbose=True ) response = query_engine.query( "/question from my database", ) print (response)```