44 lines
920 B
Markdown
44 lines
920 B
Markdown
# 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
|
||
|
||
```bash
|
||
npm install
|
||
```
|
||
|
||
## Usage
|
||
|
||
```bash
|
||
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:
|
||
|
||
```bash
|
||
npm install langchain-ollama
|
||
```
|
||
|
||
```js
|
||
import { Ollama } from 'langchain-ollama';
|
||
```
|
||
|
||
Adjust the model initialization accordingly.
|
||
|
||
--- |