Zubaish commited on
Commit ·
3f76bb4
1
Parent(s): 2d4b429
Fix langchain_chroma error; pin stable deps
Browse filesFiles changed (4)
- Dockerfile-6
- ingest.py+2-1
- rag.py+4-4
- requirements.txt+6-6
1 unmodified line234567891011121314151617181920212223241 unmodified lineWORKDIR /app# System dependenciesRUN apt-get update && apt-get install -y \git \&& rm -rf /var/lib/apt/lists/*# Python dependenciesCOPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# Application codeCOPY app.py rag.py ingest.py guardrails.py config.py ./# Create empty kb_docs directory (PDFs added later via HF UI)RUN mkdir -p kb_docs# Hugging Face Spaces portEXPOSE 7860# Start FastAPICMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]1 unmodified line234567891011121314151617181 unmodified lineWORKDIR /appRUN apt-get update && apt-get install -y \git \&& rm -rf /var/lib/apt/lists/*COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txtCOPY app.py rag.py ingest.py guardrails.py config.py ./RUN mkdir -p kb_docsEXPOSE 7860CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
10 unmodified lines11121314151617181 unmodified line2021222310 unmodified linesglob="**/*.pdf",loader_cls=PyPDFLoader)docs = loader.load()if not docs:return []1 unmodified linechunk_size=800,chunk_overlap=100)return splitter.split_documents(docs)10 unmodified lines11121314151617181 unmodified line202122232410 unmodified linesglob="**/*.pdf",loader_cls=PyPDFLoader)docs = loader.load()if not docs:return []1 unmodified linechunk_size=800,chunk_overlap=100)return splitter.split_documents(docs)
123458 unmodified lines1415161718192011 unmodified lines3233343536373839404142434445from langchain_huggingface import HuggingFaceEmbeddings, ChatHuggingFacefrom langchain_chroma import Chromafrom langchain.schema import SystemMessage, HumanMessagefrom ingest import load_and_split_docs8 unmodified linesif documents:vectorstore = Chroma.from_documents(documents,embedding=embeddings)retriever = vectorstore.as_retriever(search_kwargs={"k": 3})11 unmodified linesif not retriever:return {"status": ["⚠️ No documents uploaded yet"],"answer": "Please upload PDF files to the kb_docs folder."}docs = retriever.get_relevant_documents(question)context = "\n\n".join(d.page_content for d in docs)messages = [SystemMessage(content="Answer using the provided context."),HumanMessage(content=f"Context:\n{context}\n\nQuestion: {question}")]123458 unmodified lines1415161718192011 unmodified lines3233343536373839404142434445from langchain_community.vectorstores import Chromafrom langchain_huggingface import HuggingFaceEmbeddings, ChatHuggingFacefrom langchain.schema import SystemMessage, HumanMessagefrom ingest import load_and_split_docs8 unmodified linesif documents:vectorstore = Chroma.from_documents(documents=documents,embedding=embeddings)retriever = vectorstore.as_retriever(search_kwargs={"k": 3})11 unmodified linesif not retriever:return {"status": ["⚠️ No documents uploaded yet"],"answer": "Please upload PDF files to the kb_docs folder and restart the Space."}docs = retriever.get_relevant_documents(question)context = "\n\n".join(d.page_content for d in docs)messages = [SystemMessage(content="Answer using only the provided context."),HumanMessage(content=f"Context:\n{context}\n\nQuestion: {question}")]
2 unmodified lines345678910111213142 unmodified linespydanticpython-dotenvlangchainlangchain-communitylangchain-corelangchain-huggingfacechromadbsentence-transformerspypdfhuggingface_hub2 unmodified lines345678910111213142 unmodified linespydanticpython-dotenvlangchain==0.2.17langchain-community==0.2.17langchain-huggingface==0.1.0chromadb==0.5.5sentence-transformerspypdfhuggingface_hub>=0.33.4,<1.0.0
Dockerfile-6
ingest.py+2-1
rag.py+4-4
requirements.txt+6-6