Open data-scientist-shivam799 opened 1 month ago
Hi @data-scientist-shivam799! I'm here to help you with the issue you're facing. Let's get this sorted out together!
To resolve the ImportError: "cannot import name 'BaseCache' from 'langchain.cache'"
encountered while running the provided Colab notebook for the Graph_RAG_LlamaIndex_Workshop, you should ensure that you are not trying to import BaseCache
from langchain.cache
as it is not listed in the provided module. Instead, you should check the imports and remove or correct the import statement related to BaseCache
.
Based on the provided content, BaseCache
is not part of the langchain
module. Here is a corrected version of the import statements:
import langchain
from langchain.agents import AgentExecutor, AgentType, initialize_agent
# agents and tools
from langchain.agents.agent_toolkits.base import BaseToolkit
from langchain.base_language import BaseLanguageModel
# callback
from langchain.callbacks.base import BaseCallbackHandler, BaseCallbackManager
from langchain.chains.prompt_selector import ConditionalPromptSelector, is_chat_model
from langchain.chat_models.base import BaseChatModel
from langchain.docstore.document import Document
from langchain.memory import ChatMessageHistory, ConversationBufferMemory
# chat and memory
from langchain.memory.chat_memory import BaseChatMemory
from langchain.output_parsers import ResponseSchema
# prompts
from langchain.prompts import PromptTemplate
from langchain.prompts.chat import (
AIMessagePromptTemplate,
BaseMessagePromptTemplate,
ChatPromptTemplate,
HumanMessagePromptTemplate,
SystemMessagePromptTemplate,
)
# schema
from langchain.schema import (
AIMessage,
BaseMemory,
BaseMessage,
BaseOutputParser,
ChatGeneration,
ChatMessage,
FunctionMessage,
HumanMessage,
LLMResult,
SystemMessage,
)
# embeddings
from langchain.schema.embeddings import Embeddings
from langchain.schema.prompt_template import BasePromptTemplate
# input & output
from langchain.text_splitter import RecursiveCharacterTextSplitter, TextSplitter
from langchain.tools import BaseTool, StructuredTool, Tool
from langchain_community.chat_models import ChatAnyscale, ChatOpenAI
from langchain_community.embeddings import (
HuggingFaceBgeEmbeddings,
HuggingFaceEmbeddings,
)
# LLMs
from langchain_community.llms import AI21, BaseLLM, Cohere, FakeListLLM, OpenAI
Make sure to remove any import statement for BaseCache
as it is not part of the langchain
module according to the provided content [1].
To continue the conversation, mention @dosu.
v0.8.9 is quite old 😅 you probably need to lower your langchain version quite a bit (v0.0.303 maybe?)
Future versions of llamaindex would have removed the dependency on langchain too
@logan-markewich I tried to downgrade langchain and also tried upgrading llama_index, but the issue continues.
Bug Description
I was going through Graph_RAG_LlamaIndex_Workshop by llama index on YouTube (link is here) and following along the notebook (notebook is here) provided in the description of the video.
While running the following code, I am getting ImportError: cannot import name 'BaseCache' from 'langchain.cache' (/usr/local/lib/python3.10/dist-packages/langchain/cache.py)
from llama_index import ( VectorStoreIndex, SimpleDirectoryReader, KnowledgeGraphIndex, ServiceContext, )
I think this is because of any internal library mismatch, does anyone else faced the same issue?
Version
0.8.9
Steps to Reproduce
Just run the colab notebook.
Relevant Logs/Tracbacks