langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
94.61k stars 15.31k forks source link

Cant import create_retrieval_chain on new version of langchain==0.3.0 #26692

Open Pochomo opened 1 month ago

Pochomo commented 1 month ago

Checked other resources

Example Code

from app.services.document_loader import PDFLoader
from app.services.vector_store import VectorStore
from langchain_community.chat_models import ChatOpenAI
from langchain.chains import create_retrieval_chain 
from langchain.memory import ConversationBufferMemory
from pydantic import BaseModel
from typing import List

router = APIRouter()

pdf_loader = PDFLoader()
vector_store = VectorStore()

class ChatRequest(BaseModel):
    message: str

@router.post("/upload-pdf")
async def upload_pdf(files: List[UploadFile] = File(...)):

@router.post("/chat")
async def chat(request: ChatRequest):

@router.get("/check-vector-store")
async def check_vector_store(is_law_related: bool = False):

Error Message and Stack Trace (if applicable)

"create_retrieval_chain" is unknown import symbol

Description

I have an error here "from langchain.chains import create_retrieval_chain" , the contents of the error are as follows ""create_retrieval_chain" is unknown import symbol". my version of langchains are

[langchain 0.3.0 langchain-anthropic 0.2.1 langchain-chroma 0.1.4 langchain-community 0.3.0 langchain-core 0.3.2 langchain-openai 0.2.0 langchain-text-splitters 0.3.0]

can window cause an error?? I really need to fix this, please help.

System Info

python 3.12.6 langchain 0.3.0 langchain-anthropic 0.2.1 langchain-chroma 0.1.4 langchain-community 0.3.0 langchain-core 0.3.2 langchain-openai 0.2.0 langchain-text-splitters 0.3.0

Pochomo commented 1 month ago

when i used "from langchain.chains import ConversationalRetrievalChain" it was working, but not now lanchain let me change to create_retrieval_chain

binhnd102 commented 1 month ago

@Pochomo Could you use this instead? from langchain.chains.retrieval import create_retrieval_chain

Pochomo commented 1 month ago

@Pochomo Could you use this instead? from langchain.chains.retrieval import create_retrieval_chain

I I solved it using venv thx:)