https://github.com/jeantessier/langchain-javascript-example
An example of using LangChain in JavaScript with @langchain/core
https://github.com/jeantessier/langchain-javascript-example
Last synced: 10 months ago
JSON representation
An example of using LangChain in JavaScript with @langchain/core
- Host: GitHub
- URL: https://github.com/jeantessier/langchain-javascript-example
- Owner: jeantessier
- Created: 2024-12-13T21:25:35.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-03T19:36:03.000Z (11 months ago)
- Last Synced: 2025-03-03T20:33:16.382Z (11 months ago)
- Language: JavaScript
- Size: 37.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LangChain JavaScript Example
A sample Node script that uses LangChain to talk to LLMs.
You’ll need an API key for each LLM. So just follow the instructions linked
below to obtain your API keys.
- [OpenAI ChatGPT](https://platform.openai.com/api-keys)
- [Anthropic Claude](https://console.anthropic.com/settings/keys)
- [Google Gemini](https://aistudio.google.com/app/apikey)
- [DeepSeek R1](https://platform.deepseek.com/api_keys)
Save the keys to the `.env` file as the corresponding `..._API_KEY` environment
variable. You can use `.env.template` as a guide to structure your `.env`
file.
Install packages, if you haven't already.
```bash
pnpm install
```
## To Run
The sample logic is in the file `index.js`.
To run against OpenAI's ChatGPT:
```bash
pnpm run main --model openai
```
To run against Anthropic's Claude:
```bash
pnpm run main --model anthropic
```
To run against Google's Gemini:
```bash
pnpm run main --model google
```
To run against DeekSeek's R1:
```bash
pnpm run main --model deepseek
```
If you don't specify `--model`, it will default to `openai` and use ChatGPT.