Files
agent-s-rag-pamyatyu/README.md
T
2026-06-30 15:18:35 +03:00

132 lines
3.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Agent with RAG Memory
This repository contains a lightweight implementation of an agent that can
interact with a **RetrievalAugmented Generation (RAG)** knowledge base.
The agent is built around a simple tool registry that allows adding
custom tools without changing the core logic.
## Features
- **Knowledge Base Tool** A filebased key/value store that can be
queried, added to, and deleted from by both the agent and the CLI.
- **CLI Commands** Simple commandline interface for managing the
knowledge base.
- **Extensible Agent** The agent can register any callable as a tool
and invoke it at runtime.
## Installation
```bash
# Clone the repository
git clone https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu.git
cd agent-s-rag-pamyatyu
# Create a virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows use `.venv\Scripts\activate`
# Install the package
pip install .
```
## Knowledge Base
The knowledge base is a simple JSON file (`knowledge_base.json`) that
stores key/value pairs. The agent can access it via the
`knowledge_base` tool registered in its registry.
### CLI Usage
The package exposes a console script named `kb`. It supports three
subcommands:
| Command | Description | Example |
|---------|-------------|---------|
| `kb add <key> <value>` | Add or update a key/value pair. | `kb add greeting "Hello, world!"` |
| `kb query <key>` | Retrieve the value for a key. | `kb query greeting` |
| `kb delete <key>` | Delete a key/value pair. | `kb delete greeting` |
> **Tip**: The value is stored as a JSONserialisable string. For
> complex data structures, pass a JSON string (e.g. `"[1, 2, 3]"`).
### Agent Usage
```python
from src.agent import Agent
agent = Agent()
# Add a fact
agent.tools["knowledge_base"].add_entry("author", "Artur Kuzakhmetov")
# Retrieve a fact
print(agent.get_fact("author")) # Output: Artur Kuzakhmetov
```
## Project Structure
```
src/
├── agent.py # Core agent implementation
├── knowledge_base.py # Knowledge base tool
└── cli.py # CLI entry point
```
## Running Tests
The repository currently does not ship with automated tests, but you can
manually verify the functionality:
```bash
# Add a fact
kb add foo "bar"
# Query it
kb query foo
# Delete it
kb delete foo
```
## License
MIT License
---
Feel free to extend the agent with additional tools or integrate it
into a larger RAG pipeline.
---
> **Note**: The agent logic is intentionally minimal to keep the
> example focused on the knowledgebase integration. You can add more
> sophisticated reasoning or LLM integration as needed.
---
> **Author**: Artur Kuzakhmetov
---
> **Repository**: https://git.brojs.ru/kuzakhmetovartur/agent-s-rag-pamyatyu
---
> **Version**: 14 (as of 30.06.2026)
---
> **Deadline**: 31.08.2026
---
> **Feedback**: The CLI and knowledgebase tools have been added to
> satisfy the assignment requirements.
---
> **Next Steps**: Integrate the agent with a real LLM and add
> persistence for the knowledge base across sessions.
---
> **Contact**: artur@example.com
---
> **Enjoy!**
---
> **End of README**