# Agent with RAG Memory This project implements a simple command‑line agent that uses **Ollama embeddings** for a Retrieval‑Augmented Generation (RAG) style knowledge base. The agent supports two main tools: - **`search_knowledge_base`** – find the most relevant documents for a query. - **`add_to_knowledge_base`** – add new content to the knowledge base. ## Setup ```bash # Clone the repository git clone https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu.git cd agent-s-rag-pamyatyu # Install dependencies npm install ``` > **Note**: The project uses the `ollama-embeddings` package. > Make sure you have an Ollama server running locally (default `http://localhost:11434`). > You can change the host or model via environment variables: ```bash # Example .env file OLLAMA_HOST=http://localhost:11434 OLLAMA_MODEL=all-minilm ``` ## Running the Agent ```bash npm start ``` You will see a prompt: ``` Agent> ``` ### Commands - `/search ` – Search the knowledge base for the most relevant documents. - `/add ` – Add new content to the knowledge base. - `/exit` – Exit the program. Example: ``` Agent> /add The quick brown fox jumps over the lazy dog. Content added with id 3f1c2e4b-... Agent> /search fox Searching for "fox"... Top results: 1. [3f1c2e4b-...] (0.9123) The quick brown fox jumps over the lazy dog. ``` ## Project Structure - `src/embeddings.js` – Wrapper around `ollama-embeddings`. - `src/tools/searchKnowledgeBase.js` – Implements the search tool. - `src/tools/addToKnowledgeBase.js` – Implements the add tool. - `src/index.js` – CLI entry point and agent logic. - `package.json` – Dependencies and scripts. ## Extending The current implementation uses an in‑memory vector store. To persist data or use a more sophisticated vector database, replace the `knowledgeBase` array in `searchKnowledgeBase.js` with your preferred storage solution. ---