chuk-ai-session-manager 0.5__tar.gz → 0.7.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.
Files changed (42) hide show
  1. chuk_ai_session_manager-0.7.1/PKG-INFO +262 -0
  2. chuk_ai_session_manager-0.7.1/README.md +236 -0
  3. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/pyproject.toml +22 -7
  4. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/__init__.py +73 -3
  5. chuk_ai_session_manager-0.7.1/src/chuk_ai_session_manager.egg-info/PKG-INFO +262 -0
  6. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager.egg-info/requires.txt +7 -4
  7. chuk_ai_session_manager-0.5/PKG-INFO +0 -896
  8. chuk_ai_session_manager-0.5/README.md +0 -873
  9. chuk_ai_session_manager-0.5/src/chuk_ai_session_manager.egg-info/PKG-INFO +0 -896
  10. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/setup.cfg +0 -0
  11. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/api/__init__.py +0 -0
  12. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/api/simple_api.py +0 -0
  13. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/exceptions.py +0 -0
  14. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/infinite_conversation.py +0 -0
  15. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/__init__.py +0 -0
  16. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/event_source.py +0 -0
  17. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/event_type.py +0 -0
  18. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/session.py +0 -0
  19. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/session_event.py +0 -0
  20. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/session_metadata.py +0 -0
  21. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/session_run.py +0 -0
  22. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/models/token_usage.py +0 -0
  23. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/sample_tools.py +0 -0
  24. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/session_aware_tool_processor.py +0 -0
  25. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/session_manager.py +0 -0
  26. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/session_prompt_builder.py +0 -0
  27. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager/session_storage.py +0 -0
  28. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager.egg-info/SOURCES.txt +0 -0
  29. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager.egg-info/dependency_links.txt +0 -0
  30. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/src/chuk_ai_session_manager.egg-info/top_level.txt +0 -0
  31. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_basic_functionality.py +0 -0
  32. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_exceptions.py +0 -0
  33. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_infinite_conversation.py +0 -0
  34. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_models.py +0 -0
  35. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_prompt_builder.py +0 -0
  36. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_session_manager.py +0 -0
  37. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_session_manager_advanced.py +0 -0
  38. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_simple.py +0 -0
  39. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_simple_api.py +0 -0
  40. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_storage.py +0 -0
  41. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_system_prompt.py +0 -0
  42. {chuk_ai_session_manager-0.5 → chuk_ai_session_manager-0.7.1}/tests/test_tools.py +0 -0
@@ -0,0 +1,262 @@
1
+ Metadata-Version: 2.4
2
+ Name: chuk-ai-session-manager
3
+ Version: 0.7.1
4
+ Summary: Session manager for AI applications
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: chuk-sessions>=0.4.2
8
+ Requires-Dist: chuk-tool-processor>=0.4.1
9
+ Requires-Dist: pydantic>=2.11.3
10
+ Provides-Extra: redis
11
+ Requires-Dist: chuk-sessions[redis]>=0.4.1; extra == "redis"
12
+ Requires-Dist: redis>=4.0.0; extra == "redis"
13
+ Provides-Extra: tiktoken
14
+ Requires-Dist: tiktoken>=0.9.0; extra == "tiktoken"
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
17
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
18
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
19
+ Requires-Dist: black>=23.0.0; extra == "dev"
20
+ Requires-Dist: isort>=5.12.0; extra == "dev"
21
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
22
+ Provides-Extra: all
23
+ Requires-Dist: chuk-sessions[redis]>=0.4; extra == "all"
24
+ Requires-Dist: redis>=4.0.0; extra == "all"
25
+ Requires-Dist: tiktoken>=0.9.0; extra == "all"
26
+
27
+ # CHUK AI Session Manager
28
+
29
+ **A powerful session management system for AI applications**
30
+
31
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
+
34
+ Automatic conversation tracking, token usage monitoring, tool call logging, infinite context support with automatic summarization, and hierarchical session relationships. Perfect for AI applications that need reliable session management.
35
+
36
+ ## 🚀 Quick Start
37
+
38
+ ### Installation Options
39
+
40
+ ```bash
41
+ # Basic installation (memory storage only)
42
+ pip install chuk-ai-session-manager
43
+
44
+ # With Redis support for production
45
+ pip install chuk-ai-session-manager[redis]
46
+
47
+ # With enhanced token counting
48
+ pip install chuk-ai-session-manager[tiktoken]
49
+
50
+ # Full installation with all optional features
51
+ pip install chuk-ai-session-manager[all]
52
+
53
+ # Development installation
54
+ pip install chuk-ai-session-manager[dev]
55
+ ```
56
+
57
+ ### Quick Example
58
+
59
+ ```python
60
+ from chuk_ai_session_manager import track_conversation
61
+
62
+ # Track any conversation automatically
63
+ session_id = await track_conversation(
64
+ user_message="What's the weather like?",
65
+ ai_response="I don't have access to real-time weather data.",
66
+ model="gpt-3.5-turbo",
67
+ provider="openai"
68
+ )
69
+
70
+ print(f"Conversation tracked in session: {session_id}")
71
+ ```
72
+
73
+ That's it! Zero configuration required.
74
+
75
+ ## ⚡ Major Features
76
+
77
+ ### 🎯 **Zero-Configuration Tracking**
78
+ ```python
79
+ from chuk_ai_session_manager import SessionManager
80
+
81
+ # Just start using it
82
+ sm = SessionManager()
83
+ await sm.user_says("Hello!")
84
+ await sm.ai_responds("Hi there!", model="gpt-4")
85
+
86
+ # Get stats instantly
87
+ stats = await sm.get_stats()
88
+ print(f"Tokens: {stats['total_tokens']}, Cost: ${stats['estimated_cost']:.4f}")
89
+ ```
90
+
91
+ ### 🔄 **Infinite Context**
92
+ ```python
93
+ # Automatically handles conversations longer than token limits
94
+ sm = SessionManager(infinite_context=True, token_threshold=4000)
95
+ await sm.user_says("Tell me about the history of computing...")
96
+ await sm.ai_responds("Computing history begins with...", model="gpt-4")
97
+ # Session will auto-segment when limits are reached
98
+ ```
99
+
100
+ ### ⚙️ **Storage Backends**
101
+
102
+ | Installation | Storage | Use Case | Performance |
103
+ |-------------|---------|----------|-------------|
104
+ | `pip install chuk-ai-session-manager` | Memory | Development, testing | 1.8M ops/sec |
105
+ | `pip install chuk-ai-session-manager[redis]` | Redis | Production, persistence | 20K ops/sec |
106
+
107
+ ### 🛠️ **Tool Integration**
108
+ ```python
109
+ # Automatic tool call tracking
110
+ await sm.tool_used(
111
+ tool_name="calculator",
112
+ arguments={"operation": "add", "a": 5, "b": 3},
113
+ result={"result": 8}
114
+ )
115
+ ```
116
+
117
+ ## 💡 Common Use Cases
118
+
119
+ ### Web App Conversation Tracking
120
+ ```python
121
+ from chuk_ai_session_manager import track_conversation
122
+
123
+ # In your chat endpoint
124
+ session_id = await track_conversation(
125
+ user_message=request.message,
126
+ ai_response=ai_response,
127
+ model="gpt-4",
128
+ provider="openai",
129
+ session_id=request.session_id # Continue existing conversation
130
+ )
131
+ ```
132
+
133
+ ### LLM Wrapper with Automatic Tracking
134
+ ```python
135
+ from chuk_ai_session_manager import track_llm_call
136
+ import openai
137
+
138
+ async def my_openai_call(prompt):
139
+ response = await openai.chat.completions.create(
140
+ model="gpt-3.5-turbo",
141
+ messages=[{"role": "user", "content": prompt}]
142
+ )
143
+ return response.choices[0].message.content
144
+
145
+ # Automatically tracked
146
+ response, session_id = await track_llm_call(
147
+ user_input="Explain machine learning",
148
+ llm_function=my_openai_call,
149
+ model="gpt-3.5-turbo",
150
+ provider="openai"
151
+ )
152
+ ```
153
+
154
+ ### Long Conversations with Auto-Segmentation
155
+ ```python
156
+ from chuk_ai_session_manager import track_infinite_conversation
157
+
158
+ # Start a conversation
159
+ session_id = await track_infinite_conversation(
160
+ user_message="Tell me about the history of computing",
161
+ ai_response="Computing history begins with ancient calculating devices...",
162
+ model="gpt-4",
163
+ token_threshold=4000 # Auto-segment after 4000 tokens
164
+ )
165
+
166
+ # Continue the conversation - will auto-segment if needed
167
+ session_id = await track_infinite_conversation(
168
+ user_message="What about quantum computers?",
169
+ ai_response="Quantum computing represents a fundamental shift...",
170
+ session_id=session_id,
171
+ model="gpt-4"
172
+ )
173
+ ```
174
+
175
+ ## 🔧 Configuration
176
+
177
+ ### Storage Configuration
178
+
179
+ ```bash
180
+ # Memory provider (default) - fast, no persistence
181
+ export SESSION_PROVIDER=memory
182
+
183
+ # Redis provider - persistent, production-ready (requires redis extra)
184
+ export SESSION_PROVIDER=redis
185
+ export SESSION_REDIS_URL=redis://localhost:6379/0
186
+ ```
187
+
188
+ ### Installation Matrix
189
+
190
+ | Command | Memory | Redis | Token Counting | Use Case |
191
+ |---------|--------|-------|----------------|----------|
192
+ | `pip install chuk-ai-session-manager` | ✅ | ❌ | Basic | Development |
193
+ | `pip install chuk-ai-session-manager[redis]` | ✅ | ✅ | Basic | Production |
194
+ | `pip install chuk-ai-session-manager[tiktoken]` | ✅ | ❌ | Enhanced | Better accuracy |
195
+ | `pip install chuk-ai-session-manager[all]` | ✅ | ✅ | Enhanced | Full features |
196
+
197
+ ## 📊 Monitoring & Analytics
198
+
199
+ ```python
200
+ # Get comprehensive session analytics
201
+ stats = await sm.get_stats(include_all_segments=True)
202
+
203
+ print(f"""
204
+ 🚀 Session Analytics Dashboard
205
+ ============================
206
+ Session ID: {stats['session_id']}
207
+ Total Messages: {stats['total_messages']}
208
+ User Messages: {stats['user_messages']}
209
+ AI Messages: {stats['ai_messages']}
210
+ Tool Calls: {stats['tool_calls']}
211
+ Total Tokens: {stats['total_tokens']}
212
+ Total Cost: ${stats['estimated_cost']:.6f}
213
+ Session Segments: {stats.get('session_segments', 1)}
214
+ """)
215
+ ```
216
+
217
+ ## 🏗️ Why CHUK AI Session Manager?
218
+
219
+ - **Zero Configuration**: Start tracking conversations in 3 lines of code
220
+ - **Infinite Context**: Never worry about token limits again
221
+ - **Universal**: Works with any LLM provider (OpenAI, Anthropic, etc.)
222
+ - **Production Ready**: Built-in persistence, monitoring, and error handling
223
+ - **Token Aware**: Automatic cost tracking across all providers
224
+ - **Tool Friendly**: Seamless tool call logging and retry mechanisms
225
+
226
+ ## 🛡️ Error Handling
227
+
228
+ ```python
229
+ from chuk_ai_session_manager import (
230
+ SessionManagerError,
231
+ SessionNotFound,
232
+ TokenLimitExceeded
233
+ )
234
+
235
+ try:
236
+ session_id = await track_conversation("Hello", "Hi there")
237
+ except SessionNotFound as e:
238
+ print(f"Session not found: {e}")
239
+ except TokenLimitExceeded as e:
240
+ print(f"Token limit exceeded: {e}")
241
+ except SessionManagerError as e:
242
+ print(f"General session error: {e}")
243
+ ```
244
+
245
+ ## 🔄 Dependencies
246
+
247
+ - **Required**: `chuk-sessions` (session storage), `pydantic` (data models), `chuk-tool-processor` (tool integration)
248
+ - **Optional**: `redis` (Redis storage), `tiktoken` (accurate token counting)
249
+
250
+ ## 📄 License
251
+
252
+ MIT License - build amazing AI applications with confidence!
253
+
254
+ ---
255
+
256
+ **Ready to build better AI applications?**
257
+
258
+ ```bash
259
+ pip install chuk-ai-session-manager
260
+ ```
261
+
262
+ **Start tracking conversations in 30 seconds!**
@@ -0,0 +1,236 @@
1
+ # CHUK AI Session Manager
2
+
3
+ **A powerful session management system for AI applications**
4
+
5
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ Automatic conversation tracking, token usage monitoring, tool call logging, infinite context support with automatic summarization, and hierarchical session relationships. Perfect for AI applications that need reliable session management.
9
+
10
+ ## 🚀 Quick Start
11
+
12
+ ### Installation Options
13
+
14
+ ```bash
15
+ # Basic installation (memory storage only)
16
+ pip install chuk-ai-session-manager
17
+
18
+ # With Redis support for production
19
+ pip install chuk-ai-session-manager[redis]
20
+
21
+ # With enhanced token counting
22
+ pip install chuk-ai-session-manager[tiktoken]
23
+
24
+ # Full installation with all optional features
25
+ pip install chuk-ai-session-manager[all]
26
+
27
+ # Development installation
28
+ pip install chuk-ai-session-manager[dev]
29
+ ```
30
+
31
+ ### Quick Example
32
+
33
+ ```python
34
+ from chuk_ai_session_manager import track_conversation
35
+
36
+ # Track any conversation automatically
37
+ session_id = await track_conversation(
38
+ user_message="What's the weather like?",
39
+ ai_response="I don't have access to real-time weather data.",
40
+ model="gpt-3.5-turbo",
41
+ provider="openai"
42
+ )
43
+
44
+ print(f"Conversation tracked in session: {session_id}")
45
+ ```
46
+
47
+ That's it! Zero configuration required.
48
+
49
+ ## ⚡ Major Features
50
+
51
+ ### 🎯 **Zero-Configuration Tracking**
52
+ ```python
53
+ from chuk_ai_session_manager import SessionManager
54
+
55
+ # Just start using it
56
+ sm = SessionManager()
57
+ await sm.user_says("Hello!")
58
+ await sm.ai_responds("Hi there!", model="gpt-4")
59
+
60
+ # Get stats instantly
61
+ stats = await sm.get_stats()
62
+ print(f"Tokens: {stats['total_tokens']}, Cost: ${stats['estimated_cost']:.4f}")
63
+ ```
64
+
65
+ ### 🔄 **Infinite Context**
66
+ ```python
67
+ # Automatically handles conversations longer than token limits
68
+ sm = SessionManager(infinite_context=True, token_threshold=4000)
69
+ await sm.user_says("Tell me about the history of computing...")
70
+ await sm.ai_responds("Computing history begins with...", model="gpt-4")
71
+ # Session will auto-segment when limits are reached
72
+ ```
73
+
74
+ ### ⚙️ **Storage Backends**
75
+
76
+ | Installation | Storage | Use Case | Performance |
77
+ |-------------|---------|----------|-------------|
78
+ | `pip install chuk-ai-session-manager` | Memory | Development, testing | 1.8M ops/sec |
79
+ | `pip install chuk-ai-session-manager[redis]` | Redis | Production, persistence | 20K ops/sec |
80
+
81
+ ### 🛠️ **Tool Integration**
82
+ ```python
83
+ # Automatic tool call tracking
84
+ await sm.tool_used(
85
+ tool_name="calculator",
86
+ arguments={"operation": "add", "a": 5, "b": 3},
87
+ result={"result": 8}
88
+ )
89
+ ```
90
+
91
+ ## 💡 Common Use Cases
92
+
93
+ ### Web App Conversation Tracking
94
+ ```python
95
+ from chuk_ai_session_manager import track_conversation
96
+
97
+ # In your chat endpoint
98
+ session_id = await track_conversation(
99
+ user_message=request.message,
100
+ ai_response=ai_response,
101
+ model="gpt-4",
102
+ provider="openai",
103
+ session_id=request.session_id # Continue existing conversation
104
+ )
105
+ ```
106
+
107
+ ### LLM Wrapper with Automatic Tracking
108
+ ```python
109
+ from chuk_ai_session_manager import track_llm_call
110
+ import openai
111
+
112
+ async def my_openai_call(prompt):
113
+ response = await openai.chat.completions.create(
114
+ model="gpt-3.5-turbo",
115
+ messages=[{"role": "user", "content": prompt}]
116
+ )
117
+ return response.choices[0].message.content
118
+
119
+ # Automatically tracked
120
+ response, session_id = await track_llm_call(
121
+ user_input="Explain machine learning",
122
+ llm_function=my_openai_call,
123
+ model="gpt-3.5-turbo",
124
+ provider="openai"
125
+ )
126
+ ```
127
+
128
+ ### Long Conversations with Auto-Segmentation
129
+ ```python
130
+ from chuk_ai_session_manager import track_infinite_conversation
131
+
132
+ # Start a conversation
133
+ session_id = await track_infinite_conversation(
134
+ user_message="Tell me about the history of computing",
135
+ ai_response="Computing history begins with ancient calculating devices...",
136
+ model="gpt-4",
137
+ token_threshold=4000 # Auto-segment after 4000 tokens
138
+ )
139
+
140
+ # Continue the conversation - will auto-segment if needed
141
+ session_id = await track_infinite_conversation(
142
+ user_message="What about quantum computers?",
143
+ ai_response="Quantum computing represents a fundamental shift...",
144
+ session_id=session_id,
145
+ model="gpt-4"
146
+ )
147
+ ```
148
+
149
+ ## 🔧 Configuration
150
+
151
+ ### Storage Configuration
152
+
153
+ ```bash
154
+ # Memory provider (default) - fast, no persistence
155
+ export SESSION_PROVIDER=memory
156
+
157
+ # Redis provider - persistent, production-ready (requires redis extra)
158
+ export SESSION_PROVIDER=redis
159
+ export SESSION_REDIS_URL=redis://localhost:6379/0
160
+ ```
161
+
162
+ ### Installation Matrix
163
+
164
+ | Command | Memory | Redis | Token Counting | Use Case |
165
+ |---------|--------|-------|----------------|----------|
166
+ | `pip install chuk-ai-session-manager` | ✅ | ❌ | Basic | Development |
167
+ | `pip install chuk-ai-session-manager[redis]` | ✅ | ✅ | Basic | Production |
168
+ | `pip install chuk-ai-session-manager[tiktoken]` | ✅ | ❌ | Enhanced | Better accuracy |
169
+ | `pip install chuk-ai-session-manager[all]` | ✅ | ✅ | Enhanced | Full features |
170
+
171
+ ## 📊 Monitoring & Analytics
172
+
173
+ ```python
174
+ # Get comprehensive session analytics
175
+ stats = await sm.get_stats(include_all_segments=True)
176
+
177
+ print(f"""
178
+ 🚀 Session Analytics Dashboard
179
+ ============================
180
+ Session ID: {stats['session_id']}
181
+ Total Messages: {stats['total_messages']}
182
+ User Messages: {stats['user_messages']}
183
+ AI Messages: {stats['ai_messages']}
184
+ Tool Calls: {stats['tool_calls']}
185
+ Total Tokens: {stats['total_tokens']}
186
+ Total Cost: ${stats['estimated_cost']:.6f}
187
+ Session Segments: {stats.get('session_segments', 1)}
188
+ """)
189
+ ```
190
+
191
+ ## 🏗️ Why CHUK AI Session Manager?
192
+
193
+ - **Zero Configuration**: Start tracking conversations in 3 lines of code
194
+ - **Infinite Context**: Never worry about token limits again
195
+ - **Universal**: Works with any LLM provider (OpenAI, Anthropic, etc.)
196
+ - **Production Ready**: Built-in persistence, monitoring, and error handling
197
+ - **Token Aware**: Automatic cost tracking across all providers
198
+ - **Tool Friendly**: Seamless tool call logging and retry mechanisms
199
+
200
+ ## 🛡️ Error Handling
201
+
202
+ ```python
203
+ from chuk_ai_session_manager import (
204
+ SessionManagerError,
205
+ SessionNotFound,
206
+ TokenLimitExceeded
207
+ )
208
+
209
+ try:
210
+ session_id = await track_conversation("Hello", "Hi there")
211
+ except SessionNotFound as e:
212
+ print(f"Session not found: {e}")
213
+ except TokenLimitExceeded as e:
214
+ print(f"Token limit exceeded: {e}")
215
+ except SessionManagerError as e:
216
+ print(f"General session error: {e}")
217
+ ```
218
+
219
+ ## 🔄 Dependencies
220
+
221
+ - **Required**: `chuk-sessions` (session storage), `pydantic` (data models), `chuk-tool-processor` (tool integration)
222
+ - **Optional**: `redis` (Redis storage), `tiktoken` (accurate token counting)
223
+
224
+ ## 📄 License
225
+
226
+ MIT License - build amazing AI applications with confidence!
227
+
228
+ ---
229
+
230
+ **Ready to build better AI applications?**
231
+
232
+ ```bash
233
+ pip install chuk-ai-session-manager
234
+ ```
235
+
236
+ **Start tracking conversations in 30 seconds!**
@@ -4,30 +4,45 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chuk-ai-session-manager"
7
- version = "0.5"
7
+ version = "0.7.1"
8
8
  description = "Session manager for AI applications"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
11
+
12
+ # Core dependencies - only what's absolutely required
11
13
  dependencies = [
12
- "chuk-sessions>=0.3",
13
- "chuk-tool-processor>=0.4.1",
14
+ "chuk-sessions>=0.4.2",
15
+ "chuk-tool-processor>=0.4.1",
14
16
  "pydantic>=2.11.3",
15
17
  ]
16
18
 
17
19
  # Optional dependencies
18
20
  [project.optional-dependencies]
21
+ # Redis support (passes through to chuk-sessions)
22
+ redis = [
23
+ "chuk-sessions[redis]>=0.4.1",
24
+ "redis>=4.0.0"
25
+ ]
26
+
27
+ # Token counting for better accuracy
19
28
  tiktoken = ["tiktoken>=0.9.0"]
20
- redis = ["redis>=4.0.0"]
29
+
30
+ # Development dependencies
21
31
  dev = [
22
32
  "pytest>=7.0.0",
23
33
  "pytest-cov>=4.0.0",
24
- "pytest-asyncio>=0.21.0", # Essential for async tests
25
- "redis>=4.0.0",
34
+ "pytest-asyncio>=0.21.0",
26
35
  "black>=23.0.0",
27
36
  "isort>=5.12.0",
28
37
  "mypy>=1.0.0",
29
38
  ]
30
- full = []
39
+
40
+ # All optional features
41
+ all = [
42
+ "chuk-sessions[redis]>=0.4",
43
+ "redis>=4.0.0",
44
+ "tiktoken>=0.9.0",
45
+ ]
31
46
 
32
47
  # Configure setuptools for src/ layout
33
48
  [tool.setuptools.packages.find]
@@ -28,12 +28,25 @@ Infinite Context Example:
28
28
  await sm.user_says("Tell me about machine learning")
29
29
  await sm.ai_responds("Machine learning is...", model="gpt-4")
30
30
  # Session will auto-segment when limits are reached
31
+
32
+ Storage Configuration:
33
+ # Default: Memory storage (no Redis required)
34
+ pip install chuk-ai-session-manager
35
+
36
+ # Redis: For production persistence
37
+ pip install chuk-ai-session-manager[redis]
38
+ export SESSION_PROVIDER=redis
39
+ export SESSION_REDIS_URL=redis://localhost:6379/0
40
+
41
+ # Environment variables:
42
+ SESSION_PROVIDER=memory (default - fast, no persistence)
43
+ SESSION_PROVIDER=redis (persistent - requires [redis] extra)
31
44
  """
32
45
 
33
46
  import logging
34
47
 
35
48
  # Package version
36
- __version__ = "0.4"
49
+ __version__ = "0.5"
37
50
 
38
51
  # Set up package-level logger
39
52
  logger = logging.getLogger(__name__)
@@ -103,6 +116,11 @@ def configure_storage(sandbox_id: str = "chuk-ai-session-manager",
103
116
 
104
117
  Returns:
105
118
  True if configuration was successful, False otherwise
119
+
120
+ Note:
121
+ Storage provider is controlled by SESSION_PROVIDER environment variable:
122
+ - memory (default): Fast, no persistence, no extra dependencies
123
+ - redis: Persistent, requires pip install chuk-ai-session-manager[redis]
106
124
  """
107
125
  try:
108
126
  setup_chuk_sessions_storage(
@@ -128,6 +146,22 @@ def is_available() -> dict:
128
146
  Returns:
129
147
  Dictionary showing availability of each component
130
148
  """
149
+ # Check if Redis is available
150
+ redis_available = False
151
+ try:
152
+ import redis
153
+ redis_available = True
154
+ except ImportError:
155
+ pass
156
+
157
+ # Check if tiktoken is available for enhanced token counting
158
+ tiktoken_available = False
159
+ try:
160
+ import tiktoken
161
+ tiktoken_available = True
162
+ except ImportError:
163
+ pass
164
+
131
165
  return {
132
166
  "core_enums": True,
133
167
  "core_models": True,
@@ -139,9 +173,39 @@ def is_available() -> dict:
139
173
  "token_tracking": True,
140
174
  "exceptions": True,
141
175
  "session_manager": True,
176
+ "redis_support": redis_available,
177
+ "enhanced_token_counting": tiktoken_available,
142
178
  }
143
179
 
144
180
 
181
+ def get_storage_info() -> dict:
182
+ """
183
+ Get information about the current storage configuration.
184
+
185
+ Returns:
186
+ Dictionary with storage configuration details
187
+ """
188
+ import os
189
+ from chuk_ai_session_manager.session_storage import get_backend
190
+
191
+ try:
192
+ backend = get_backend()
193
+ stats = backend.get_stats()
194
+
195
+ return {
196
+ "provider": os.getenv("SESSION_PROVIDER", "memory"),
197
+ "backend": stats.get("backend", "unknown"),
198
+ "sandbox_id": stats.get("sandbox_id", "unknown"),
199
+ "redis_url": os.getenv("SESSION_REDIS_URL", "not_set"),
200
+ "stats": stats
201
+ }
202
+ except Exception as e:
203
+ return {
204
+ "provider": os.getenv("SESSION_PROVIDER", "memory"),
205
+ "error": str(e)
206
+ }
207
+
208
+
145
209
  # Main exports - everything should be available
146
210
  __all__ = [
147
211
  # Version and utilities
@@ -149,6 +213,7 @@ __all__ = [
149
213
  "get_version",
150
214
  "is_available",
151
215
  "configure_storage",
216
+ "get_storage_info",
152
217
 
153
218
  # Core enums
154
219
  "EventSource",
@@ -201,5 +266,10 @@ try:
201
266
  except Exception as e:
202
267
  logger.debug(f"Auto-setup skipped: {e}")
203
268
 
204
- # Log successful import
205
- logger.debug(f"CHUK AI Session Manager v{__version__} imported successfully")
269
+ # Log successful import with storage info
270
+ try:
271
+ storage_info = get_storage_info()
272
+ provider = storage_info.get("provider", "unknown")
273
+ logger.debug(f"CHUK AI Session Manager v{__version__} imported successfully (storage: {provider})")
274
+ except Exception:
275
+ logger.debug(f"CHUK AI Session Manager v{__version__} imported successfully")