I loaded a company organization chart to a csv and loaded into FAISS. Each time I ask the bot to list out all the duties of an individual, it only searches up to 4 results and create the response based on that.
How do I force it to pull more data from FAISS?
Here's my code:
# Import os to set API key
import os
from apikey import apikey
os.environ['OPENAI_API_KEY'] = apikey
import streamlit as st
from streamlit_chat import message
from langchain.embeddings.openai import OpenAIEmbeddings
from langchain.chat_models import ChatOpenAI
from langchain.chains import ConversationalRetrievalChain
from langchain.document_loaders.csv_loader import CSVLoader
from langchain.vectorstores import FAISS
import tempfile
uploaded_file = st.sidebar.file_uploader("upload", type="csv")
if uploaded_file :
#use tempfile because CSVLoader only accepts a file_path
with tempfile.NamedTemporaryFile(delete=False) as tmp_file:
tmp_file.write(uploaded_file.getvalue())
tmp_file_path = tmp_file.name
loader = CSVLoader(file_path=tmp_file_path, encoding="utf-8", csv_args={
'delimiter': ','})
data = loader.load()
embeddings = OpenAIEmbeddings()
#we use FAISS as a vector db
vectorstore = FAISS.from_documents(data, embeddings)
chain = ConversationalRetrievalChain.from_llm(
llm = ChatOpenAI(temperature=0.0,
model='gpt-3.5-turbo-16k',
max_tokens=10000),
retriever=vectorstore.as_retriever(),verbose=True)
def conversational_chat(query):
result = chain({"question": query,
"chat_history": st.session_state['history']})
st.session_state['history'].append((query, result["answer"]))
return result["answer"]
if 'history' not in st.session_state:
st.session_state['history'] = []
if 'generated' not in st.session_state:
st.session_state['generated'] = ["Hello ! Ask me anything about " + uploaded_file.name + " "]
if 'past' not in st.session_state:
st.session_state['past'] = ["Hey ! "]
#container for the chat history
response_container = st.container()
#container for the user's text input
container = st.container()
with container:
with st.form(key='my_form', clear_on_submit=True):
user_input = st.text_input("Query:", placeholder="Talk about your csv data here (:", key='input')
submit_button = st.form_submit_button(label='Send')
if submit_button and user_input:
output = conversational_chat(user_input)
st.session_state['past'].append(user_input)
st.session_state['generated'].append(output)
if st.session_state['generated']:
with response_container:
for i in range(len(st.session_state['generated'])):
message(st.session_state["past"][i], is_user=True, key=str(i) + '_user', avatar_style="big-smile")
message(st.session_state["generated"][i], key=str(i), avatar_style="thumbs")
Here's part of my csv
AREA OF RESPONSIBILITY,Directly Responsible Individual,Backup,Oversight
,,,
"Run quarterly company meetings: schedule, set agenda for, and chair",Agatha,Agnes,Agatha
"Run bi-weekly company meetings: schedule, set agenda for, and chair",Agatha,Agnes,Agatha
"Run exec meetings: schedule, set agenda for, and chair",David,Urjita,Agatha
Manage hiring and HR,Agatha,Agnes,Agatha
Finalize company's 3-month goals,Agatha,David,Agatha
Maintain competitive landscape analysis,David,Agnes,Agnes
Maintain project roadmap ,David,Urjita,Agatha
Maintain project idea backlog,David,Urjita,Agatha
Maintain AORs (this sheet),David,Agatha,Agatha
Manage Polish business,Agnes,Agatha,Agnes
,,,
,,,
OPERATIONS MANAGEMENT,,,
"Run team operations meetings: schedule, set agenda for, and chair",Urjita,David?,David
Manage and coordinate the sharing of resources (people),Urjita,Agatha,David
Maintain task management systems (Kanban),Urjita,Agatha,David
Mantain operations calendar,Urjita,Agatha,Agatha
Field and sort incoming feature requests and bugs from team,Urjita,David,David
Manage individual projects,Varies,Varies,Varies
Maintain company wiki,David,Urjita,Agatha
"Manage Payroll, AR, and AP",Anne Marie,Agatha,Agatha
Manage company events,Anne Marie,Michael,Michael
Manage company holidays and vacation requests,Anne Marie,Agatha,Agatha
Manage the tracking of company email accounts,James,Agnes,Agnes
,,,
,,,
SALES AND MARKETING,,,
"Run sales meetings: schedule, set agenda for, and chair",Agatha,James,Agatha
"Set sales, marketing goals, and projects (adding projects to Project Roadmap)",Agatha,Agnes,Agatha
"Finalize numerical sales targets (for revenue, upgrades, etc.)",Agatha,Agnes,Agatha
Maintain sales and marketing portion of company calendar,James,Agatha,Agatha
"Develop and maintain sales collateral, messaging, and presentation structures",Agatha,Agnes,Agatha
"Schedule, manage, and execute B2B marketing/communications campaigns—print, online, email, social",James,Agatha,Agatha
"Manage CRM (Zoho): maintenance, functions, systems, usage by sales people",James,Agnes,Agnes
Track marketing and sales KPIs—and communicate internally,Agatha,James,Agatha
Pull Performance Reports and create GA reports for clients,James,Agnes,Agnes
Manage Insider Reports,James,Agatha,Agatha
Develop and maintain online sales conversion funnels,James,Agnes,Agnes
Maintain corporate website,Agatha,Agnes,Agatha
Distribute inbound sales inquiries,Marina,James,James
Conduct analysis after each sales cycle,Agatha,Agnes,Agatha
Manage Marketing Academy—both sales and product,James,Agatha,Agatha
Manage printing of sales collateral,Michael,James,Agatha
A sample result currently looks something like this:
>> Entering new chain...
Prompt after formatting:
Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question, in its original language.
Chat History:
Human: what does james do
Assistant: James is responsible for managing insider reports, managing social media, managing the tracking of company email accounts, and managing expo B2B communications.
Follow Up Input: list all things james does. be as comprehensive as possible
Standalone question:
> Finished chain.
> Entering new chain...
> Entering new chain...
Prompt after formatting:
System: Use the following pieces of context to answer the users question.
If you don't know the answer, just say that you don't know, don't try to make up an answer.
----------------
AREA OF RESPONSIBILITY: Manage client liability task tracking through Zoho Tasks: maintenance, functions, systems
Directly Responsible Individual: James
Backup: Urjita
Oversight: Agnes
AREA OF RESPONSIBILITY: Manage client communications (to-dos, reminders) regarding liabilities
Directly Responsible Individual: James
Backup: Agnes
Oversight: Agnes
AREA OF RESPONSIBILITY: Schedule, manage, and execute B2B marketing/communications campaigns—print, online, email, social
Directly Responsible Individual: James
Backup: Agatha
Oversight: Agatha
AREA OF RESPONSIBILITY: Manage the tracking of company email accounts
Directly Responsible Individual: James
Backup: Agnes
Oversight: Agnes
Human: Can you provide a comprehensive list of all the tasks that James is responsible for?