0.3.6 • Published 5 months ago
@aigne/example-memory v0.3.6
Memory Example
This example demonstrates how to create a chatbot with memory capabilities using the AIGNE Framework and AIGNE CLI. The example utilizes the FSMemory plugin to provide persistence across chat sessions.
Prerequisites
- Node.js and npm installed on your machine
- An OpenAI API key for interacting with OpenAI's services
- Optional dependencies (if running the example from source code):
Quick Start (No Installation Required)
export OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Set your OpenAI API key
# Run the chatbot with memory
npx -y @aigne/example-memoryInstallation
Clone the Repository
git clone https://github.com/AIGNE-io/aigne-frameworkInstall Dependencies
cd aigne-framework/examples/memory
pnpm installSetup Environment Variables
Setup your OpenAI API key in the .env.local file:
OPENAI_API_KEY="" # Set your OpenAI API key hereRun the Example
pnpm startHow Memory Works
This example uses the FSMemory plugin from @aigne/agent-library to persist conversation history. The memory is stored in files within the memories directory, allowing the chatbot to remember previous interactions across different chat sessions.
Key features of the memory implementation:
- Conversations are stored in a file system for persistence
- The chatbot can recall previous interactions even after restarting
- You can test this by chatting with the bot, closing the session, and starting a new one
Example Usage
Try using the chatbot in these ways to test its memory capabilities:
- Introduce yourself to the chatbot
- Ask it a question or have a conversation
- Close the session and restart the chatbot
- Ask the chatbot if it remembers your previous conversation
The chatbot should be able to recall information from your previous interactions.