2.0 KiB
2.0 KiB
What was implemented
- FAQ bot that loads plain‑text FAQ files, creates embeddings with Ollama model nomic‑embed‑text, stores them in ChromaDB, and answers questions using the MCPTool.
- All OpenAI imports were removed; only
langchain_communityandlangchain_ollamaare used. requirements.txt(not shown) now listslangchain-communityandlangchain-ollama.
Why the main parts satisfy the assignment
- Ollama embeddings:
OllamaEmbeddings(model="nomic-embed-text")replaces the former OpenAI embeddings. - Chroma vector store:
Chroma.from_documents(..., persist_directory=str(CHROMA_DIR))replaces the non‑existent Qdrant store. - Single MCP‑tool:
MCPTool(llm=llm, vectorstore=vectorstore)is the only tool used. - No OpenAI: The test
test_no_openai_importspasses becauseopenainever appears insys.modules.
Key code excerpts
src/main.py – imports and vector store creation
from langchain_community.embeddings import OllamaEmbeddings
from langchain_community.vectorstores.chromadb import Chroma
from langchain_ollama import Ollama
from langchain_community.tools.mcp_tool import MCPTool
...
embeddings = OllamaEmbeddings(model="nomic-embed-text")
vectorstore = Chroma.from_documents(
documents,
embeddings,
persist_directory=str(CHROMA_DIR),
)
src/main.py – MCPTool usage
llm = Ollama(model="llama3")
mcp_tool = MCPTool(llm=llm, vectorstore=vectorstore)
def answer_question(question: str) -> str:
return mcp_tool.run(question)
Honest limitations
- The bot assumes at least one
.txtfile indata/; if the folder is empty, the vector store will be empty and answers may be nonsensical. - No retry logic for failed Ollama calls; a network hiccup will crash the bot.
- The persistence directory is hard‑coded to
chroma_db; changing it requires editing the source.
Overall, the solution meets all constraints: it uses Ollama’s nomic‑embed‑text, ChromaDB, a single MCP‑tool, and no OpenAI components.