08e0fee2233e34b4cdc389f174868b83d547f3d5
Self‑Correcting Agent
This repository demonstrates a minimal self‑correcting agent that uses the LangChain OpenAI provider to generate responses from an LLM.
Prerequisites
- Node.js v18 or newer (ESM support required)
- An OpenAI API key set in the environment variable
OPENAI_API_KEY
Installation
npm install
Usage
npm start
The script will send a prompt to the LLM and print the response.
Project Structure
src/agent.js– Contains the logic to interact with the LLM.src/index.js– Entry point that demonstrates usage.package.json– Project metadata and dependencies.
Adding a Different LLM Provider
If you prefer to use another provider (e.g., Ollama), replace the dependency and imports:
npm install langchain-ollama
import { Ollama } from 'langchain-ollama';
Adjust the model initialization accordingly.
Languages
Python
63.5%
JavaScript
22%
TypeScript
14.5%