Spaces:
Sleeping
Sleeping
Joachim M. Vis commited on
Delete SUPABASE_TABLES_README.md
Browse files- SUPABASE_TABLES_README.md +0 -122
SUPABASE_TABLES_README.md
DELETED
|
@@ -1,122 +0,0 @@
|
|
| 1 |
-
# Supabase Tables for GAIA Agent
|
| 2 |
-
|
| 3 |
-
This document explains the issue with Supabase tables in the GAIA agent and how to fix it.
|
| 4 |
-
|
| 5 |
-
## Issue
|
| 6 |
-
|
| 7 |
-
The GAIA agent uses multiple Supabase tables for different types of memory:
|
| 8 |
-
|
| 9 |
-
1. `gaia_memory`: Main memory table for storing key-value pairs
|
| 10 |
-
2. `gaia_memory_working`: Working memory table for storing intermediate results during reasoning
|
| 11 |
-
3. `gaia_memory_conversations`: Conversation history table for storing message history
|
| 12 |
-
4. `gaia_memory_cache`: Cache table for storing frequently accessed results
|
| 13 |
-
|
| 14 |
-
However, only the main memory table (`gaia_memory`) and the test connection table are being populated, while the other tables remain empty. This is because the specialized memory classes (`WorkingMemory`, `ConversationMemory`, `ResultCache`) set their own table names but when calling methods on the base memory object, they were always using the base memory's table.
|
| 15 |
-
|
| 16 |
-
## Fix
|
| 17 |
-
|
| 18 |
-
We've created two fix scripts:
|
| 19 |
-
|
| 20 |
-
1. `memory/fix_supabase_tables.py`: A comprehensive fix that modifies all memory classes to use their respective tables
|
| 21 |
-
2. `memory/simplified_memory_fix.py`: A simplified fix that focuses only on the working memory table
|
| 22 |
-
|
| 23 |
-
The fix modifies the `SupabaseMemory` class to accept a `table_name` parameter in its methods, and updates the specialized memory classes to pass their table name when calling the base memory methods.
|
| 24 |
-
|
| 25 |
-
## How to Use the Fix
|
| 26 |
-
|
| 27 |
-
### Option 1: Run the GAIA agent with the fix applied
|
| 28 |
-
|
| 29 |
-
```bash
|
| 30 |
-
python run_gaia_with_fix.py --question "Your question here"
|
| 31 |
-
```
|
| 32 |
-
|
| 33 |
-
This script applies the fix, runs the GAIA agent with your question, and shows the content of all tables after the question is answered.
|
| 34 |
-
|
| 35 |
-
### Option 2: Apply the fix manually
|
| 36 |
-
|
| 37 |
-
```bash
|
| 38 |
-
# For all tables
|
| 39 |
-
python -m memory.fix_supabase_tables
|
| 40 |
-
|
| 41 |
-
# For working memory only
|
| 42 |
-
python -m memory.simplified_memory_fix
|
| 43 |
-
```
|
| 44 |
-
|
| 45 |
-
### Option 3: Run tests
|
| 46 |
-
|
| 47 |
-
```bash
|
| 48 |
-
# Simple test for working memory
|
| 49 |
-
python -m tests.test_supabase_tables_simple
|
| 50 |
-
|
| 51 |
-
# Comprehensive test for all tables
|
| 52 |
-
python -m tests.test_gaia_with_all_tables
|
| 53 |
-
```
|
| 54 |
-
|
| 55 |
-
## Table Descriptions
|
| 56 |
-
|
| 57 |
-
### gaia_memory
|
| 58 |
-
|
| 59 |
-
The main memory table for storing key-value pairs. This is the default table used by the `SupabaseMemory` class.
|
| 60 |
-
|
| 61 |
-
### gaia_memory_working
|
| 62 |
-
|
| 63 |
-
The working memory table for storing intermediate results during reasoning. This table is used by the `WorkingMemory` class to store temporary data during the reasoning process, such as:
|
| 64 |
-
|
| 65 |
-
- Parsed question
|
| 66 |
-
- Identified entities
|
| 67 |
-
- Intermediate reasoning steps
|
| 68 |
-
- Search results
|
| 69 |
-
- Final answer
|
| 70 |
-
|
| 71 |
-
### gaia_memory_conversations
|
| 72 |
-
|
| 73 |
-
The conversation history table for storing message history. This table is used by the `ConversationMemory` class to store the conversation history, including:
|
| 74 |
-
|
| 75 |
-
- User messages
|
| 76 |
-
- Assistant messages
|
| 77 |
-
- Timestamps
|
| 78 |
-
- Metadata
|
| 79 |
-
|
| 80 |
-
### gaia_memory_cache
|
| 81 |
-
|
| 82 |
-
The cache table for storing frequently accessed results. This table is used by the `ResultCache` class to store cached results, which can improve performance by avoiding redundant computations.
|
| 83 |
-
|
| 84 |
-
## Performance Benefits
|
| 85 |
-
|
| 86 |
-
Using the specialized tables provides several benefits:
|
| 87 |
-
|
| 88 |
-
1. **Improved organization**: Each type of memory has its own table, making it easier to manage and query.
|
| 89 |
-
2. **Better performance**: Smaller, specialized tables are faster to query than a single large table.
|
| 90 |
-
3. **Enhanced debugging**: It's easier to debug issues when each memory type has its own table.
|
| 91 |
-
4. **Reduced data conflicts**: Separate tables reduce the risk of key conflicts between different memory types.
|
| 92 |
-
|
| 93 |
-
## Implementation Details
|
| 94 |
-
|
| 95 |
-
The fix works by monkey-patching the following methods:
|
| 96 |
-
|
| 97 |
-
### SupabaseMemory
|
| 98 |
-
|
| 99 |
-
- `store`: Modified to accept a `table_name` parameter
|
| 100 |
-
- `retrieve`: Modified to accept a `table_name` parameter
|
| 101 |
-
- `delete`: Modified to accept a `table_name` parameter
|
| 102 |
-
- `list_keys`: Modified to accept a `table_name` parameter
|
| 103 |
-
|
| 104 |
-
### WorkingMemory
|
| 105 |
-
|
| 106 |
-
- `store_intermediate_result`: Modified to use the working memory table
|
| 107 |
-
- `get_intermediate_result`: Modified to use the working memory table
|
| 108 |
-
- `list_intermediate_results`: Modified to use the working memory table
|
| 109 |
-
- `clear`: Modified to use the working memory table
|
| 110 |
-
|
| 111 |
-
### ConversationMemory
|
| 112 |
-
|
| 113 |
-
- `add_message`: Modified to use the conversations table
|
| 114 |
-
- `get_messages`: Modified to use the conversations table
|
| 115 |
-
- `clear`: Modified to use the conversations table
|
| 116 |
-
|
| 117 |
-
### ResultCache
|
| 118 |
-
|
| 119 |
-
- `cache_result`: Modified to use the cache table
|
| 120 |
-
- `get_result`: Modified to use the cache table
|
| 121 |
-
- `invalidate`: Modified to use the cache table
|
| 122 |
-
- `clear`: Modified to use the cache table
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|