socratic-learning 0.1.0__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 (34) hide show
  1. socratic_learning-0.1.0/LICENSE +21 -0
  2. socratic_learning-0.1.0/PKG-INFO +209 -0
  3. socratic_learning-0.1.0/README.md +164 -0
  4. socratic_learning-0.1.0/pyproject.toml +105 -0
  5. socratic_learning-0.1.0/setup.cfg +4 -0
  6. socratic_learning-0.1.0/src/socratic_learning/__init__.py +21 -0
  7. socratic_learning-0.1.0/src/socratic_learning/analytics/__init__.py +13 -0
  8. socratic_learning-0.1.0/src/socratic_learning/analytics/aggregator.py +356 -0
  9. socratic_learning-0.1.0/src/socratic_learning/analytics/metrics_collector.py +118 -0
  10. socratic_learning-0.1.0/src/socratic_learning/analytics/pattern_detector.py +184 -0
  11. socratic_learning-0.1.0/src/socratic_learning/analytics/reporter.py +373 -0
  12. socratic_learning-0.1.0/src/socratic_learning/core/__init__.py +13 -0
  13. socratic_learning-0.1.0/src/socratic_learning/core/interaction.py +78 -0
  14. socratic_learning-0.1.0/src/socratic_learning/core/metric.py +75 -0
  15. socratic_learning-0.1.0/src/socratic_learning/core/pattern.py +61 -0
  16. socratic_learning-0.1.0/src/socratic_learning/core/recommendation.py +70 -0
  17. socratic_learning-0.1.0/src/socratic_learning/feedback/__init__.py +9 -0
  18. socratic_learning-0.1.0/src/socratic_learning/feedback/analyzer.py +252 -0
  19. socratic_learning-0.1.0/src/socratic_learning/feedback/collector.py +217 -0
  20. socratic_learning-0.1.0/src/socratic_learning/recommendations/__init__.py +11 -0
  21. socratic_learning-0.1.0/src/socratic_learning/recommendations/engine.py +248 -0
  22. socratic_learning-0.1.0/src/socratic_learning/recommendations/export.py +302 -0
  23. socratic_learning-0.1.0/src/socratic_learning/recommendations/rules.py +318 -0
  24. socratic_learning-0.1.0/src/socratic_learning/storage/__init__.py +9 -0
  25. socratic_learning-0.1.0/src/socratic_learning/storage/base.py +111 -0
  26. socratic_learning-0.1.0/src/socratic_learning/storage/sqlite_store.py +658 -0
  27. socratic_learning-0.1.0/src/socratic_learning/tracking/__init__.py +9 -0
  28. socratic_learning-0.1.0/src/socratic_learning/tracking/logger.py +103 -0
  29. socratic_learning-0.1.0/src/socratic_learning/tracking/session.py +55 -0
  30. socratic_learning-0.1.0/src/socratic_learning.egg-info/PKG-INFO +209 -0
  31. socratic_learning-0.1.0/src/socratic_learning.egg-info/SOURCES.txt +32 -0
  32. socratic_learning-0.1.0/src/socratic_learning.egg-info/dependency_links.txt +1 -0
  33. socratic_learning-0.1.0/src/socratic_learning.egg-info/requires.txt +25 -0
  34. socratic_learning-0.1.0/src/socratic_learning.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Socratic Learning Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,209 @@
1
+ Metadata-Version: 2.4
2
+ Name: socratic-learning
3
+ Version: 0.1.0
4
+ Summary: Continuous learning system that tracks agent interactions, detects patterns, and provides improvement recommendations.
5
+ Author: Socratic Learning Contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/Nireus79/Socratic-learning
8
+ Project-URL: Repository, https://github.com/Nireus79/Socratic-learning
9
+ Project-URL: Documentation, https://github.com/Nireus79/Socratic-learning#readme
10
+ Project-URL: Issues, https://github.com/Nireus79/Socratic-learning/issues
11
+ Keywords: learning,tracking,agent,pattern-detection,recommendations,fine-tuning,analytics,socratic
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Information Technology
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: pydantic>=2.0.0
26
+ Provides-Extra: agents
27
+ Requires-Dist: socratic-agents>=0.1.0; extra == "agents"
28
+ Provides-Extra: nexus
29
+ Requires-Dist: socrates-nexus>=0.3.0; extra == "nexus"
30
+ Provides-Extra: openclaw
31
+ Provides-Extra: langchain
32
+ Requires-Dist: langchain>=0.1.0; extra == "langchain"
33
+ Provides-Extra: all
34
+ Requires-Dist: socratic-agents>=0.1.0; extra == "all"
35
+ Requires-Dist: socrates-nexus>=0.3.0; extra == "all"
36
+ Requires-Dist: langchain>=0.1.0; extra == "all"
37
+ Provides-Extra: dev
38
+ Requires-Dist: pytest>=7.0; extra == "dev"
39
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
40
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
41
+ Requires-Dist: black>=23.0; extra == "dev"
42
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
43
+ Requires-Dist: mypy>=1.0; extra == "dev"
44
+ Dynamic: license-file
45
+
46
+ # Socratic Learning
47
+
48
+ [![PyPI version](https://badge.fury.io/py/socratic-learning.svg)](https://badge.fury.io/py/socratic-learning)
49
+ [![Tests](https://github.com/Nireus79/Socratic-learning/workflows/Tests/badge.svg)](https://github.com/Nireus79/Socratic-learning/actions)
50
+ [![Code Quality](https://github.com/Nireus79/Socratic-learning/workflows/Code%20Quality/badge.svg)](https://github.com/Nireus79/Socratic-learning/actions)
51
+
52
+ A continuous learning system for AI agents that tracks interactions, detects patterns, and provides data-driven improvement recommendations.
53
+
54
+ ## Features
55
+
56
+ - **Interaction Tracking** - Capture and store all agent interactions with context
57
+ - **Pattern Detection** - Identify recurring patterns in agent behaviors and LLM outputs
58
+ - **Performance Metrics** - Monitor agent effectiveness with success rates, response times, costs
59
+ - **User Feedback Integration** - Collect and analyze user feedback on agent responses
60
+ - **Learning Recommendations** - Generate actionable improvement suggestions
61
+ - **Fine-Tuning Export** - Export interaction data for model fine-tuning
62
+ - **Analytics & Reporting** - JSON-based insights and metrics
63
+ - **Framework Integration** - Works with Openclaw and LangChain
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ # Core package
69
+ pip install socratic-learning
70
+
71
+ # With Socratic Agents integration
72
+ pip install socratic-learning[agents]
73
+
74
+ # With all optional dependencies
75
+ pip install socratic-learning[all]
76
+
77
+ # For development
78
+ pip install socratic-learning[dev]
79
+ ```
80
+
81
+ ## Quick Start
82
+
83
+ ```python
84
+ from socratic_learning import LearningManager
85
+ from socratic_agents import SocraticCounselor
86
+
87
+ # Initialize learning manager
88
+ learning = LearningManager(storage="sqlite", db_path="learning.db")
89
+
90
+ # Create a tracking session
91
+ session_id = learning.create_session(
92
+ user_id="user123",
93
+ context={"environment": "production"}
94
+ )
95
+
96
+ # Track agent interactions
97
+ counselor = SocraticCounselor()
98
+ result = counselor.guide("recursion", level="beginner")
99
+
100
+ learning.track_interaction(
101
+ session_id=session_id,
102
+ agent_name="SocraticCounselor",
103
+ input_data={"topic": "recursion", "level": "beginner"},
104
+ output_data=result,
105
+ model_name="claude-opus-4",
106
+ provider="anthropic",
107
+ input_tokens=150,
108
+ output_tokens=500,
109
+ duration_ms=1200.0,
110
+ )
111
+
112
+ # Add user feedback
113
+ learning.add_feedback(
114
+ interaction_id=interaction.interaction_id,
115
+ rating=5,
116
+ feedback="Very helpful explanation!"
117
+ )
118
+
119
+ # Get metrics
120
+ metrics = learning.get_metrics(agent_name="SocraticCounselor")
121
+ print(f"Success rate: {metrics.success_rate}%")
122
+ print(f"Avg rating: {metrics.avg_rating}/5")
123
+
124
+ # Detect patterns
125
+ patterns = learning.detect_patterns(agent_name="SocraticCounselor")
126
+ for pattern in patterns:
127
+ print(f"Pattern: {pattern.name} (confidence: {pattern.confidence})")
128
+
129
+ # Get recommendations
130
+ recommendations = learning.get_recommendations(agent_name="SocraticCounselor")
131
+ for rec in recommendations:
132
+ print(f"Recommendation: {rec.title}")
133
+
134
+ # Export for fine-tuning
135
+ learning.export_for_finetuning(
136
+ output_path="finetuning_data.jsonl",
137
+ agent_name="SocraticCounselor",
138
+ min_rating=4,
139
+ format="openai"
140
+ )
141
+ ```
142
+
143
+ ## Core Concepts
144
+
145
+ ### Interaction
146
+ Represents a single agent interaction with input, output, performance metrics, and optional user feedback.
147
+
148
+ ### Pattern
149
+ A detected recurring pattern in agent behaviors (e.g., error patterns, topic-specific behaviors).
150
+
151
+ ### Metric
152
+ Aggregated performance metrics (success rate, average response time, user satisfaction, costs).
153
+
154
+ ### Recommendation
155
+ An actionable improvement suggestion based on detected patterns and metrics.
156
+
157
+ ## Architecture
158
+
159
+ - **Core Models** - Dataclass-based models with serialization
160
+ - **Storage Layer** - Abstract interface with SQLite backend
161
+ - **Tracking** - Interaction logger with session management
162
+ - **Analytics** - Pattern detection and metrics collection
163
+ - **Integrations** - Openclaw skills and LangChain tools
164
+
165
+ ## Documentation
166
+
167
+ See [examples/](examples/) for complete working examples.
168
+
169
+ ## Testing
170
+
171
+ ```bash
172
+ # Run all tests
173
+ pytest
174
+
175
+ # Run with coverage
176
+ pytest --cov=src/socratic_learning --cov-report=html
177
+
178
+ # Run specific test file
179
+ pytest tests/unit/test_models.py -v
180
+ ```
181
+
182
+ ## Code Quality
183
+
184
+ ```bash
185
+ # Format with Black
186
+ black src/ tests/
187
+
188
+ # Lint with Ruff
189
+ ruff check src/ tests/
190
+
191
+ # Type check with MyPy
192
+ mypy src/
193
+ ```
194
+
195
+ ## License
196
+
197
+ MIT
198
+
199
+ ## Contributing
200
+
201
+ Contributions welcome! Please open an issue or submit a PR.
202
+
203
+ ## Status
204
+
205
+ **Phase 1** - Core foundation complete (v0.1.0 development)
206
+ - ✅ Core data models
207
+ - ✅ SQLite storage
208
+ - ✅ Unit tests
209
+ - 🚀 Phase 2-6 planned
@@ -0,0 +1,164 @@
1
+ # Socratic Learning
2
+
3
+ [![PyPI version](https://badge.fury.io/py/socratic-learning.svg)](https://badge.fury.io/py/socratic-learning)
4
+ [![Tests](https://github.com/Nireus79/Socratic-learning/workflows/Tests/badge.svg)](https://github.com/Nireus79/Socratic-learning/actions)
5
+ [![Code Quality](https://github.com/Nireus79/Socratic-learning/workflows/Code%20Quality/badge.svg)](https://github.com/Nireus79/Socratic-learning/actions)
6
+
7
+ A continuous learning system for AI agents that tracks interactions, detects patterns, and provides data-driven improvement recommendations.
8
+
9
+ ## Features
10
+
11
+ - **Interaction Tracking** - Capture and store all agent interactions with context
12
+ - **Pattern Detection** - Identify recurring patterns in agent behaviors and LLM outputs
13
+ - **Performance Metrics** - Monitor agent effectiveness with success rates, response times, costs
14
+ - **User Feedback Integration** - Collect and analyze user feedback on agent responses
15
+ - **Learning Recommendations** - Generate actionable improvement suggestions
16
+ - **Fine-Tuning Export** - Export interaction data for model fine-tuning
17
+ - **Analytics & Reporting** - JSON-based insights and metrics
18
+ - **Framework Integration** - Works with Openclaw and LangChain
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ # Core package
24
+ pip install socratic-learning
25
+
26
+ # With Socratic Agents integration
27
+ pip install socratic-learning[agents]
28
+
29
+ # With all optional dependencies
30
+ pip install socratic-learning[all]
31
+
32
+ # For development
33
+ pip install socratic-learning[dev]
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ```python
39
+ from socratic_learning import LearningManager
40
+ from socratic_agents import SocraticCounselor
41
+
42
+ # Initialize learning manager
43
+ learning = LearningManager(storage="sqlite", db_path="learning.db")
44
+
45
+ # Create a tracking session
46
+ session_id = learning.create_session(
47
+ user_id="user123",
48
+ context={"environment": "production"}
49
+ )
50
+
51
+ # Track agent interactions
52
+ counselor = SocraticCounselor()
53
+ result = counselor.guide("recursion", level="beginner")
54
+
55
+ learning.track_interaction(
56
+ session_id=session_id,
57
+ agent_name="SocraticCounselor",
58
+ input_data={"topic": "recursion", "level": "beginner"},
59
+ output_data=result,
60
+ model_name="claude-opus-4",
61
+ provider="anthropic",
62
+ input_tokens=150,
63
+ output_tokens=500,
64
+ duration_ms=1200.0,
65
+ )
66
+
67
+ # Add user feedback
68
+ learning.add_feedback(
69
+ interaction_id=interaction.interaction_id,
70
+ rating=5,
71
+ feedback="Very helpful explanation!"
72
+ )
73
+
74
+ # Get metrics
75
+ metrics = learning.get_metrics(agent_name="SocraticCounselor")
76
+ print(f"Success rate: {metrics.success_rate}%")
77
+ print(f"Avg rating: {metrics.avg_rating}/5")
78
+
79
+ # Detect patterns
80
+ patterns = learning.detect_patterns(agent_name="SocraticCounselor")
81
+ for pattern in patterns:
82
+ print(f"Pattern: {pattern.name} (confidence: {pattern.confidence})")
83
+
84
+ # Get recommendations
85
+ recommendations = learning.get_recommendations(agent_name="SocraticCounselor")
86
+ for rec in recommendations:
87
+ print(f"Recommendation: {rec.title}")
88
+
89
+ # Export for fine-tuning
90
+ learning.export_for_finetuning(
91
+ output_path="finetuning_data.jsonl",
92
+ agent_name="SocraticCounselor",
93
+ min_rating=4,
94
+ format="openai"
95
+ )
96
+ ```
97
+
98
+ ## Core Concepts
99
+
100
+ ### Interaction
101
+ Represents a single agent interaction with input, output, performance metrics, and optional user feedback.
102
+
103
+ ### Pattern
104
+ A detected recurring pattern in agent behaviors (e.g., error patterns, topic-specific behaviors).
105
+
106
+ ### Metric
107
+ Aggregated performance metrics (success rate, average response time, user satisfaction, costs).
108
+
109
+ ### Recommendation
110
+ An actionable improvement suggestion based on detected patterns and metrics.
111
+
112
+ ## Architecture
113
+
114
+ - **Core Models** - Dataclass-based models with serialization
115
+ - **Storage Layer** - Abstract interface with SQLite backend
116
+ - **Tracking** - Interaction logger with session management
117
+ - **Analytics** - Pattern detection and metrics collection
118
+ - **Integrations** - Openclaw skills and LangChain tools
119
+
120
+ ## Documentation
121
+
122
+ See [examples/](examples/) for complete working examples.
123
+
124
+ ## Testing
125
+
126
+ ```bash
127
+ # Run all tests
128
+ pytest
129
+
130
+ # Run with coverage
131
+ pytest --cov=src/socratic_learning --cov-report=html
132
+
133
+ # Run specific test file
134
+ pytest tests/unit/test_models.py -v
135
+ ```
136
+
137
+ ## Code Quality
138
+
139
+ ```bash
140
+ # Format with Black
141
+ black src/ tests/
142
+
143
+ # Lint with Ruff
144
+ ruff check src/ tests/
145
+
146
+ # Type check with MyPy
147
+ mypy src/
148
+ ```
149
+
150
+ ## License
151
+
152
+ MIT
153
+
154
+ ## Contributing
155
+
156
+ Contributions welcome! Please open an issue or submit a PR.
157
+
158
+ ## Status
159
+
160
+ **Phase 1** - Core foundation complete (v0.1.0 development)
161
+ - ✅ Core data models
162
+ - ✅ SQLite storage
163
+ - ✅ Unit tests
164
+ - 🚀 Phase 2-6 planned
@@ -0,0 +1,105 @@
1
+ [build-system]
2
+ requires = ["setuptools>=65.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "socratic-learning"
7
+ version = "0.1.0"
8
+ description = "Continuous learning system that tracks agent interactions, detects patterns, and provides improvement recommendations."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ authors = [
12
+ {name = "Socratic Learning Contributors"}
13
+ ]
14
+ keywords = [
15
+ "learning",
16
+ "tracking",
17
+ "agent",
18
+ "pattern-detection",
19
+ "recommendations",
20
+ "fine-tuning",
21
+ "analytics",
22
+ "socratic",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 3 - Alpha",
26
+ "Intended Audience :: Developers",
27
+ "Intended Audience :: Information Technology",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.9",
30
+ "Programming Language :: Python :: 3.10",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Topic :: Software Development :: Libraries :: Python Modules",
34
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
35
+ ]
36
+ requires-python = ">=3.9"
37
+
38
+ dependencies = [
39
+ "pydantic>=2.0.0",
40
+ ]
41
+
42
+ [project.optional-dependencies]
43
+ agents = ["socratic-agents>=0.1.0"]
44
+ nexus = ["socrates-nexus>=0.3.0"]
45
+ openclaw = []
46
+ langchain = ["langchain>=0.1.0"]
47
+
48
+ all = [
49
+ "socratic-agents>=0.1.0",
50
+ "socrates-nexus>=0.3.0",
51
+ "langchain>=0.1.0",
52
+ ]
53
+
54
+ dev = [
55
+ "pytest>=7.0",
56
+ "pytest-asyncio>=0.21.0",
57
+ "pytest-cov>=4.0",
58
+ "black>=23.0",
59
+ "ruff>=0.1.0",
60
+ "mypy>=1.0",
61
+ ]
62
+
63
+ [project.urls]
64
+ Homepage = "https://github.com/Nireus79/Socratic-learning"
65
+ Repository = "https://github.com/Nireus79/Socratic-learning"
66
+ Documentation = "https://github.com/Nireus79/Socratic-learning#readme"
67
+ Issues = "https://github.com/Nireus79/Socratic-learning/issues"
68
+
69
+ [tool.setuptools]
70
+ package-dir = {"" = "src"}
71
+
72
+ [tool.setuptools.packages]
73
+ find = {where = ["src"]}
74
+
75
+ [tool.pytest.ini_options]
76
+ testpaths = ["tests"]
77
+ python_files = "test_*.py"
78
+ python_classes = "Test*"
79
+ python_functions = "test_*"
80
+ markers = [
81
+ "unit: Unit tests",
82
+ "integration: Integration tests",
83
+ ]
84
+ addopts = "-v --strict-markers"
85
+
86
+ [tool.black]
87
+ line-length = 100
88
+ target-version = ["py39"]
89
+
90
+ [tool.ruff]
91
+ line-length = 100
92
+ target-version = "py39"
93
+
94
+ [tool.ruff.lint]
95
+ select = ["E", "F", "W", "I"]
96
+ ignore = ["E501"]
97
+
98
+ [tool.mypy]
99
+ python_version = "3.10"
100
+ warn_return_any = false
101
+ warn_unused_configs = true
102
+ disallow_untyped_defs = false
103
+ disallow_incomplete_defs = false
104
+ ignore_missing_imports = true
105
+ follow_imports = "silent"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,21 @@
1
+ """Socratic Learning - Continuous learning system for AI agents."""
2
+
3
+ from socratic_learning.analytics import MetricsCollector, PatternDetector
4
+ from socratic_learning.core import Interaction, Metric, Pattern, Recommendation
5
+ from socratic_learning.storage import BaseLearningStore, SQLiteLearningStore
6
+ from socratic_learning.tracking import InteractionLogger, Session
7
+
8
+ __version__ = "0.1.0"
9
+
10
+ __all__ = [
11
+ "Interaction",
12
+ "Pattern",
13
+ "Metric",
14
+ "Recommendation",
15
+ "BaseLearningStore",
16
+ "SQLiteLearningStore",
17
+ "Session",
18
+ "InteractionLogger",
19
+ "MetricsCollector",
20
+ "PatternDetector",
21
+ ]
@@ -0,0 +1,13 @@
1
+ """Analytics and metrics for Socratic Learning."""
2
+
3
+ from socratic_learning.analytics.aggregator import DataAggregator
4
+ from socratic_learning.analytics.metrics_collector import MetricsCollector
5
+ from socratic_learning.analytics.pattern_detector import PatternDetector
6
+ from socratic_learning.analytics.reporter import ReportGenerator
7
+
8
+ __all__ = [
9
+ "MetricsCollector",
10
+ "PatternDetector",
11
+ "DataAggregator",
12
+ "ReportGenerator",
13
+ ]