socratic-nexus 0.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.
- socratic_nexus-0.3.1/LICENSE +21 -0
- socratic_nexus-0.3.1/PKG-INFO +228 -0
- socratic_nexus-0.3.1/README.md +163 -0
- socratic_nexus-0.3.1/pyproject.toml +164 -0
- socratic_nexus-0.3.1/setup.cfg +4 -0
- socratic_nexus-0.3.1/src/socrates_nexus/__init__.py +89 -0
- socratic_nexus-0.3.1/src/socrates_nexus/async_client.py +184 -0
- socratic_nexus-0.3.1/src/socrates_nexus/client.py +186 -0
- socratic_nexus-0.3.1/src/socrates_nexus/deduplication.py +323 -0
- socratic_nexus-0.3.1/src/socrates_nexus/documentation.py +464 -0
- socratic_nexus-0.3.1/src/socrates_nexus/exceptions.py +99 -0
- socratic_nexus-0.3.1/src/socrates_nexus/integrations/__init__.py +14 -0
- socratic_nexus-0.3.1/src/socrates_nexus/integrations/langchain/__init__.py +20 -0
- socratic_nexus-0.3.1/src/socrates_nexus/integrations/langchain/llm.py +114 -0
- socratic_nexus-0.3.1/src/socrates_nexus/integrations/openclaw/__init__.py +9 -0
- socratic_nexus-0.3.1/src/socrates_nexus/integrations/openclaw/skill.py +136 -0
- socratic_nexus-0.3.1/src/socrates_nexus/models.py +187 -0
- socratic_nexus-0.3.1/src/socrates_nexus/performance.py +303 -0
- socratic_nexus-0.3.1/src/socrates_nexus/providers/__init__.py +15 -0
- socratic_nexus-0.3.1/src/socrates_nexus/providers/anthropic.py +361 -0
- socratic_nexus-0.3.1/src/socrates_nexus/providers/base.py +182 -0
- socratic_nexus-0.3.1/src/socrates_nexus/providers/google.py +430 -0
- socratic_nexus-0.3.1/src/socrates_nexus/providers/ollama.py +341 -0
- socratic_nexus-0.3.1/src/socrates_nexus/providers/openai.py +430 -0
- socratic_nexus-0.3.1/src/socrates_nexus/retry.py +106 -0
- socratic_nexus-0.3.1/src/socrates_nexus/streaming.py +113 -0
- socratic_nexus-0.3.1/src/socrates_nexus/utils/__init__.py +22 -0
- socratic_nexus-0.3.1/src/socrates_nexus/utils/cache.py +287 -0
- socratic_nexus-0.3.1/src/socrates_nexus/utils/images.py +112 -0
- socratic_nexus-0.3.1/src/socrates_nexus/vision.py +180 -0
- socratic_nexus-0.3.1/src/socratic_nexus.egg-info/PKG-INFO +228 -0
- socratic_nexus-0.3.1/src/socratic_nexus.egg-info/SOURCES.txt +49 -0
- socratic_nexus-0.3.1/src/socratic_nexus.egg-info/dependency_links.txt +1 -0
- socratic_nexus-0.3.1/src/socratic_nexus.egg-info/requires.txt +49 -0
- socratic_nexus-0.3.1/src/socratic_nexus.egg-info/top_level.txt +1 -0
- socratic_nexus-0.3.1/tests/test_async_client.py +216 -0
- socratic_nexus-0.3.1/tests/test_cache.py +348 -0
- socratic_nexus-0.3.1/tests/test_client.py +139 -0
- socratic_nexus-0.3.1/tests/test_client_integration.py +467 -0
- socratic_nexus-0.3.1/tests/test_deduplication.py +323 -0
- socratic_nexus-0.3.1/tests/test_documentation.py +443 -0
- socratic_nexus-0.3.1/tests/test_edge_cases.py +429 -0
- socratic_nexus-0.3.1/tests/test_exceptions.py +132 -0
- socratic_nexus-0.3.1/tests/test_integration.py +243 -0
- socratic_nexus-0.3.1/tests/test_integrations_langchain.py +440 -0
- socratic_nexus-0.3.1/tests/test_integrations_openclaw.py +415 -0
- socratic_nexus-0.3.1/tests/test_models.py +263 -0
- socratic_nexus-0.3.1/tests/test_retry.py +163 -0
- socratic_nexus-0.3.1/tests/test_streaming.py +406 -0
- socratic_nexus-0.3.1/tests/test_vision.py +253 -0
- socratic_nexus-0.3.1/tests/test_vision_and_tools.py +358 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Socrates Nexus 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,228 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: socratic-nexus
|
|
3
|
+
Version: 0.3.1
|
|
4
|
+
Summary: Universal LLM client for production - works with Claude, GPT-4, Gemini, Llama, and any LLM. Built-in integrations with Openclaw and LangChain.
|
|
5
|
+
Author: Socrates Nexus Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Nireus79/socrates-nexus
|
|
8
|
+
Project-URL: Documentation, https://github.com/Nireus79/socrates-nexus/tree/main/docs
|
|
9
|
+
Project-URL: Repository, https://github.com/Nireus79/socrates-nexus
|
|
10
|
+
Project-URL: Source Code, https://github.com/Nireus79/socrates-nexus
|
|
11
|
+
Project-URL: Bug Tracker, https://github.com/Nireus79/socrates-nexus/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/Nireus79/socrates-nexus/releases
|
|
13
|
+
Keywords: llm,ai,claude,gpt-4,gemini,ollama,llama,production,multi-llm,universal-client,retry,streaming,async,token-tracking
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
24
|
+
Requires-Python: >=3.9
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: pydantic>=2.0.0
|
|
28
|
+
Provides-Extra: anthropic
|
|
29
|
+
Requires-Dist: anthropic>=0.40.0; extra == "anthropic"
|
|
30
|
+
Provides-Extra: openai
|
|
31
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
32
|
+
Provides-Extra: google
|
|
33
|
+
Requires-Dist: google-generativeai>=0.1.0rc1; extra == "google"
|
|
34
|
+
Provides-Extra: ollama
|
|
35
|
+
Requires-Dist: ollama>=0.0.8; extra == "ollama"
|
|
36
|
+
Provides-Extra: huggingface
|
|
37
|
+
Requires-Dist: huggingface-hub>=0.17.0; extra == "huggingface"
|
|
38
|
+
Provides-Extra: openclaw
|
|
39
|
+
Provides-Extra: langchain
|
|
40
|
+
Requires-Dist: langchain>=0.1.0; extra == "langchain"
|
|
41
|
+
Provides-Extra: all
|
|
42
|
+
Requires-Dist: anthropic>=0.40.0; extra == "all"
|
|
43
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
44
|
+
Requires-Dist: ollama>=0.0.8; extra == "all"
|
|
45
|
+
Requires-Dist: huggingface-hub>=0.17.0; extra == "all"
|
|
46
|
+
Provides-Extra: integrations
|
|
47
|
+
Requires-Dist: langchain>=0.1.0; extra == "integrations"
|
|
48
|
+
Provides-Extra: full
|
|
49
|
+
Requires-Dist: anthropic>=0.40.0; extra == "full"
|
|
50
|
+
Requires-Dist: openai>=1.0.0; extra == "full"
|
|
51
|
+
Requires-Dist: google-generativeai>=0.3.0; extra == "full"
|
|
52
|
+
Requires-Dist: ollama>=0.0.8; extra == "full"
|
|
53
|
+
Requires-Dist: huggingface-hub>=0.17.0; extra == "full"
|
|
54
|
+
Requires-Dist: langchain>=0.1.0; extra == "full"
|
|
55
|
+
Provides-Extra: async
|
|
56
|
+
Requires-Dist: asyncio>=3.4.3; extra == "async"
|
|
57
|
+
Provides-Extra: dev
|
|
58
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
59
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
60
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
61
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
62
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
63
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
64
|
+
Dynamic: license-file
|
|
65
|
+
|
|
66
|
+
# Socratic Nexus (socrates-nexus)
|
|
67
|
+
|
|
68
|
+
Universal LLM abstraction layer providing unified access to multiple AI providers
|
|
69
|
+
|
|
70
|
+
## Overview
|
|
71
|
+
|
|
72
|
+
socrates-nexus is a specialized component of the Socratic ecosystem that provides comprehensive functionality for universal llm abstraction layer providing unified access to multiple ai providers. It offers a production-ready, well-tested solution for integrating into larger Socratic systems.
|
|
73
|
+
|
|
74
|
+
## Key Features
|
|
75
|
+
|
|
76
|
+
- Multi-provider support
|
|
77
|
+
- Unified client interface
|
|
78
|
+
- Async/sync API support
|
|
79
|
+
- Model standardization
|
|
80
|
+
|
|
81
|
+
## Installation
|
|
82
|
+
|
|
83
|
+
### Prerequisites
|
|
84
|
+
- Python 3.8+
|
|
85
|
+
- pip or poetry package manager
|
|
86
|
+
|
|
87
|
+
### Via pip
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install socrates-nexus
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Via poetry
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
poetry add socrates-nexus
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### From source
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
git clone https://github.com/socratic-ai/socrates-nexus.git
|
|
103
|
+
cd socrates-nexus
|
|
104
|
+
pip install -e .
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Quick Start
|
|
108
|
+
|
|
109
|
+
### Basic Usage
|
|
110
|
+
|
|
111
|
+
```python
|
|
112
|
+
from socrates_nexus import Client
|
|
113
|
+
|
|
114
|
+
# Initialize the component
|
|
115
|
+
client = Client()
|
|
116
|
+
|
|
117
|
+
# Perform basic operation
|
|
118
|
+
result = client.process()
|
|
119
|
+
print(result)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Configuration
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
from socrates_nexus import Client
|
|
126
|
+
|
|
127
|
+
# Configure with custom settings
|
|
128
|
+
client = Client(
|
|
129
|
+
api_key="your-api-key",
|
|
130
|
+
model="claude-3-5-haiku",
|
|
131
|
+
timeout=30
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
# Use the client
|
|
135
|
+
response = client.query("What is the essence of learning?")
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Core Components
|
|
139
|
+
|
|
140
|
+
- **Client**: Main interface for interacting
|
|
141
|
+
- **Providers**: Provider-specific implementations
|
|
142
|
+
- **Models**: Model definitions and configurations
|
|
143
|
+
- **Async Client**: Asynchronous version
|
|
144
|
+
- **Exceptions**: Custom error handling
|
|
145
|
+
|
|
146
|
+
## Architecture Overview
|
|
147
|
+
|
|
148
|
+
socrates-nexus follows a modular, layered architecture:
|
|
149
|
+
|
|
150
|
+
- **Client Layer**: Public API for external consumers
|
|
151
|
+
- **Processing Layer**: Core business logic and algorithms
|
|
152
|
+
- **Integration Layer**: Connections to external services and APIs
|
|
153
|
+
- **Data Layer**: State management and data persistence
|
|
154
|
+
|
|
155
|
+
## Integration with Socratic Ecosystem
|
|
156
|
+
|
|
157
|
+
socrates-nexus integrates seamlessly with:
|
|
158
|
+
|
|
159
|
+
- **socrates-nexus**: Unified LLM provider interface
|
|
160
|
+
- **socratic-rag**: Knowledge retrieval and augmentation
|
|
161
|
+
- **socratic-core**: Common utilities and base classes
|
|
162
|
+
- **Other ecosystem components**: As needed for specific use cases
|
|
163
|
+
|
|
164
|
+
## Dependencies
|
|
165
|
+
|
|
166
|
+
```
|
|
167
|
+
- anthropic
|
|
168
|
+
- openai
|
|
169
|
+
- google-generativeai
|
|
170
|
+
- langchain
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Performance Considerations
|
|
174
|
+
|
|
175
|
+
- **Caching**: Intelligent caching for frequently accessed data
|
|
176
|
+
- **Async Support**: Full async/await support for non-blocking I/O
|
|
177
|
+
- **Scalability**: Designed for high-concurrency scenarios
|
|
178
|
+
- **Resource Efficiency**: Optimized memory and CPU usage
|
|
179
|
+
|
|
180
|
+
## Error Handling
|
|
181
|
+
|
|
182
|
+
The library provides comprehensive error handling:
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
from socrates_nexus import Client, Error
|
|
186
|
+
|
|
187
|
+
try:
|
|
188
|
+
client = Client()
|
|
189
|
+
result = client.process()
|
|
190
|
+
except Error as e:
|
|
191
|
+
print(f"Error: {e}")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Testing
|
|
195
|
+
|
|
196
|
+
Run the test suite:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
pytest tests/
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
With coverage reporting:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
pytest --cov=socrates_nexus tests/
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## API Reference
|
|
209
|
+
|
|
210
|
+
For complete API documentation, see [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Contributions are welcome! See CONTRIBUTING.md for guidelines.
|
|
215
|
+
|
|
216
|
+
## Support & Resources
|
|
217
|
+
|
|
218
|
+
- GitHub Issues: https://github.com/socratic-ai/socrates-nexus/issues
|
|
219
|
+
- Documentation: https://socratic-docs.readthedocs.io/socrates-nexus
|
|
220
|
+
- Discussions: https://github.com/socratic-ai/socrates-nexus/discussions
|
|
221
|
+
|
|
222
|
+
## License
|
|
223
|
+
|
|
224
|
+
MIT License - See LICENSE file for details
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
Part of the Socratic Ecosystem
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Socratic Nexus (socrates-nexus)
|
|
2
|
+
|
|
3
|
+
Universal LLM abstraction layer providing unified access to multiple AI providers
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
socrates-nexus is a specialized component of the Socratic ecosystem that provides comprehensive functionality for universal llm abstraction layer providing unified access to multiple ai providers. It offers a production-ready, well-tested solution for integrating into larger Socratic systems.
|
|
8
|
+
|
|
9
|
+
## Key Features
|
|
10
|
+
|
|
11
|
+
- Multi-provider support
|
|
12
|
+
- Unified client interface
|
|
13
|
+
- Async/sync API support
|
|
14
|
+
- Model standardization
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
### Prerequisites
|
|
19
|
+
- Python 3.8+
|
|
20
|
+
- pip or poetry package manager
|
|
21
|
+
|
|
22
|
+
### Via pip
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install socrates-nexus
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Via poetry
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
poetry add socrates-nexus
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### From source
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/socratic-ai/socrates-nexus.git
|
|
38
|
+
cd socrates-nexus
|
|
39
|
+
pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Quick Start
|
|
43
|
+
|
|
44
|
+
### Basic Usage
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from socrates_nexus import Client
|
|
48
|
+
|
|
49
|
+
# Initialize the component
|
|
50
|
+
client = Client()
|
|
51
|
+
|
|
52
|
+
# Perform basic operation
|
|
53
|
+
result = client.process()
|
|
54
|
+
print(result)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Configuration
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from socrates_nexus import Client
|
|
61
|
+
|
|
62
|
+
# Configure with custom settings
|
|
63
|
+
client = Client(
|
|
64
|
+
api_key="your-api-key",
|
|
65
|
+
model="claude-3-5-haiku",
|
|
66
|
+
timeout=30
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Use the client
|
|
70
|
+
response = client.query("What is the essence of learning?")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Core Components
|
|
74
|
+
|
|
75
|
+
- **Client**: Main interface for interacting
|
|
76
|
+
- **Providers**: Provider-specific implementations
|
|
77
|
+
- **Models**: Model definitions and configurations
|
|
78
|
+
- **Async Client**: Asynchronous version
|
|
79
|
+
- **Exceptions**: Custom error handling
|
|
80
|
+
|
|
81
|
+
## Architecture Overview
|
|
82
|
+
|
|
83
|
+
socrates-nexus follows a modular, layered architecture:
|
|
84
|
+
|
|
85
|
+
- **Client Layer**: Public API for external consumers
|
|
86
|
+
- **Processing Layer**: Core business logic and algorithms
|
|
87
|
+
- **Integration Layer**: Connections to external services and APIs
|
|
88
|
+
- **Data Layer**: State management and data persistence
|
|
89
|
+
|
|
90
|
+
## Integration with Socratic Ecosystem
|
|
91
|
+
|
|
92
|
+
socrates-nexus integrates seamlessly with:
|
|
93
|
+
|
|
94
|
+
- **socrates-nexus**: Unified LLM provider interface
|
|
95
|
+
- **socratic-rag**: Knowledge retrieval and augmentation
|
|
96
|
+
- **socratic-core**: Common utilities and base classes
|
|
97
|
+
- **Other ecosystem components**: As needed for specific use cases
|
|
98
|
+
|
|
99
|
+
## Dependencies
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
- anthropic
|
|
103
|
+
- openai
|
|
104
|
+
- google-generativeai
|
|
105
|
+
- langchain
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Performance Considerations
|
|
109
|
+
|
|
110
|
+
- **Caching**: Intelligent caching for frequently accessed data
|
|
111
|
+
- **Async Support**: Full async/await support for non-blocking I/O
|
|
112
|
+
- **Scalability**: Designed for high-concurrency scenarios
|
|
113
|
+
- **Resource Efficiency**: Optimized memory and CPU usage
|
|
114
|
+
|
|
115
|
+
## Error Handling
|
|
116
|
+
|
|
117
|
+
The library provides comprehensive error handling:
|
|
118
|
+
|
|
119
|
+
```python
|
|
120
|
+
from socrates_nexus import Client, Error
|
|
121
|
+
|
|
122
|
+
try:
|
|
123
|
+
client = Client()
|
|
124
|
+
result = client.process()
|
|
125
|
+
except Error as e:
|
|
126
|
+
print(f"Error: {e}")
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Testing
|
|
130
|
+
|
|
131
|
+
Run the test suite:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pytest tests/
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
With coverage reporting:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pytest --cov=socrates_nexus tests/
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## API Reference
|
|
144
|
+
|
|
145
|
+
For complete API documentation, see [ARCHITECTURE.md](ARCHITECTURE.md)
|
|
146
|
+
|
|
147
|
+
## Contributing
|
|
148
|
+
|
|
149
|
+
Contributions are welcome! See CONTRIBUTING.md for guidelines.
|
|
150
|
+
|
|
151
|
+
## Support & Resources
|
|
152
|
+
|
|
153
|
+
- GitHub Issues: https://github.com/socratic-ai/socrates-nexus/issues
|
|
154
|
+
- Documentation: https://socratic-docs.readthedocs.io/socrates-nexus
|
|
155
|
+
- Discussions: https://github.com/socratic-ai/socrates-nexus/discussions
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT License - See LICENSE file for details
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
Part of the Socratic Ecosystem
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "socratic-nexus"
|
|
7
|
+
version = "0.3.1"
|
|
8
|
+
description = "Universal LLM client for production - works with Claude, GPT-4, Gemini, Llama, and any LLM. Built-in integrations with Openclaw and LangChain."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Socrates Nexus Contributors"}
|
|
13
|
+
]
|
|
14
|
+
keywords = [
|
|
15
|
+
"llm",
|
|
16
|
+
"ai",
|
|
17
|
+
"claude",
|
|
18
|
+
"gpt-4",
|
|
19
|
+
"gemini",
|
|
20
|
+
"ollama",
|
|
21
|
+
"llama",
|
|
22
|
+
"production",
|
|
23
|
+
"multi-llm",
|
|
24
|
+
"universal-client",
|
|
25
|
+
"retry",
|
|
26
|
+
"streaming",
|
|
27
|
+
"async",
|
|
28
|
+
"token-tracking"
|
|
29
|
+
]
|
|
30
|
+
classifiers = [
|
|
31
|
+
"Development Status :: 3 - Alpha",
|
|
32
|
+
"Intended Audience :: Developers",
|
|
33
|
+
"License :: OSI Approved :: MIT License",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.9",
|
|
36
|
+
"Programming Language :: Python :: 3.10",
|
|
37
|
+
"Programming Language :: Python :: 3.11",
|
|
38
|
+
"Programming Language :: Python :: 3.12",
|
|
39
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
40
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
41
|
+
]
|
|
42
|
+
requires-python = ">=3.9"
|
|
43
|
+
|
|
44
|
+
dependencies = [
|
|
45
|
+
"pydantic>=2.0.0",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
[project.optional-dependencies]
|
|
49
|
+
# Providers
|
|
50
|
+
anthropic = ["anthropic>=0.40.0"]
|
|
51
|
+
openai = ["openai>=1.0.0"]
|
|
52
|
+
google = ["google-generativeai>=0.1.0rc1"]
|
|
53
|
+
ollama = ["ollama>=0.0.8"]
|
|
54
|
+
huggingface = ["huggingface-hub>=0.17.0"]
|
|
55
|
+
|
|
56
|
+
# Integrations
|
|
57
|
+
openclaw = []
|
|
58
|
+
langchain = ["langchain>=0.1.0"]
|
|
59
|
+
|
|
60
|
+
# All providers
|
|
61
|
+
all = [
|
|
62
|
+
"anthropic>=0.40.0",
|
|
63
|
+
"openai>=1.0.0",
|
|
64
|
+
"ollama>=0.0.8",
|
|
65
|
+
"huggingface-hub>=0.17.0",
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
# All integrations
|
|
69
|
+
integrations = [
|
|
70
|
+
"langchain>=0.1.0",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
# Everything
|
|
74
|
+
full = [
|
|
75
|
+
"anthropic>=0.40.0",
|
|
76
|
+
"openai>=1.0.0",
|
|
77
|
+
"google-generativeai>=0.3.0",
|
|
78
|
+
"ollama>=0.0.8",
|
|
79
|
+
"huggingface-hub>=0.17.0",
|
|
80
|
+
"langchain>=0.1.0",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
async = ["asyncio>=3.4.3"]
|
|
84
|
+
dev = [
|
|
85
|
+
"pytest>=7.0",
|
|
86
|
+
"pytest-asyncio>=0.21.0",
|
|
87
|
+
"pytest-cov>=4.0",
|
|
88
|
+
"black>=23.0",
|
|
89
|
+
"ruff>=0.1.0",
|
|
90
|
+
"mypy>=1.0",
|
|
91
|
+
]
|
|
92
|
+
|
|
93
|
+
[project.urls]
|
|
94
|
+
Homepage = "https://github.com/Nireus79/socrates-nexus"
|
|
95
|
+
Documentation = "https://github.com/Nireus79/socrates-nexus/tree/main/docs"
|
|
96
|
+
Repository = "https://github.com/Nireus79/socrates-nexus"
|
|
97
|
+
"Source Code" = "https://github.com/Nireus79/socrates-nexus"
|
|
98
|
+
"Bug Tracker" = "https://github.com/Nireus79/socrates-nexus/issues"
|
|
99
|
+
Changelog = "https://github.com/Nireus79/socrates-nexus/releases"
|
|
100
|
+
|
|
101
|
+
[tool.setuptools]
|
|
102
|
+
packages = [
|
|
103
|
+
"socrates_nexus",
|
|
104
|
+
"socrates_nexus.providers",
|
|
105
|
+
"socrates_nexus.utils",
|
|
106
|
+
"socrates_nexus.integrations",
|
|
107
|
+
"socrates_nexus.integrations.openclaw",
|
|
108
|
+
"socrates_nexus.integrations.langchain",
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
[tool.setuptools.package-dir]
|
|
112
|
+
"" = "src"
|
|
113
|
+
|
|
114
|
+
[tool.setuptools.package-data]
|
|
115
|
+
socrates_nexus = ["py.typed"]
|
|
116
|
+
|
|
117
|
+
[tool.black]
|
|
118
|
+
line-length = 100
|
|
119
|
+
target-version = ['py38']
|
|
120
|
+
|
|
121
|
+
[tool.ruff]
|
|
122
|
+
line-length = 100
|
|
123
|
+
target-version = "py38"
|
|
124
|
+
|
|
125
|
+
[tool.pytest.ini_options]
|
|
126
|
+
testpaths = ["tests"]
|
|
127
|
+
asyncio_mode = "auto"
|
|
128
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
129
|
+
addopts = "--strict-markers --tb=short -v"
|
|
130
|
+
markers = [
|
|
131
|
+
"unit: Unit tests (no external dependencies)",
|
|
132
|
+
"integration: Integration tests (require API keys)",
|
|
133
|
+
"slow: Tests that take >1 second",
|
|
134
|
+
"requires_api: Tests requiring valid API keys",
|
|
135
|
+
]
|
|
136
|
+
|
|
137
|
+
[tool.mypy]
|
|
138
|
+
python_version = "3.9"
|
|
139
|
+
warn_return_any = false
|
|
140
|
+
warn_unused_configs = true
|
|
141
|
+
ignore_missing_imports = true
|
|
142
|
+
disallow_incomplete_defs = false
|
|
143
|
+
disallow_untyped_defs = false
|
|
144
|
+
check_untyped_defs = false
|
|
145
|
+
strict_optional = true
|
|
146
|
+
warn_redundant_casts = true
|
|
147
|
+
warn_unused_ignores = true
|
|
148
|
+
plugins = ["pydantic.mypy"]
|
|
149
|
+
|
|
150
|
+
[[tool.mypy.overrides]]
|
|
151
|
+
module = [
|
|
152
|
+
"socrates_nexus.integrations.*",
|
|
153
|
+
"tests.*",
|
|
154
|
+
]
|
|
155
|
+
ignore_errors = true
|
|
156
|
+
|
|
157
|
+
[tool.coverage.run]
|
|
158
|
+
source = ["socrates_nexus"]
|
|
159
|
+
branch = true
|
|
160
|
+
omit = [
|
|
161
|
+
"*/tests/*",
|
|
162
|
+
"*/test_*.py",
|
|
163
|
+
"*/__init__.py",
|
|
164
|
+
]
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Socrates Nexus - Universal LLM client for production.
|
|
3
|
+
|
|
4
|
+
Works with Claude, GPT-4, Gemini, Llama, and any LLM with production patterns:
|
|
5
|
+
- Automatic retry logic with exponential backoff
|
|
6
|
+
- Token usage tracking and cost calculation
|
|
7
|
+
- Streaming support with helpers
|
|
8
|
+
- Async + sync APIs
|
|
9
|
+
- Multi-model fallback
|
|
10
|
+
- Type hints throughout
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
__version__ = "0.1.0"
|
|
14
|
+
__author__ = "Socrates Nexus Contributors"
|
|
15
|
+
|
|
16
|
+
from .client import LLMClient
|
|
17
|
+
from .async_client import AsyncLLMClient
|
|
18
|
+
from .documentation import (
|
|
19
|
+
APIDocumentation,
|
|
20
|
+
APIDocumentationGenerator,
|
|
21
|
+
EndpointDoc,
|
|
22
|
+
ParameterDoc,
|
|
23
|
+
)
|
|
24
|
+
from .performance import (
|
|
25
|
+
CostOptimizer,
|
|
26
|
+
InferenceOptimizer,
|
|
27
|
+
LatencyOptimizer,
|
|
28
|
+
ModelOptimizationConfig,
|
|
29
|
+
OptimizationResult,
|
|
30
|
+
PerformanceMetrics,
|
|
31
|
+
)
|
|
32
|
+
from .deduplication import (
|
|
33
|
+
RequestDeduplicator,
|
|
34
|
+
RequestBatcher,
|
|
35
|
+
CachedResponse,
|
|
36
|
+
)
|
|
37
|
+
from .models import ChatResponse, TokenUsage, LLMConfig, ImageContent, TextContent
|
|
38
|
+
from .exceptions import (
|
|
39
|
+
LLMError,
|
|
40
|
+
NexusError,
|
|
41
|
+
RateLimitError,
|
|
42
|
+
AuthenticationError,
|
|
43
|
+
InvalidAPIKeyError,
|
|
44
|
+
TimeoutError,
|
|
45
|
+
ContextLengthExceededError,
|
|
46
|
+
ModelNotFoundError,
|
|
47
|
+
ProviderError,
|
|
48
|
+
)
|
|
49
|
+
from .vision import VisionMessage, VisionProcessor, VisionCapabilities
|
|
50
|
+
|
|
51
|
+
__all__ = [
|
|
52
|
+
"LLMClient",
|
|
53
|
+
"AsyncLLMClient",
|
|
54
|
+
"ChatResponse",
|
|
55
|
+
"TokenUsage",
|
|
56
|
+
"LLMConfig",
|
|
57
|
+
"ImageContent",
|
|
58
|
+
"TextContent",
|
|
59
|
+
# Vision support
|
|
60
|
+
"VisionMessage",
|
|
61
|
+
"VisionProcessor",
|
|
62
|
+
"VisionCapabilities",
|
|
63
|
+
# Documentation
|
|
64
|
+
"APIDocumentation",
|
|
65
|
+
"APIDocumentationGenerator",
|
|
66
|
+
"EndpointDoc",
|
|
67
|
+
"ParameterDoc",
|
|
68
|
+
# Performance Optimization
|
|
69
|
+
"InferenceOptimizer",
|
|
70
|
+
"LatencyOptimizer",
|
|
71
|
+
"CostOptimizer",
|
|
72
|
+
"ModelOptimizationConfig",
|
|
73
|
+
"PerformanceMetrics",
|
|
74
|
+
"OptimizationResult",
|
|
75
|
+
# Request Deduplication & Batching
|
|
76
|
+
"RequestDeduplicator",
|
|
77
|
+
"RequestBatcher",
|
|
78
|
+
"CachedResponse",
|
|
79
|
+
# Exceptions
|
|
80
|
+
"LLMError",
|
|
81
|
+
"NexusError",
|
|
82
|
+
"RateLimitError",
|
|
83
|
+
"AuthenticationError",
|
|
84
|
+
"InvalidAPIKeyError",
|
|
85
|
+
"TimeoutError",
|
|
86
|
+
"ContextLengthExceededError",
|
|
87
|
+
"ModelNotFoundError",
|
|
88
|
+
"ProviderError",
|
|
89
|
+
]
|