langchain
langchain copied to clipboard
TypeError: 'FAISS' object is not callable
HI, I am getting this error. Sounds like normal pronlem, anyone can halp?
TypeError: 'FAISS' object is not callable
Traceback:
File "D:\mk\python\Lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script
exec(code, module.dict)
File "D:\mk\python\ready cody\ZkouÅ¡enÃ\CHAT_WITH_DATA\main.py", line 65, in
Can you post the main.py
code to reproduce the error?
sure, here it is `"""Python file to serve as the frontend""" import streamlit as st from streamlit_chat import message
from langchain.chains import ConversationChain from langchain.llms import OpenAI from ingest_data import embed_doc from query_data import _template, CONDENSE_QUESTION_PROMPT, QA_PROMPT, get_chain import pickle import os from ingest_data import embed_doc from query_data import get_chain
def load_chain():
"""Logic for loading the chain you want to use should go here."""
llm = OpenAI(temperature=0)
chain = ConversationChain(llm=llm)
return chain
From here down is all the StreamLit UI.
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:") st.header("LangChain Demo")
uploaded_file = st.file_uploader("Upload a document you would like to chat about", type=None, accept_multiple_files=False, key=None, help=None, on_change=None, args=None, kwargs=None, disabled=False, label_visibility="visible")
check if file is uploaded and file does not exist in data folder
if uploaded_file is not None and uploaded_file.name not in os.listdir("data"): # write the file to data directory with open("data/" + uploaded_file.name, "wb") as f: f.write(uploaded_file.getbuffer()) st.write("File uploaded successfully") with st.spinner('Document is being vectorized...'): embed_doc()
open vectorstore.pkl if it exists in current directory
if "vectorstore.pkl" in os.listdir("."): with open("vectorstore.pkl", "rb") as f: vectorstore = pickle.load(f) print("Loading vectorstore...")
chain = get_chain(vectorstore)
if "generated" not in st.session_state: st.session_state["generated"] = []
if "past" not in st.session_state: st.session_state["past"] = []
placeholder = st.empty() def get_text():
input_text = placeholder.text_input("You: ", value="", key="input")
return input_text
user_input = get_text() print(st.session_state.input)
print(user_input)
if user_input: docs = vectorstore(user_input) # if checkbox is checked, print docs
print(len(docs))
output = chain.run(input=user_input, vectorstore = vectorstore, context=docs[:2], chat_history = [], question= user_input, QA_PROMPT=QA_PROMPT, CONDENSE_QUESTION_PROMPT=CONDENSE_QUESTION_PROMPT, template=_template)
st.session_state.past.append(user_input)
print(st.session_state.past)
st.session_state.generated.append(output)
# placeholder.text_input("You: ", value="", key="input2")
print(st.session_state.past)
if st.checkbox("Show similar documents"):
st.markdown(docs)
if st.session_state["generated"]:
for i in range(len(st.session_state["generated"]) - 1, -1, -1):
message(st.session_state["generated"][i], key=str(i))
message(st.session_state["past"][i], is_user=True, key=str(i) + "_user")
`
Hi, @parkos123! I'm Dosu, and I'm here to help the LangChain team manage their backlog. I wanted to let you know that we are marking this issue as stale.
From what I understand, you encountered a TypeError
in the main.py
file at line 65, where the 'FAISS' object is not callable. It seems that you were asked to provide the code from main.py
to reproduce the error, but there hasn't been any response or update on the issue since then.
Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the LangChain repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.
Thank you for your understanding and cooperation!