This project implements an AI agent capable of collecting information from websites, building a vectorized knowledge base, and leveraging that data to enhance a large language model through a retrieval-augmented generation (RAG) workflow.
"Currently, the example environment variables and the prompt assigned to the Astronomer Agent are configured to retrieve information from https://ialp.fcaglp.unlp.edu.ar. This allows the agent to respond to queries based on the content available on that website."
- Web scraping capabilities for linguistic data collection
- Text processing and smart text splitting
- RAG-based information retrieval
- Agent-based workflows for automated linguistic analysis
- Integration with Ollama for local LLM support
- Framework: Mastra.js for agent orchestration
- Language: TypeScript/Node.js (requires Node.js ≥ 20.9.0)
- Database: PostgreSQL for data storage
- LLM Integration: Ollama for local model deployment
- Web Scraping: Puppeteer and Cheerio
- Text Processing: HTML-to-text, PDF parsing
src/config/: Configuration files for environment, logging, and Ollamasrc/ingest/: Data ingestion processessrc/mastra/: Agent definitions, tools, and workflowssrc/rag/: Retrieval-Augmented Generation componentssrc/scraping/: Web scraping functionalitysrc/utils/: Utility functions for text processing and data handling
- Node.js (version 20.9.0 or higher)
- PNPM package manager
- PostgreSQL
- Ollama (for local LLM support)
-
Clone the repository:
git clone https://github.com/nehuenpereyra/web-agent cd web-agent -
Install dependencies:
pnpm install npx puppeteer browsers install chrome
-
Start the PostgreSQL database using Docker (optional):
docker run -d \
--name postgres-vector
-e POSTGRES_DB=vector_db
-e POSTGRES_USER=postgres
-e POSTGRES_PASSWORD=postgres
-e POSTGRES_HOST_AUTH_METHOD=trust
-p 5433:5432
-v "$(pwd -W)/pgdata:/var/lib/postgresql/data"
pgvector/pgvector:pg16
4. Set up environment variables:
```bash
cp .env.example .env
Edit the .env file with your configuration settings.
- Set up Ollama (if using local models):
pnpm setup:ollama
Run the development server:
pnpm devBuild the project:
pnpm buildStart the production server:
pnpm startProcess and ingest data:
pnpm ingestSave HTML content:
pnpm save:htmlSave extracted text:
pnpm save:textPrisma Migrate:
npx prisma migrate devMIT