|
| 1 | +# Chat Interface Setup |
| 2 | + |
| 3 | +The chat interface is now connected to the OpenMemory backend and can query memories in real-time. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +✅ **Memory Querying**: Searches your memory database for relevant content |
| 8 | +✅ **Salience-based Results**: Shows top memories ranked by relevance |
| 9 | +✅ **Memory Reinforcement**: Click the + button to boost memory importance |
| 10 | +✅ **Real-time Updates**: Live connection to backend API |
| 11 | +✅ **Action Buttons**: Quick actions after assistant responses |
| 12 | + |
| 13 | +## Setup Instructions |
| 14 | + |
| 15 | +### 1. Start the Backend |
| 16 | + |
| 17 | +First, make sure the OpenMemory backend is running: |
| 18 | + |
| 19 | +```bash |
| 20 | +cd backend |
| 21 | +npm install |
| 22 | +npm run dev |
| 23 | +``` |
| 24 | + |
| 25 | +The backend will start on `http://localhost:8080` |
| 26 | + |
| 27 | +### 2. Configure Environment (Optional) |
| 28 | + |
| 29 | +The dashboard is pre-configured to connect to `localhost:8080`. If your backend runs on a different port, create a `.env.local` file: |
| 30 | + |
| 31 | +```bash |
| 32 | +# dashboard/.env.local |
| 33 | +NEXT_PUBLIC_API_URL=http://localhost:8080 |
| 34 | +``` |
| 35 | + |
| 36 | +### 3. Start the Dashboard |
| 37 | + |
| 38 | +```bash |
| 39 | +cd dashboard |
| 40 | +npm install |
| 41 | +npm run dev |
| 42 | +``` |
| 43 | + |
| 44 | +The dashboard will start on `http://localhost:3000` |
| 45 | + |
| 46 | +### 4. Add Some Memories |
| 47 | + |
| 48 | +Before chatting, you need to add some memories to your database. You can do this via: |
| 49 | + |
| 50 | +**Option A: API (Recommended for Testing)** |
| 51 | + |
| 52 | +```bash |
| 53 | +curl -X POST http://localhost:8080/memory/add \ |
| 54 | + -H "Content-Type: application/json" \ |
| 55 | + -d '{ |
| 56 | + "content": "JavaScript async/await makes asynchronous code more readable", |
| 57 | + "tags": ["javascript", "async"], |
| 58 | + "metadata": {"source": "learning"} |
| 59 | + }' |
| 60 | +``` |
| 61 | + |
| 62 | +**Option B: Use the SDK** |
| 63 | + |
| 64 | +```javascript |
| 65 | +// examples/js-sdk/basic-usage.js |
| 66 | +import OpenMemory from '../../sdk-js/src/index.js'; |
| 67 | + |
| 68 | +const om = new OpenMemory('http://localhost:8080'); |
| 69 | + |
| 70 | +await om.addMemory({ |
| 71 | + content: 'React hooks revolutionized state management', |
| 72 | + tags: ['react', 'hooks'], |
| 73 | +}); |
| 74 | +``` |
| 75 | + |
| 76 | +**Option C: Ingest a Document** |
| 77 | + |
| 78 | +```bash |
| 79 | +curl -X POST http://localhost:8080/memory/ingest \ |
| 80 | + -H "Content-Type: application/json" \ |
| 81 | + -d '{ |
| 82 | + "content_type": "text", |
| 83 | + "data": "Your document content here...", |
| 84 | + "metadata": {"source": "document"} |
| 85 | + }' |
| 86 | +``` |
| 87 | + |
| 88 | +## How It Works |
| 89 | + |
| 90 | +### Memory Query Flow |
| 91 | + |
| 92 | +1. **User Input**: You ask a question in the chat |
| 93 | +2. **Backend Query**: POST to `/memory/query` with your question |
| 94 | +3. **Vector Search**: Backend searches HSG memory graph |
| 95 | +4. **Results**: Top 5 memories returned with salience scores |
| 96 | +5. **Response**: Chat generates answer based on retrieved memories |
| 97 | + |
| 98 | +### Memory Reinforcement |
| 99 | + |
| 100 | +Clicking the **+** button on a memory card: |
| 101 | + |
| 102 | +- Sends POST to `/memory/reinforce` |
| 103 | +- Increases memory salience by 0.1 |
| 104 | +- Makes it more likely to appear in future queries |
| 105 | + |
| 106 | +## Current Features |
| 107 | + |
| 108 | +✅ Real-time memory querying |
| 109 | +✅ Salience-based ranking |
| 110 | +✅ Memory reinforcement (boost) |
| 111 | +✅ Sector classification display |
| 112 | +✅ Error handling with backend status |
| 113 | + |
| 114 | +## Coming Soon |
| 115 | + |
| 116 | +- 🚧 LLM Integration (OpenAI, Ollama, Gemini) |
| 117 | +- 🚧 Conversation memory persistence |
| 118 | +- 🚧 Export chat to memories |
| 119 | +- 🚧 WebSocket streaming responses |
| 120 | +- 🚧 Quiz generation from memories |
| 121 | +- 🚧 Podcast script generation |
| 122 | + |
| 123 | +## Troubleshooting |
| 124 | + |
| 125 | +### "Failed to query memories" |
| 126 | + |
| 127 | +- Ensure backend is running: `npm run dev` in `backend/` |
| 128 | +- Check backend is on port 8080: `curl http://localhost:8080/health` |
| 129 | +- Verify CORS is enabled (already configured) |
| 130 | + |
| 131 | +### "No memories found" |
| 132 | + |
| 133 | +- Add memories using the API or SDK (see setup above) |
| 134 | +- Try broader search terms |
| 135 | +- Check memory content exists: `GET http://localhost:8080/memory/all` |
| 136 | + |
| 137 | +### Connection refused |
| 138 | + |
| 139 | +- Backend not started |
| 140 | +- Wrong port in `.env.local` |
| 141 | +- Firewall blocking connection |
| 142 | + |
| 143 | +## API Endpoints Used |
| 144 | + |
| 145 | +```typescript |
| 146 | +POST /memory/query // Search memories |
| 147 | +POST /memory/add // Add new memory |
| 148 | +POST /memory/reinforce // Boost memory salience |
| 149 | +GET /memory/all // List all memories |
| 150 | +GET /memory/:id // Get specific memory |
| 151 | +``` |
| 152 | + |
| 153 | +## Next Steps |
| 154 | + |
| 155 | +1. Add LLM integration for intelligent responses |
| 156 | +2. Implement conversation memory storage |
| 157 | +3. Add streaming response support |
| 158 | +4. Create memory export feature |
| 159 | +5. Build quiz/podcast generators |
0 commit comments