memorisdk 2.1.1__tar.gz → 2.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of memorisdk might be problematic. Click here for more details.
- {memorisdk-2.1.1 → memorisdk-2.3.1}/PKG-INFO +21 -7
- {memorisdk-2.1.1 → memorisdk-2.3.1}/README.md +20 -6
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/__init__.py +1 -1
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/agents/conscious_agent.py +5 -4
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/agents/memory_agent.py +13 -7
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/agents/retrieval_agent.py +49 -17
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/core/conversation.py +15 -8
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/core/memory.py +117 -45
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/auto_creator.py +72 -5
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/mongodb_manager.py +29 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/search_service.py +265 -121
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/sqlalchemy_manager.py +94 -13
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/integrations/openai_integration.py +12 -27
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/logging.py +32 -81
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/validators.py +4 -4
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memorisdk.egg-info/PKG-INFO +21 -7
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memorisdk.egg-info/SOURCES.txt +2 -1
- {memorisdk-2.1.1 → memorisdk-2.3.1}/pyproject.toml +1 -1
- memorisdk-2.3.1/tests/test_memory_validation.py +39 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/LICENSE +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/agents/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/config/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/config/manager.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/config/memory_manager.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/config/settings.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/core/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/core/database.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/core/providers.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/adapters/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/adapters/mongodb_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/adapters/mysql_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/adapters/postgresql_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/adapters/sqlite_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connection_utils.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connectors/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connectors/base_connector.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connectors/mongodb_connector.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connectors/mysql_connector.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connectors/postgres_connector.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/connectors/sqlite_connector.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/models.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/queries/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/queries/base_queries.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/queries/chat_queries.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/queries/entity_queries.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/queries/memory_queries.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/query_translator.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/schema_generators/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/schema_generators/mongodb_schema_generator.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/schema_generators/mysql_schema_generator.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/search/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/search/mongodb_search_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/search/mysql_search_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/search/sqlite_search_adapter.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/templates/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/templates/basic_template.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/database/templates/schemas/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/integrations/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/integrations/anthropic_integration.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/integrations/litellm_integration.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/tools/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/tools/memory_tool.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/__init__.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/exceptions.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/helpers.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/input_validator.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/pydantic_models.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/query_builder.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/schemas.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/security_audit.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/security_integration.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memori/utils/transaction_manager.py +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memorisdk.egg-info/dependency_links.txt +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memorisdk.egg-info/requires.txt +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/memorisdk.egg-info/top_level.txt +0 -0
- {memorisdk-2.1.1 → memorisdk-2.3.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: memorisdk
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: The Open-Source Memory Layer for AI Agents & Multi-Agent Systems
|
|
5
5
|
Author-email: GibsonAI Team <noc@gibsonai.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -95,7 +95,7 @@ Requires-Dist: pandas>=2.0.0; extra == "all"
|
|
|
95
95
|
Requires-Dist: plotly>=5.17.0; extra == "all"
|
|
96
96
|
Dynamic: license-file
|
|
97
97
|
|
|
98
|
-
[](https://memorilabs.ai/)
|
|
99
99
|
|
|
100
100
|
# memori
|
|
101
101
|
|
|
@@ -110,7 +110,7 @@ Dynamic: license-file
|
|
|
110
110
|
<p align="center">
|
|
111
111
|
<a href="https://memori.gibsonai.com/docs">Learn more</a>
|
|
112
112
|
·
|
|
113
|
-
<a href="https://
|
|
113
|
+
<a href="https://discord.gg/abD4eGym6v">Join Discord</a>
|
|
114
114
|
</p>
|
|
115
115
|
|
|
116
116
|
<p align="center">
|
|
@@ -120,14 +120,20 @@ Dynamic: license-file
|
|
|
120
120
|
<a href="https://pepy.tech/projects/memorisdk">
|
|
121
121
|
<img src="https://static.pepy.tech/badge/memorisdk" alt="Downloads">
|
|
122
122
|
</a>
|
|
123
|
-
<a href="https://opensource.org/
|
|
124
|
-
<img src="https://img.shields.io/badge/
|
|
123
|
+
<a href="https://opensource.org/license/apache-2-0">
|
|
124
|
+
<img src="https://img.shields.io/badge/license-Apache%20License%202.0-blue" alt="License: Apache 2.0">
|
|
125
125
|
</a>
|
|
126
126
|
<a href="https://www.python.org/downloads/">
|
|
127
127
|
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python 3.8+">
|
|
128
128
|
</a>
|
|
129
129
|
</p>
|
|
130
130
|
|
|
131
|
+
<p align="center">
|
|
132
|
+
<a href="https://github.com/GibsonAI/memori/stargazers">
|
|
133
|
+
<img src="https://img.shields.io/badge/⭐%20Give%20a%20Star-Support%20the%20project-orange?style=for-the-badge" alt="Give a Star">
|
|
134
|
+
</a>
|
|
135
|
+
</p>
|
|
136
|
+
|
|
131
137
|
---
|
|
132
138
|
|
|
133
139
|
## What is Memori
|
|
@@ -206,6 +212,8 @@ print("\n💡 Notice: Memori automatically knows about your FastAPI Python proje
|
|
|
206
212
|
|
|
207
213
|
---
|
|
208
214
|
|
|
215
|
+
⭐️ **Enjoying Memori?** Give us a star to support open development
|
|
216
|
+
|
|
209
217
|
> By default, Memori uses in-memory SQLite database. Get **FREE** serverless database instance in [GibsonAI](https://app.gibsonai.com/signup) platform.
|
|
210
218
|
|
|
211
219
|
**🚀 Ready to explore more?**
|
|
@@ -326,6 +334,7 @@ memori = Memori(
|
|
|
326
334
|
database_connect="sqlite:///my_memory.db",
|
|
327
335
|
template="basic",
|
|
328
336
|
conscious_ingest=True, # One-shot context injection
|
|
337
|
+
conscious_memory_limit=100, # Must be an integer between 1 and 500
|
|
329
338
|
openai_api_key="sk-..."
|
|
330
339
|
)
|
|
331
340
|
|
|
@@ -482,6 +491,7 @@ Memori works seamlessly with popular AI frameworks:
|
|
|
482
491
|
| [Agno](./examples/integrations/agno_example.py) | Memory-enhanced agent framework integration with persistent conversations | Simple chat agent with memory search |
|
|
483
492
|
| [AWS Strands](./examples/integrations/aws_strands_example.py) | Professional development coach with Strands SDK and persistent memory | Career coaching agent with goal tracking |
|
|
484
493
|
| [Azure AI Foundry](./examples/integrations/azure_ai_foundry_example.py) | Azure AI Foundry agents with persistent memory across conversations | Enterprise AI agents with Azure integration |
|
|
494
|
+
| [AutoGen](./examples/integrations/autogen_example.py) | Multi-agent group chat memory recording | Agent chats with memory integration |
|
|
485
495
|
| [CamelAI](./examples/integrations/camelai_example.py) | Multi-agent communication framework with automatic memory recording and retrieval | Memory-enhanced chat agents with conversation continuity |
|
|
486
496
|
| [CrewAI](./examples/integrations/crewai_example.py) | Multi-agent system with shared memory across agent interactions | Collaborative agents with memory |
|
|
487
497
|
| [Digital Ocean AI](./examples/integrations/digital_ocean_example.py) | Memory-enhanced customer support using Digital Ocean's AI platform | Customer support assistant with conversation history |
|
|
@@ -502,11 +512,15 @@ Explore Memori's capabilities through these interactive demonstrations:
|
|
|
502
512
|
## 🤝 Contributing
|
|
503
513
|
|
|
504
514
|
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
|
|
505
|
-
- Community: [Discord](https://
|
|
515
|
+
- Community: [Discord](https://discord.gg/abD4eGym6v)
|
|
516
|
+
|
|
517
|
+
## ⭐️ Star us on GitHub to support the project
|
|
518
|
+
|
|
519
|
+
[](https://www.star-history.com/#GibsonAI/memori&type=date&legend=top-left)
|
|
506
520
|
|
|
507
521
|
## 📄 License
|
|
508
522
|
|
|
509
|
-
|
|
523
|
+
Apache 2.0 License - see [LICENSE](./LICENSE) for details.
|
|
510
524
|
|
|
511
525
|
---
|
|
512
526
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://memorilabs.ai/)
|
|
2
2
|
|
|
3
3
|
# memori
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
<p align="center">
|
|
14
14
|
<a href="https://memori.gibsonai.com/docs">Learn more</a>
|
|
15
15
|
·
|
|
16
|
-
<a href="https://
|
|
16
|
+
<a href="https://discord.gg/abD4eGym6v">Join Discord</a>
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
19
|
<p align="center">
|
|
@@ -23,14 +23,20 @@
|
|
|
23
23
|
<a href="https://pepy.tech/projects/memorisdk">
|
|
24
24
|
<img src="https://static.pepy.tech/badge/memorisdk" alt="Downloads">
|
|
25
25
|
</a>
|
|
26
|
-
<a href="https://opensource.org/
|
|
27
|
-
<img src="https://img.shields.io/badge/
|
|
26
|
+
<a href="https://opensource.org/license/apache-2-0">
|
|
27
|
+
<img src="https://img.shields.io/badge/license-Apache%20License%202.0-blue" alt="License: Apache 2.0">
|
|
28
28
|
</a>
|
|
29
29
|
<a href="https://www.python.org/downloads/">
|
|
30
30
|
<img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python 3.8+">
|
|
31
31
|
</a>
|
|
32
32
|
</p>
|
|
33
33
|
|
|
34
|
+
<p align="center">
|
|
35
|
+
<a href="https://github.com/GibsonAI/memori/stargazers">
|
|
36
|
+
<img src="https://img.shields.io/badge/⭐%20Give%20a%20Star-Support%20the%20project-orange?style=for-the-badge" alt="Give a Star">
|
|
37
|
+
</a>
|
|
38
|
+
</p>
|
|
39
|
+
|
|
34
40
|
---
|
|
35
41
|
|
|
36
42
|
## What is Memori
|
|
@@ -109,6 +115,8 @@ print("\n💡 Notice: Memori automatically knows about your FastAPI Python proje
|
|
|
109
115
|
|
|
110
116
|
---
|
|
111
117
|
|
|
118
|
+
⭐️ **Enjoying Memori?** Give us a star to support open development
|
|
119
|
+
|
|
112
120
|
> By default, Memori uses in-memory SQLite database. Get **FREE** serverless database instance in [GibsonAI](https://app.gibsonai.com/signup) platform.
|
|
113
121
|
|
|
114
122
|
**🚀 Ready to explore more?**
|
|
@@ -229,6 +237,7 @@ memori = Memori(
|
|
|
229
237
|
database_connect="sqlite:///my_memory.db",
|
|
230
238
|
template="basic",
|
|
231
239
|
conscious_ingest=True, # One-shot context injection
|
|
240
|
+
conscious_memory_limit=100, # Must be an integer between 1 and 500
|
|
232
241
|
openai_api_key="sk-..."
|
|
233
242
|
)
|
|
234
243
|
|
|
@@ -385,6 +394,7 @@ Memori works seamlessly with popular AI frameworks:
|
|
|
385
394
|
| [Agno](./examples/integrations/agno_example.py) | Memory-enhanced agent framework integration with persistent conversations | Simple chat agent with memory search |
|
|
386
395
|
| [AWS Strands](./examples/integrations/aws_strands_example.py) | Professional development coach with Strands SDK and persistent memory | Career coaching agent with goal tracking |
|
|
387
396
|
| [Azure AI Foundry](./examples/integrations/azure_ai_foundry_example.py) | Azure AI Foundry agents with persistent memory across conversations | Enterprise AI agents with Azure integration |
|
|
397
|
+
| [AutoGen](./examples/integrations/autogen_example.py) | Multi-agent group chat memory recording | Agent chats with memory integration |
|
|
388
398
|
| [CamelAI](./examples/integrations/camelai_example.py) | Multi-agent communication framework with automatic memory recording and retrieval | Memory-enhanced chat agents with conversation continuity |
|
|
389
399
|
| [CrewAI](./examples/integrations/crewai_example.py) | Multi-agent system with shared memory across agent interactions | Collaborative agents with memory |
|
|
390
400
|
| [Digital Ocean AI](./examples/integrations/digital_ocean_example.py) | Memory-enhanced customer support using Digital Ocean's AI platform | Customer support assistant with conversation history |
|
|
@@ -405,11 +415,15 @@ Explore Memori's capabilities through these interactive demonstrations:
|
|
|
405
415
|
## 🤝 Contributing
|
|
406
416
|
|
|
407
417
|
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
|
|
408
|
-
- Community: [Discord](https://
|
|
418
|
+
- Community: [Discord](https://discord.gg/abD4eGym6v)
|
|
419
|
+
|
|
420
|
+
## ⭐️ Star us on GitHub to support the project
|
|
421
|
+
|
|
422
|
+
[](https://www.star-history.com/#GibsonAI/memori&type=date&legend=top-left)
|
|
409
423
|
|
|
410
424
|
## 📄 License
|
|
411
425
|
|
|
412
|
-
|
|
426
|
+
Apache 2.0 License - see [LICENSE](./LICENSE) for details.
|
|
413
427
|
|
|
414
428
|
---
|
|
415
429
|
|
|
@@ -5,7 +5,7 @@ Professional-grade memory layer with comprehensive error handling, configuration
|
|
|
5
5
|
management, and modular architecture for production AI systems.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "2.
|
|
8
|
+
__version__ = "2.3.0"
|
|
9
9
|
__author__ = "Harshal More"
|
|
10
10
|
__email__ = "harshalmore2468@gmail.com"
|
|
11
11
|
|
|
@@ -116,7 +116,7 @@ class ConsciouscAgent:
|
|
|
116
116
|
return False
|
|
117
117
|
|
|
118
118
|
async def initialize_existing_conscious_memories(
|
|
119
|
-
self, db_manager, namespace: str = "default"
|
|
119
|
+
self, db_manager, namespace: str = "default", limit: int = 10
|
|
120
120
|
) -> bool:
|
|
121
121
|
"""
|
|
122
122
|
Initialize by copying ALL existing conscious-info memories to short-term memory
|
|
@@ -143,16 +143,17 @@ class ConsciouscAgent:
|
|
|
143
143
|
from sqlalchemy import text
|
|
144
144
|
|
|
145
145
|
with db_manager._get_connection() as connection:
|
|
146
|
-
# Get
|
|
146
|
+
# Get top conscious-info labeled memories from long-term memory (limited for performance)
|
|
147
147
|
cursor = connection.execute(
|
|
148
148
|
text(
|
|
149
149
|
"""SELECT memory_id, processed_data, summary, searchable_content,
|
|
150
150
|
importance_score, created_at
|
|
151
151
|
FROM long_term_memory
|
|
152
152
|
WHERE namespace = :namespace AND classification = 'conscious-info'
|
|
153
|
-
ORDER BY importance_score DESC, created_at DESC
|
|
153
|
+
ORDER BY importance_score DESC, created_at DESC
|
|
154
|
+
LIMIT :limit"""
|
|
154
155
|
),
|
|
155
|
-
{"namespace": namespace},
|
|
156
|
+
{"namespace": namespace, "limit": limit},
|
|
156
157
|
)
|
|
157
158
|
existing_conscious_memories = cursor.fetchall()
|
|
158
159
|
|
|
@@ -204,6 +204,9 @@ CONVERSATION CONTEXT:
|
|
|
204
204
|
"content": f"Process this conversation for enhanced memory storage:\n\n{conversation_text}\n{context_info}",
|
|
205
205
|
},
|
|
206
206
|
],
|
|
207
|
+
metadata=[
|
|
208
|
+
"INTERNAL_MEMORY_PROCESSING"
|
|
209
|
+
], # Internal metadata tag
|
|
207
210
|
response_format=ProcessedLongTermMemory,
|
|
208
211
|
temperature=0.1, # Low temperature for consistent processing
|
|
209
212
|
)
|
|
@@ -237,17 +240,19 @@ CONVERSATION CONTEXT:
|
|
|
237
240
|
)
|
|
238
241
|
|
|
239
242
|
logger.debug(
|
|
240
|
-
f"Processed conversation {chat_id}
|
|
241
|
-
f"classification
|
|
242
|
-
f"importance
|
|
243
|
-
f"conscious_context
|
|
244
|
-
f"promotion_eligible
|
|
243
|
+
f"[AGENT] Processed conversation {chat_id[:8]}... - "
|
|
244
|
+
f"classification: {processed_memory.classification.value} | "
|
|
245
|
+
f"importance: {processed_memory.importance.value} | "
|
|
246
|
+
f"conscious_context: {processed_memory.is_user_context} | "
|
|
247
|
+
f"promotion_eligible: {processed_memory.promotion_eligible}"
|
|
245
248
|
)
|
|
246
249
|
|
|
247
250
|
return processed_memory
|
|
248
251
|
|
|
249
252
|
except Exception as e:
|
|
250
|
-
logger.error(
|
|
253
|
+
logger.error(
|
|
254
|
+
f"[AGENT] Memory processing failed for {chat_id[:8]}... - {type(e).__name__}: {e}"
|
|
255
|
+
)
|
|
251
256
|
return self._create_empty_long_term_memory(
|
|
252
257
|
chat_id, f"Processing failed: {str(e)}"
|
|
253
258
|
)
|
|
@@ -307,7 +312,7 @@ CONVERSATION CONTEXT:
|
|
|
307
312
|
|
|
308
313
|
if avg_similarity >= similarity_threshold:
|
|
309
314
|
logger.info(
|
|
310
|
-
f"Duplicate detected
|
|
315
|
+
f"[AGENT] Duplicate detected - {avg_similarity:.2f} similarity with {existing.conversation_id[:8]}..."
|
|
311
316
|
)
|
|
312
317
|
return existing.conversation_id
|
|
313
318
|
|
|
@@ -415,6 +420,7 @@ CONVERSATION CONTEXT:
|
|
|
415
420
|
"content": f"Process this conversation for enhanced memory storage:\n\n{conversation_text}\n{context_info}",
|
|
416
421
|
},
|
|
417
422
|
],
|
|
423
|
+
metadata=["INTERNAL_MEMORY_PROCESSING"], # Internal metadata tag
|
|
418
424
|
temperature=0.1, # Low temperature for consistent processing
|
|
419
425
|
max_tokens=2000, # Ensure enough tokens for full response
|
|
420
426
|
)
|
|
@@ -149,6 +149,9 @@ Be strategic and comprehensive in your search planning."""
|
|
|
149
149
|
"content": prompt,
|
|
150
150
|
},
|
|
151
151
|
],
|
|
152
|
+
metadata=[
|
|
153
|
+
"INTERNAL_MEMORY_PROCESSING"
|
|
154
|
+
], # Internal metadata tag
|
|
152
155
|
response_format=MemorySearchQuery,
|
|
153
156
|
temperature=0.1,
|
|
154
157
|
)
|
|
@@ -218,15 +221,25 @@ Be strategic and comprehensive in your search planning."""
|
|
|
218
221
|
all_results = []
|
|
219
222
|
seen_memory_ids = set()
|
|
220
223
|
|
|
221
|
-
# For MongoDB and SQL, use
|
|
222
|
-
# This ensures we use the database's native search capabilities
|
|
223
|
-
logger.debug(f"Executing
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
224
|
+
# For MongoDB and SQL, use SearchService directly to avoid recursion
|
|
225
|
+
# This ensures we use the database's native search capabilities without triggering context injection
|
|
226
|
+
logger.debug(f"Executing direct SearchService search using {db_type}")
|
|
227
|
+
try:
|
|
228
|
+
from ..database.search_service import SearchService
|
|
229
|
+
|
|
230
|
+
with db_manager.SessionLocal() as session:
|
|
231
|
+
search_service = SearchService(session, db_type)
|
|
232
|
+
primary_results = search_service.search_memories(
|
|
233
|
+
query=search_plan.query_text or query,
|
|
234
|
+
namespace=namespace,
|
|
235
|
+
limit=limit,
|
|
236
|
+
)
|
|
237
|
+
logger.debug(
|
|
238
|
+
f"Direct SearchService returned {len(primary_results)} results"
|
|
239
|
+
)
|
|
240
|
+
except Exception as e:
|
|
241
|
+
logger.error(f"SearchService direct access failed: {e}")
|
|
242
|
+
primary_results = []
|
|
230
243
|
|
|
231
244
|
# Process primary results and add search metadata
|
|
232
245
|
for result in primary_results:
|
|
@@ -383,9 +396,17 @@ Be strategic and comprehensive in your search planning."""
|
|
|
383
396
|
|
|
384
397
|
search_terms = " ".join(keywords)
|
|
385
398
|
try:
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
399
|
+
# Use SearchService directly to avoid recursion
|
|
400
|
+
from ..database.search_service import SearchService
|
|
401
|
+
|
|
402
|
+
db_type = self._detect_database_type(db_manager)
|
|
403
|
+
|
|
404
|
+
with db_manager.SessionLocal() as session:
|
|
405
|
+
search_service = SearchService(session, db_type)
|
|
406
|
+
results = search_service.search_memories(
|
|
407
|
+
query=search_terms, namespace=namespace, limit=limit
|
|
408
|
+
)
|
|
409
|
+
|
|
389
410
|
# Ensure results is a list of dictionaries
|
|
390
411
|
if not isinstance(results, list):
|
|
391
412
|
logger.warning(f"Search returned non-list result: {type(results)}")
|
|
@@ -417,14 +438,24 @@ Be strategic and comprehensive in your search planning."""
|
|
|
417
438
|
if not categories:
|
|
418
439
|
return []
|
|
419
440
|
|
|
420
|
-
#
|
|
421
|
-
#
|
|
441
|
+
# Use SearchService directly to avoid recursion
|
|
442
|
+
# Get all memories and filter by category
|
|
422
443
|
logger.debug(
|
|
423
444
|
f"Searching memories by categories: {categories} in namespace: {namespace}"
|
|
424
445
|
)
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
446
|
+
try:
|
|
447
|
+
from ..database.search_service import SearchService
|
|
448
|
+
|
|
449
|
+
db_type = self._detect_database_type(db_manager)
|
|
450
|
+
|
|
451
|
+
with db_manager.SessionLocal() as session:
|
|
452
|
+
search_service = SearchService(session, db_type)
|
|
453
|
+
all_results = search_service.search_memories(
|
|
454
|
+
query="", namespace=namespace, limit=limit * 3
|
|
455
|
+
)
|
|
456
|
+
except Exception as e:
|
|
457
|
+
logger.error(f"Category search failed: {e}")
|
|
458
|
+
all_results = []
|
|
428
459
|
|
|
429
460
|
logger.debug(
|
|
430
461
|
f"Retrieved {len(all_results)} total results for category filtering"
|
|
@@ -628,6 +659,7 @@ Be strategic and comprehensive in your search planning."""
|
|
|
628
659
|
"content": prompt,
|
|
629
660
|
},
|
|
630
661
|
],
|
|
662
|
+
metadata=["INTERNAL_MEMORY_PROCESSING"], # Internal metadata tag
|
|
631
663
|
temperature=0.1,
|
|
632
664
|
max_tokens=1000, # Ensure enough tokens for full response
|
|
633
665
|
)
|
|
@@ -207,7 +207,7 @@ class ConversationManager:
|
|
|
207
207
|
elif mode == "auto":
|
|
208
208
|
# Auto mode: Search long-term memory database for relevant context
|
|
209
209
|
logger.debug(
|
|
210
|
-
f"Auto-ingest
|
|
210
|
+
f"[CONTEXT] Auto-ingest processing - Query: '{user_input[:50]}...' | Session: {session_id[:8]}..."
|
|
211
211
|
)
|
|
212
212
|
context = (
|
|
213
213
|
memori_instance._get_auto_ingest_context(user_input)
|
|
@@ -217,11 +217,11 @@ class ConversationManager:
|
|
|
217
217
|
if context:
|
|
218
218
|
context_prompt = self._build_auto_context_prompt(context)
|
|
219
219
|
logger.debug(
|
|
220
|
-
f"
|
|
220
|
+
f"[CONTEXT] Long-term memory injected - {len(context)} items | Session: {session_id[:8]}..."
|
|
221
221
|
)
|
|
222
222
|
else:
|
|
223
223
|
logger.debug(
|
|
224
|
-
f"
|
|
224
|
+
f"[CONTEXT] No relevant memories found for '{user_input[:30]}...' | Session: {session_id[:8]}..."
|
|
225
225
|
)
|
|
226
226
|
|
|
227
227
|
# Get conversation history
|
|
@@ -242,11 +242,17 @@ class ConversationManager:
|
|
|
242
242
|
if previous_messages:
|
|
243
243
|
system_content += "\n--- Conversation History ---\n"
|
|
244
244
|
for msg in previous_messages:
|
|
245
|
-
|
|
245
|
+
if msg["role"] == "assistant":
|
|
246
|
+
role_label = "Assistant"
|
|
247
|
+
elif msg["role"] == "user":
|
|
248
|
+
role_label = "User"
|
|
249
|
+
else:
|
|
250
|
+
role_label = msg["role"].capitalize()
|
|
246
251
|
system_content += f"{role_label}: {msg['content']}\n"
|
|
252
|
+
|
|
247
253
|
system_content += "--- End History ---\n"
|
|
248
254
|
logger.debug(
|
|
249
|
-
f"Added {len(previous_messages)} history messages
|
|
255
|
+
f"[CONTEXT] Added {len(previous_messages)} history messages | Session: {session_id[:8]}..."
|
|
250
256
|
)
|
|
251
257
|
|
|
252
258
|
# Find existing system message or create new one
|
|
@@ -267,16 +273,17 @@ class ConversationManager:
|
|
|
267
273
|
0, {"role": "system", "content": system_content}
|
|
268
274
|
)
|
|
269
275
|
|
|
276
|
+
context_status = "yes" if context_prompt else "no"
|
|
277
|
+
history_status = "yes" if len(history_messages) > 1 else "no"
|
|
270
278
|
logger.debug(
|
|
271
|
-
f"Enhanced messages for session {session_id}:
|
|
272
|
-
f"history={'yes' if len(history_messages) > 1 else 'no'}"
|
|
279
|
+
f"[CONTEXT] Enhanced messages for session {session_id[:8]}... - context: {context_status} | history: {history_status}"
|
|
273
280
|
)
|
|
274
281
|
|
|
275
282
|
return enhanced_messages
|
|
276
283
|
|
|
277
284
|
except Exception as e:
|
|
278
285
|
logger.error(
|
|
279
|
-
f"Failed to inject context
|
|
286
|
+
f"[CONTEXT] Failed to inject context for session {session_id[:8]}... - {type(e).__name__}: {e}"
|
|
280
287
|
)
|
|
281
288
|
return messages
|
|
282
289
|
|