2.7 KiB
2.7 KiB
What was implemented
- Switched the embedding provider from
OpenAIEmbeddingstoOllamaEmbeddings(langchain‑community). - Replaced the FAISS vector store with a Qdrant store.
- Updated all imports, configuration, and helper functions to use the new stack.
- Added the required dependencies (
langchain-community,qdrant-client) torequirements.txt. - Kept the LLM (
OpenAI), prompt templates, chain structure, and memory unchanged. - Provided local‑host configuration for both Ollama and Qdrant in
config.py.
Why the main parts satisfy the requirements
- Embeddings –
embeddings.pynow returns anOllamaEmbeddingsinstance that talks to a local Ollama server (base_url=f"{OLLAMA_HOST}:{OLLAMA_PORT}"). - Vector store –
vector_store.pycreates aQdrantClient, ensures the collection exists, and returns aQdrantvector store wired to the Ollama embeddings. - Agent –
agent.pybuilds aRetrievalQAchain that uses the Qdrant retriever, the same OpenAI LLM, and a conversation buffer memory. - Configuration –
config.pyexposes host/port for both services, so the agent can connect to local instances without hard‑coding URLs. - Dependencies –
requirements.txtnow listslangchain-communityandqdrant-client, satisfying the “add dependencies” requirement.
Key code excerpts
embeddings.py – Ollama embeddings
from langchain_community.embeddings import OllamaEmbeddings
...
return OllamaEmbeddings(
model=OLLAMA_EMBEDDING_MODEL,
base_url=f"{OLLAMA_HOST}:{OLLAMA_PORT}"
)
vector_store.py – Qdrant store
from qdrant_client import QdrantClient
...
return Qdrant(
client=client,
collection_name=QDRANT_COLLECTION_NAME,
embeddings=embeddings
)
agent.py – RetrievalQA chain unchanged except for the retriever
vector_store: Qdrant = get_vector_store()
retriever = vector_store.as_retriever(search_kwargs={"k": 5})
...
chain = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=retriever,
memory=memory
)
config.py – local‑host settings
OLLAMA_HOST: str = "http://localhost"
OLLAMA_PORT: int = 11434
QDRANT_HOST: str = "http://localhost"
QDRANT_PORT: int = 6333
Honest limitations
- The solution assumes a running local Ollama server exposing the chosen embedding model (
llama2) and a Qdrant instance listening on the default ports. - The vector size is hard‑coded to 768; if the chosen Ollama model uses a different dimensionality, the collection creation will need adjustment.
- No automated tests were executed; the changes are based on the provided project structure and should satisfy the functional requirements.