codebasics / langchain

Tutorial for langchain LLM library
130 stars 228 forks source link

IndexError: list index out of range #16

Open ahujaravinder022 opened 4 months ago

ahujaravinder022 commented 4 months ago

File "C:\Users\Ravinder.Ahuja\Desktop\Generative AI Course wirh contents\Projects\langchain-main (1)\langchain-main\2_news_research_tool_project\mm2\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 565, in _run_script exec(code, module.dict) File "C:\Users\Ravinder.Ahuja\Desktop\Generative AI Course wirh contents\Projects\langchain-main (1)\langchain-main\2_news_research_tool_project\main.py", line 43, in vectorstore_openai = FAISS.from_documents(docs, embeddings) File "C:\Users\Ravinder.Ahuja\Desktop\Generative AI Course wirh contents\Projects\langchain-main (1)\langchain-main\2_news_research_tool_project\mm2\lib\site-packages\langchain\vectorstores\base.py", line 417, in from_documents return cls.from_texts(texts, embedding, metadatas=metadatas, **kwargs) File "C:\Users\Ravinder.Ahuja\Desktop\Generative AI Course wirh contents\Projects\langchain-main (1)\langchain-main\2_news_research_tool_project\mm2\lib\site-packages\langchain\vectorstores\faiss.py", line 603, in from_texts return cls.from( File "C:\Users\Ravinder.Ahuja\Desktop\Generative AI Course wirh contents\Projects\langchain-main (1)\langchain-main\2_news_research_tool_project\mm2\lib\site-packages\langchain\vectorstores\faiss.py", line 562, in from index = faiss.IndexFlatL2(len(embeddings[0]))

can someone help in resolving this issue.

AKILSADIK commented 2 months ago

Facing the same issue. can anyone tell me how to resolve this issue.

Now i had figured it my API key is expired

ritik7545 commented 2 months ago

solve hua kya please koi mujhe ye project bana ke de skta h kya i paying them 1.5 k

yashraj-dudhe commented 1 month ago

solve hua kya ritik

lostbeauty69 commented 3 weeks ago

Hi @ahujaravinder022 The issue you're facing is most likely related to faiss or the embeddings you are passing. Ensure that the library is installed correctly using either: pip install faiss-cpu
pip install faiss-gpu

There might also be an issue with the embeddings array. You can check this by printing the shape of the embeddings with: print("Embedding shape:", len(embeddings), len(embeddings[0]) if embeddings else "Empty embeddings") It will help you identify if the embeddings array is empty or has inconsistent dimensions."