Agent with RAG Memory

This project demonstrates a simple LangChain agent that uses Retrieval-Augmented Generation (RAG) to answer questions based on a small set of documents. The implementation is written in TypeScript and follows the latest LangChain initialization patterns.

Features

  • Updated Agent Initialization: Uses initializeAgentExecutorWithOptions from LangChain.
  • Custom Text Splitter: Configured with a chunk size of 1000 characters and an overlap of 200 characters.
  • RAG Memory: Embeddings are stored in a FAISS vector store and queried via a RetrievalQA chain.
  • Simple Test Harness: Runs a sample query and prints the agent's response.

Prerequisites

  • Node.js v18 or newer
  • npm

Setup

# Clone the repository
git clone https://github.com/your-username/agent-rag-memory.git
cd agent-rag-memory

# Install dependencies
npm install

# Create a .env file with your OpenAI API key
echo "OPENAI_API_KEY=your_api_key_here" > .env

Running the Agent

npm start

You should see output similar to:

=== Agent Response ===
Paris

Project Structure

agent-rag-memory/
├── src/
│   └── index.ts          # Main implementation
├── package.json
├── tsconfig.json
└── README.md

License

MIT License

S
Description
BroJS: Агент с RAG-памятью
Readme 145 KiB
Languages
Python 67.1%
TypeScript 16.6%
JavaScript 15.4%
Dockerfile 0.9%