2.2 KiB
2.2 KiB
SOLUTION.md
What was implemented
- Switched from OpenAI embeddings/LLM to Ollama’s
nomic-embed-textfor vector generation. - Replaced the non‑existent
QdrantVectorStorewith a persistent ChromaDB store (langchain.vectorstores.Chroma). - Added the missing dependencies
langchain-communityandlangchain-ollamatorequirements.txt. - Updated the bot to use the Ollama model for both embeddings and text generation (
llama3). - Kept the interactive FAQ loop and retrieval‑QA chain intact.
Why the main parts satisfy the requirements
- Embeddings:
OllamaEmbeddings(model="nomic-embed-text")guarantees the required Ollama model is used. - Vector store:
Chromais imported fromlangchain.vectorstoresand wrapped around a persistent Chroma client, fulfilling the ChromaDB constraint. - Dependencies:
requirements.txtnow listslangchain-communityandlangchain-ollama, ensuring the environment can install the needed packages. - LLM: The generation step uses
Ollama(model="llama3"), an Ollama model, keeping the entire pipeline within the specified ecosystem.
Key code excerpts
src/main.py – embeddings and vector store
# 1. Set up embeddings using Ollama's "nomic-embed-text" model
embeddings = OllamaEmbeddings(model="nomic-embed-text")
def create_vectorstore(embeddings, persist_directory: str = "chroma_db") -> Chroma:
...
vectorstore = Chroma(
client=client,
collection_name="faq",
embedding_function=embeddings
)
return vectorstore
src/main.py – retrieval‑QA chain
qa_chain = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=vectorstore.as_retriever()
)
requirements.txt (excerpt)
langchain-community
langchain-ollama
Limitations
- The bot currently uses a hard‑coded FAQ list; adding dynamic data sources would require further changes.
- Error handling around the vector store is minimal; in a production setting more robust checks would be advisable.
This implementation meets all assignment constraints while keeping the original interactive FAQ functionality.