-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathletta.txt
More file actions
371 lines (281 loc) Β· 11.6 KB
/
letta.txt
File metadata and controls
371 lines (281 loc) Β· 11.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
================================================================================
LETTA LOCAL SERVER SETUP GUIDE
================================================================================
This guide will help you set up and run Letta server locally for the
LettaXRAG application. Follow these steps carefully to avoid connection errors.
================================================================================
OVERVIEW
================================================================================
The error you're seeing:
"HTTP Request: GET https://api.letta.com/v1/agents/?name=Isabella
HTTP/1.1 401 Unauthorized"
This happens because the Letta client is trying to connect to the cloud-based
Letta server (api.letta.com) instead of your local server.
SOLUTION: We need to:
1. Set up PostgreSQL (required by Letta server)
2. Configure Letta to use SQLite instead (simpler alternative)
3. Run the local Letta server
4. Configure LettaXRAG to connect to the local server
================================================================================
OPTION 1: USING SQLITE (RECOMMENDED - EASIEST)
================================================================================
SQLite is simpler and doesn't require PostgreSQL installation.
Step 1: Configure Letta to Use SQLite
--------------------------------------
Run the following command to configure Letta:
letta configure
When prompted, choose:
- Storage backend: "local" or "sqlite"
- Default model provider: Choose your preferred LLM provider
- Base URL: Leave as default (http://localhost:8283)
This creates a Letta configuration in your home directory:
- Linux/Mac: ~/.letta/config
- Windows: %USERPROFILE%\.letta\config
Step 2: Start Letta Server
---------------------------
letta server
Expected output:
[[ Letta server // v0.16.2 ]]
Server running at: http://localhost:8283
Step 3: Configure LettaXRAG
----------------------------
In your backend/.env file, ensure you have:
LETTA_BASE_URL=http://localhost:8283
# LETTA_API_KEY not needed for local server
Step 4: Run LettaXRAG Backend
------------------------------
cd backend
python main.py
You should see:
β
Connecting to local Letta server: http://localhost:8283
β
Letta personality engine ready!
================================================================================
OPTION 2: USING POSTGRESQL (ADVANCED)
================================================================================
If you prefer PostgreSQL or need its features:
Step 1: Install PostgreSQL
---------------------------
Ubuntu/Debian:
sudo apt update
sudo apt install postgresql postgresql-contrib
macOS (with Homebrew):
brew install postgresql
brew services start postgresql
Windows:
Download installer from: https://www.postgresql.org/download/windows/
Step 2: Create Letta Database
------------------------------
# Switch to postgres user
sudo -u postgres psql
# In PostgreSQL shell:
CREATE DATABASE letta;
CREATE USER letta_user WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE letta TO letta_user;
\q
Step 3: Configure Letta with PostgreSQL
----------------------------------------
letta configure
When prompted:
- Storage backend: Choose "postgres" or "postgresql"
- Database connection string:
postgresql://letta_user:your_password@localhost:5432/letta
- Base URL: http://localhost:8283
Step 4: Start PostgreSQL (if not running)
------------------------------------------
Ubuntu/Debian:
sudo systemctl start postgresql
sudo systemctl enable postgresql # Start on boot
macOS:
brew services start postgresql
Windows:
# PostgreSQL should auto-start as a service
# Or use: net start postgresql-x64-14 # Adjust version number
Step 5: Start Letta Server
---------------------------
letta server
Step 6: Configure and Run LettaXRAG
------------------------------------
Same as Option 1, Step 3-4 above.
================================================================================
TROUBLESHOOTING
================================================================================
Error: "ConnectionRefusedError: [WinError 1225]"
------------------------------------------------
CAUSE: Letta server is not running OR configured to use PostgreSQL but
PostgreSQL is not running.
SOLUTIONS:
1. Make sure Letta server is running in a separate terminal:
letta server
2. If using PostgreSQL, verify it's running:
Linux: sudo systemctl status postgresql
Mac: brew services list
Windows: services.msc -> look for "postgresql" service
3. Check Letta configuration:
letta configure
Choose SQLite for simpler setup.
Error: "HTTP/1.1 401 Unauthorized"
-----------------------------------
CAUSE: LettaXRAG is connecting to api.letta.com (cloud) instead of localhost.
SOLUTION:
1. Check your backend/.env file has:
LETTA_BASE_URL=http://localhost:8283
2. Restart the backend:
cd backend
python main.py
3. Verify in the logs you see:
"Connecting to local Letta server: http://localhost:8283"
Error: "Letta library not installed"
-------------------------------------
CAUSE: Letta package is not installed in your virtual environment.
SOLUTION:
cd backend
source venv/bin/activate # Windows: venv\Scripts\activate
pip install letta>=0.16.0
Error: "cannot access local variable 'session'"
------------------------------------------------
CAUSE: Database connection issue in Letta server.
SOLUTION:
1. Reconfigure Letta with SQLite:
letta configure
Choose "local" or "sqlite" storage backend.
2. Delete old Letta data (WARNING: loses Letta history):
Linux/Mac: rm -rf ~/.letta
Windows: rmdir /s %USERPROFILE%\.letta
3. Reconfigure and restart:
letta configure
letta server
Error: Port 8283 already in use
--------------------------------
CAUSE: Another Letta server is running or port is occupied.
SOLUTION:
1. Kill existing Letta process:
Linux/Mac: lsof -ti:8283 | xargs kill -9
Windows: netstat -ano | findstr :8283
taskkill /PID [PID_NUMBER] /F
2. Or change Letta server port:
letta server --port 8284
Then update backend/.env:
LETTA_BASE_URL=http://localhost:8284
================================================================================
RUNNING WITHOUT LETTA (ALTERNATIVE)
================================================================================
If you can't get Letta working or don't need personality features:
Option: Disable Letta
---------------------
1. Simply don't set LETTA_BASE_URL in your .env file:
# backend/.env
MONGODB_URI=mongodb://localhost:27017/lettaXrag
LONGCAT_API_KEY=your_api_key_here
# LETTA_BASE_URL= # Comment out or remove
# LETTA_API_KEY= # Comment out or remove
2. The system will automatically detect Letta is not available and continue
without it. Isabella will still work but without the Letta personality
processing layer.
3. Personality will be handled by LLM system prompts in llm_service.py.
================================================================================
VERIFICATION CHECKLIST
================================================================================
β Letta Configuration Check
----------------------------
letta configure --show
# Should display your current configuration
β Test Letta Server
--------------------
In a separate terminal:
letta server
Expected output:
Server running at: http://localhost:8283
β Test Letta Connection
------------------------
In Python (test the connection):
# Use the same import as in letta_service.py
from letta_client import Letta
client = Letta(base_url="http://localhost:8283")
agents = client.agents.list()
print("Connected successfully!")
# Note: If you get ImportError, try: pip install letta>=0.16.0
# The import 'from letta_client import Letta' is for Letta 0.16.x
β Check Backend Configuration
------------------------------
cat backend/.env | grep LETTA
Should show:
LETTA_BASE_URL=http://localhost:8283
β Test Full System
-------------------
1. Terminal 1 - Start Letta Server:
letta server
2. Terminal 2 - Start Backend:
cd backend
python main.py
Look for in logs:
"β
Connecting to local Letta server: http://localhost:8283"
"β
Letta personality engine ready!"
3. Terminal 3 - Start Frontend:
npm run dev
4. Open browser to http://localhost:5173 and test chat
================================================================================
RECOMMENDED SETUP FOR DEVELOPMENT
================================================================================
For the simplest and most reliable setup:
1. Use SQLite for Letta storage (not PostgreSQL)
2. Run Letta server locally on default port (8283)
3. Configure LettaXRAG to connect to localhost
4. Keep Letta server running in a dedicated terminal
Terminal Window Layout:
βββββββββββββββββββ¬ββββββββββββββββββ¬ββββββββββββββββββ
β Letta Server β Backend β Frontend β
β letta server β python main.py β npm run dev β
β :8283 β :8000 β :5173 β
βββββββββββββββββββ΄ββββββββββββββββββ΄ββββββββββββββββββ
================================================================================
ENVIRONMENT VARIABLES REFERENCE
================================================================================
backend/.env file should contain:
# Required
MONGODB_URI=mongodb://localhost:27017/lettaXrag
LONGCAT_API_KEY=your_actual_longcat_api_key_here
# Letta - Local Server (Recommended)
LETTA_BASE_URL=http://localhost:8283
# No LETTA_API_KEY needed for local server
# Letta - Cloud Server (Alternative)
# LETTA_BASE_URL=https://api.letta.com
# LETTA_API_KEY=your_letta_cloud_api_key_here
# Optional
DATA_FOLDER=./data
FAISS_INDEX_PATH=./storage/faiss_index.bin
LOG_LEVEL=DEBUG
================================================================================
COMMON COMMANDS REFERENCE
================================================================================
Letta Server Management:
letta configure # Configure Letta settings
letta configure --show # Show current configuration
letta server # Start server (default port 8283)
letta server --port 8284 # Start on custom port
PostgreSQL Management (if using):
# Linux
sudo systemctl start postgresql
sudo systemctl stop postgresql
sudo systemctl status postgresql
# macOS
brew services start postgresql
brew services stop postgresql
brew services list
# Windows
net start postgresql-x64-14
net stop postgresql-x64-14
Backend Management:
cd backend
source venv/bin/activate # Activate virtual environment
pip install -r requirements.txt # Install dependencies
python main.py # Start backend server
================================================================================
SUPPORT AND RESOURCES
================================================================================
Letta Documentation: https://docs.letta.com
Letta GitHub: https://github.com/letta-ai/letta
LettaXRAG Docs: See LETTA_INFO.md for detailed Letta integration info
For more help, open an issue on GitHub.
================================================================================
LAST UPDATED: January 2026
================================================================================