memorisdk 1.0.1__py3-none-any.whl → 1.0.2__py3-none-any.whl

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.

memori/core/memory.py CHANGED
@@ -89,6 +89,7 @@ class Memori:
89
89
  self.search_engine = None
90
90
  self.conscious_agent = None
91
91
  self._background_task = None
92
+ self._conscious_init_pending = False
92
93
 
93
94
  if conscious_ingest or auto_ingest:
94
95
  try:
@@ -168,16 +169,44 @@ class Memori:
168
169
  "Conscious-ingest: Starting conscious agent analysis at startup"
169
170
  )
170
171
 
171
- # Run conscious agent analysis in background
172
- if self._background_task is None or self._background_task.done():
173
- self._background_task = asyncio.create_task(
174
- self._run_conscious_initialization()
172
+ # Check if there's a running event loop
173
+ try:
174
+ loop = asyncio.get_running_loop()
175
+ # If we're in an event loop, create the task
176
+ if self._background_task is None or self._background_task.done():
177
+ self._background_task = loop.create_task(
178
+ self._run_conscious_initialization()
179
+ )
180
+ logger.debug(
181
+ "Conscious-ingest: Background initialization task started"
182
+ )
183
+ except RuntimeError:
184
+ # No event loop running, defer initialization until first async call
185
+ logger.debug(
186
+ "Conscious-ingest: No event loop available, deferring initialization"
175
187
  )
176
- logger.debug("Conscious-ingest: Background initialization task started")
188
+ self._conscious_init_pending = True
177
189
 
178
190
  except Exception as e:
179
191
  logger.error(f"Failed to initialize conscious memory: {e}")
180
192
 
193
+ def _check_deferred_initialization(self):
194
+ """Check and handle deferred conscious memory initialization"""
195
+ if self._conscious_init_pending and self.conscious_agent:
196
+ try:
197
+ loop = asyncio.get_running_loop()
198
+ if self._background_task is None or self._background_task.done():
199
+ self._background_task = loop.create_task(
200
+ self._run_conscious_initialization()
201
+ )
202
+ logger.debug(
203
+ "Conscious-ingest: Deferred initialization task started"
204
+ )
205
+ self._conscious_init_pending = False
206
+ except RuntimeError:
207
+ # Still no event loop, keep pending
208
+ pass
209
+
181
210
  async def _run_conscious_initialization(self):
182
211
  """Run conscious agent initialization in background"""
183
212
  try:
@@ -475,6 +504,8 @@ class Memori:
475
504
  def _inject_openai_context(self, kwargs):
476
505
  """Inject context for OpenAI calls"""
477
506
  try:
507
+ # Check for deferred conscious initialization
508
+ self._check_deferred_initialization()
478
509
  # Extract user input from messages
479
510
  user_input = ""
480
511
  for msg in reversed(kwargs.get("messages", [])):
@@ -513,6 +544,8 @@ class Memori:
513
544
  def _inject_anthropic_context(self, kwargs):
514
545
  """Inject context for Anthropic calls"""
515
546
  try:
547
+ # Check for deferred conscious initialization
548
+ self._check_deferred_initialization()
516
549
  # Extract user input from messages
517
550
  user_input = ""
518
551
  for msg in reversed(kwargs.get("messages", [])):
@@ -563,6 +596,8 @@ class Memori:
563
596
  mode: "conscious" (one-shot short-term) or "auto" (continuous retrieval)
564
597
  """
565
598
  try:
599
+ # Check for deferred conscious initialization
600
+ self._check_deferred_initialization()
566
601
  # Extract user input from messages
567
602
  user_input = ""
568
603
  messages = params.get("messages", [])
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memorisdk
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: The Open-Source Memory Layer for AI Agents & Multi-Agent Systems
5
- Author-email: Memori Team <contact@memori.dev>
5
+ Author-email: GibsonAI Team <noc@gibsonai.com>
6
6
  License: Apache-2.0
7
7
  Project-URL: Homepage, https://github.com/GibsonAI/memori
8
8
  Project-URL: Documentation, https://gibsonai.github.io/memori
@@ -70,15 +70,38 @@ Requires-Dist: litellm>=1.0.0; extra == "all"
70
70
  Requires-Dist: anthropic>=0.3.0; extra == "all"
71
71
  Dynamic: license-file
72
72
 
73
- # Memori
74
-
75
- **The Open-Source Memory Layer for AI Agents & Multi-Agent Systems v1.2**
76
-
77
- *Give your AI agents structured, persistent memory with intelligent context injection - no more repeating yourself!*
78
-
79
- [![PyPI version](https://badge.fury.io/py/memori.svg)](https://badge.fury.io/py/memori)
80
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
81
- [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
73
+ [![GibsonAI](https://github.com/user-attachments/assets/878e341b-5a93-4489-a398-abeca91b6b11)](https://gibsonai.com/)
74
+
75
+ # memori
76
+
77
+ <p align="center">
78
+ <strong>Open-Source Memory Engine for LLMs, AI Agents & Multi-Agent Systems</strong>
79
+ </p>
80
+
81
+ <p align="center">
82
+ <i>Make LLMs context-aware with human-like memory, dual-mode retrieval, and automatic context injection.</i>
83
+ </p>
84
+
85
+ <p align="center">
86
+ <a href="https://gibsonai.github.io/memori/">Learn more</a>
87
+ ·
88
+ <a href="https://www.gibsonai.com/discord">Join Discord</a>
89
+ </p>
90
+
91
+ <p align="center">
92
+ <a href="https://badge.fury.io/py/memorisdk">
93
+ <img src="https://badge.fury.io/py/memori.svg" alt="PyPI version">
94
+ </a>
95
+ <a href="https://pepy.tech/projects/memorisdk">
96
+ <img src="https://static.pepy.tech/badge/memorisdk" alt="Downloads">
97
+ </a>
98
+ <a href="https://opensource.org/licenses/MIT">
99
+ <img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT">
100
+ </a>
101
+ <a href="https://www.python.org/downloads/">
102
+ <img src="https://img.shields.io/badge/python-3.8+-blue.svg" alt="Python 3.8+">
103
+ </a>
104
+ </p>
82
105
 
83
106
  ---
84
107
 
@@ -92,32 +115,69 @@ Dynamic: license-file
92
115
 
93
116
  ## ⚡ Quick Start
94
117
 
118
+ Install Memori:
119
+
95
120
  ```bash
96
121
  pip install memorisdk
97
122
  ```
98
123
 
124
+ ### Example with LiteLLM
125
+
126
+ 1. Install LiteLLM:
127
+
128
+ ```bash
129
+ pip install litellm
130
+ ```
131
+
132
+ 2. Set OpenAI API Key:
133
+
134
+ ```bash
135
+ export OPENAI_API_KEY="sk-your-openai-key-here"
136
+ ```
137
+
138
+ 3. Run this Python script:
139
+
99
140
  ```python
100
141
  from memori import Memori
142
+ from litellm import completion
101
143
 
102
- # Create your workspace memory with conscious mode
103
- office_work = Memori(
104
- database_connect="sqlite:///office_memory.db",
105
- conscious_ingest=True, # Short-term working memory (one-shot context)
106
- openai_api_key="your-key"
107
- )
144
+ # Initialize memory
145
+ memori = Memori(conscious_ingest=True)
146
+ memori.enable()
108
147
 
109
- office_work.enable() # Start recording conversations
148
+ print("=== First Conversation - Establishing Context ===")
149
+ response1 = completion(
150
+ model="gpt-4o-mini",
151
+ messages=[{
152
+ "role": "user",
153
+ "content": "I'm working on a Python FastAPI project"
154
+ }]
155
+ )
110
156
 
111
- # Use ANY LLM library - context automatically injected!
112
- from litellm import completion
157
+ print("Assistant:", response1.choices[0].message.content)
158
+ print("\n" + "="*50)
159
+ print("=== Second Conversation - Memory Provides Context ===")
113
160
 
114
- response = completion(
115
- model="gpt-4o",
116
- messages=[{"role": "user", "content": "Help me with Python testing"}]
161
+ response2 = completion(
162
+ model="gpt-4o-mini",
163
+ messages=[{
164
+ "role": "user",
165
+ "content": "Help me add user authentication"
166
+ }]
117
167
  )
118
- # ✨ Short-term working memory automatically included once per session
168
+ print("Assistant:", response2.choices[0].message.content)
169
+ print("\n💡 Notice: Memori automatically knows about your FastAPI Python project!")
119
170
  ```
120
171
 
172
+ ---
173
+
174
+ **🚀 Ready to explore more?**
175
+ - [📖 Examples](#examples) - Basic usage patterns and code samples
176
+ - [🔌 Framework Integrations](#framework-integrations) - LangChain, Agno & CrewAI examples
177
+ - [🎮 Interactive Demos](#interactive-demos) - Live applications & tutorials
178
+
179
+ ---
180
+
121
181
  ## 🧠 How It Works
122
182
 
123
183
  ### 1. **Universal Recording**
@@ -365,7 +425,7 @@ memori/
365
425
  └── tools/ # Memory search tools
366
426
  ```
367
427
 
368
- ## 🚀 Examples
428
+ ## Examples
369
429
 
370
430
  - **[Basic Usage](./examples/basic_usage.py)** - Simple memory setup with conscious ingestion
371
431
  - **[Personal Assistant](./examples/personal_assistant.py)** - AI assistant with intelligent memory
@@ -373,9 +433,32 @@ memori/
373
433
  - **[Advanced Config](./examples/advanced_config.py)** - Production configuration
374
434
  - **[Interactive Demo](./memori_example.py)** - Live conscious ingestion showcase
375
435
 
436
+ ## Framework Integrations
437
+
438
+ Memori works seamlessly with popular AI frameworks:
439
+
440
+ | Framework | Description | Example | Features |
441
+ |-----------|-------------|---------|----------|
442
+ | 🤖 [Agno](./examples/integrations/agno_example.py) | Memory-enhanced agent framework integration with persistent conversations | Simple chat agent with memory search | Memory tools, conversation persistence, contextual responses |
443
+ | 👥 [CrewAI](./examples/integrations/crewai_example.py) | Multi-agent system with shared memory across agent interactions | Collaborative agents with memory | Agent coordination, shared memory, task-based workflows |
444
+ | 🌊 [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 | Context injection, session continuity, support analytics |
445
+ | 🔗 [LangChain](./examples/integrations/langchain_example.py) | Enterprise-grade agent framework with advanced memory integration | AI assistant with LangChain tools and memory | Custom tools, agent executors, memory persistence, error handling |
446
+ | 🚀 [Swarms](./examples/integrations/swarms_example.py) | Multi-agent system framework with persistent memory capabilities | Memory-enhanced Swarms agents with auto/conscious ingestion | Agent memory persistence, multi-agent coordination, contextual awareness |
447
+
448
+ ## Interactive Demos
449
+
450
+ Explore Memori's capabilities through these interactive demonstrations:
451
+
452
+ | Title | Description | Tools Used | Live Demo |
453
+ |------------|-------------|------------|-----------|
454
+ | 🌟 [Personal Diary Assistant](./demos/personal_diary_assistant/) | A comprehensive diary assistant with mood tracking, pattern analysis, and personalized recommendations. | Streamlit, LiteLLM, OpenAI, SQLite | [Run Demo](https://personal-diary-assistant.streamlit.app/) |
455
+ | 🌍 [Travel Planner Agent](./demos/travel_planner/) | Intelligent travel planning with CrewAI agents, real-time web search, and memory-based personalization. Plans complete itineraries with budget analysis. | CrewAI, Streamlit, OpenAI, SQLite | |
456
+ | 🧑‍🔬 [Researcher Agent](./demos/researcher_agent/) | Advanced AI research assistant with persistent memory, real-time web search, and comprehensive report generation. Builds upon previous research sessions. | Agno, Streamlit, OpenAI, ExaAI, SQLite | [Run Demo](https://researcher-agent-memori.streamlit.app/) |
457
+
376
458
  ## 🤝 Contributing
377
459
 
378
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
460
+ - See [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.
461
+ - Community: [Discord](https://www.gibsonai.com/discord)
379
462
 
380
463
  ## 📄 License
381
464
 
@@ -8,7 +8,7 @@ memori/config/manager.py,sha256=xi8d8xW3obyV6v9UHDG6idSAymge8yWxGW11e2mI0nQ,1038
8
8
  memori/config/settings.py,sha256=nrrWD4hwdbtYlIPtJFHgGyMudGP-hz9sA-KBW_7ZZbE,9724
9
9
  memori/core/__init__.py,sha256=jvhHn-KL3bzRHs11-4B0BCKH6gkAf6Gf_G59If8fD0M,157
10
10
  memori/core/database.py,sha256=eok8lvXvFbHk_H2TEiYnRAX5nVE0xQgE0TUigRfGovs,36248
11
- memori/core/memory.py,sha256=nYPqO4dCzKEzVxYKJn4OvrSz7zq3vQ3gUpGkpZ1B88A,53313
11
+ memori/core/memory.py,sha256=8xF7Yi1k13OkNGisc_ehY_iuU3E0qTHiSc_mnw2iouk,54955
12
12
  memori/database/__init__.py,sha256=kMLxwfRfTVvw0oV1kl9v-Dkyqm6ggcsMV6hltqdrN3k,189
13
13
  memori/database/connectors/__init__.py,sha256=tG283nMRMWWM3B4WBfi7PMYnSUcH2Go5C88O91dOjcE,275
14
14
  memori/database/connectors/mysql_connector.py,sha256=P9tahYczjgfm_0iZpD1OxekeXLXnbpKt9M9EEe9NAjU,4861
@@ -36,9 +36,9 @@ memori/utils/logging.py,sha256=HXf3UrE0cm72KvFwyCjE7237opIxdNqzqxQQauhrX34,7131
36
36
  memori/utils/pydantic_models.py,sha256=U9nVy3Dko1X_dS4PpA7z2aacqegSSwOmZvQzPuVRcA0,8047
37
37
  memori/utils/schemas.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
38
  memori/utils/validators.py,sha256=2btILpEh2yBS_6rytp2B2epFxMT4876SibS0yNj6bKI,11287
39
- memorisdk-1.0.1.dist-info/licenses/LICENSE,sha256=gyrDaYsSODngoYE1l68l_UfjppS-oYDrf1MvY1JGhgE,10430
40
- memorisdk-1.0.1.dist-info/METADATA,sha256=NlWPctmdLlWel35LPLNMIgKjzbpSsHCebqZ5mU_nsUk,12989
41
- memorisdk-1.0.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
- memorisdk-1.0.1.dist-info/entry_points.txt,sha256=ir3aWDbFfKGKQlnJCW440GQ2saYNznptoXWheOUtu5c,43
43
- memorisdk-1.0.1.dist-info/top_level.txt,sha256=Nm3ad0isbJYBzTEce-O_gmkAEiTbAbyilgAhRt8IoGA,7
44
- memorisdk-1.0.1.dist-info/RECORD,,
39
+ memorisdk-1.0.2.dist-info/licenses/LICENSE,sha256=gyrDaYsSODngoYE1l68l_UfjppS-oYDrf1MvY1JGhgE,10430
40
+ memorisdk-1.0.2.dist-info/METADATA,sha256=KlUMw305S5PF68k0fxmS4ByYTLmEPrguzlr3FyzgqbI,16784
41
+ memorisdk-1.0.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
+ memorisdk-1.0.2.dist-info/entry_points.txt,sha256=ir3aWDbFfKGKQlnJCW440GQ2saYNznptoXWheOUtu5c,43
43
+ memorisdk-1.0.2.dist-info/top_level.txt,sha256=Nm3ad0isbJYBzTEce-O_gmkAEiTbAbyilgAhRt8IoGA,7
44
+ memorisdk-1.0.2.dist-info/RECORD,,