Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/extrawest/anthropic-claude-chat-bot
Chat bot with conversation memory using Anthropic's Claude AI model on LangChain JS
https://github.com/extrawest/anthropic-claude-chat-bot
ai anthropic-claude claude demo javascript langchain langchain-js prompt
Last synced: 15 days ago
JSON representation
Chat bot with conversation memory using Anthropic's Claude AI model on LangChain JS
- Host: GitHub
- URL: https://github.com/extrawest/anthropic-claude-chat-bot
- Owner: extrawest
- Created: 2024-08-01T16:06:45.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-02T07:49:20.000Z (6 months ago)
- Last Synced: 2024-08-27T09:05:37.697Z (5 months ago)
- Topics: ai, anthropic-claude, claude, demo, javascript, langchain, langchain-js, prompt
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Anthropic Claude Chat Bot
This project implements a chat bot using Anthropic's Claude AI model, with conversation memory and streaming capabilities. It's built using Node.js and leverages the LangChain framework for AI interactions.
## Demo
https://github.com/user-attachments/assets/c28c4685-f4bd-4a79-9145-e74d12cd7261
## Technologies and Frameworks Used
- **Node.js**: The runtime environment for executing the JavaScript code.
- **LangChain**: A framework for developing applications powered by language models.### Libraries and Packages
- **@langchain/anthropic**: For interacting with Anthropic's Claude AI model.
- **@langchain/core**: Core LangChain functionalities for prompts, messages, and chat history.
- **dotenv**: For loading environment variables.## Key Concepts and Features
1. **Chat Model**: Uses Anthropic's Claude 3.5 Sonnet model for generating responses.
2. **Conversation Memory**: Implements in-memory chat history to maintain context across interactions.
4. **Prompt Templates**: Utilizes ChatPromptTemplate for structuring prompts with system messages and placeholders.
5. **Runnable Sequences**: Implements a chain of operations using RunnableSequence for processing inputs and generating responses.
6. **Streaming Responses**: Supports streaming of AI responses for real-time output.## Setup and Configuration
1. Clone the repository.
2. Install dependencies with `npm install`.
3. Create a `.env` file with the following variable:
- `ANTHROPIC_API_KEY`: Your Anthropic API key## Usage
Run the script with:
```bash
node index.js
```The script demonstrates the chat bot's capabilities by:
1. Initializing with a pre-defined conversation history.
2. Asking a question that requires remembering previous information.
3. Streaming the AI's response to the console.## Customization
- Modify the messages array to change the initial conversation history.
- Adjust the prompt template to alter the system message or structure of the prompts.
- Change the model configuration in the ChatAnthropic constructor to use different Claude models or parameters.