hanzo 0.3.23__tar.gz → 0.3.24__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 hanzo might be problematic. Click here for more details.
- hanzo-0.3.24/PKG-INFO +276 -0
- hanzo-0.3.24/README.md +223 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/pyproject.toml +1 -1
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/base_agent.py +4 -5
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/batch_orchestrator.py +11 -11
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/cli.py +7 -5
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/chat.py +57 -16
- hanzo-0.3.23/src/hanzo/commands/cluster.py → hanzo-0.3.24/src/hanzo/commands/node.py +128 -128
- hanzo-0.3.24/src/hanzo/commands/router.py +152 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/dev.py +1 -1
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/fallback_handler.py +1 -1
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/interactive/repl.py +52 -32
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/mcp_server.py +8 -3
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/memory_manager.py +1 -1
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/model_registry.py +2 -2
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/rate_limiter.py +1 -1
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/streaming.py +1 -1
- hanzo-0.3.23/PKG-INFO +0 -137
- hanzo-0.3.23/README.md +0 -84
- {hanzo-0.3.23 → hanzo-0.3.24}/.gitignore +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/__init__.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/__main__.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/__init__.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/agent.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/auth.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/config.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/mcp.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/miner.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/network.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/repl.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/commands/tools.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/interactive/__init__.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/interactive/dashboard.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/orchestrator_config.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/repl.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/router/__init__.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/utils/__init__.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/utils/config.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/utils/net_check.py +0 -0
- {hanzo-0.3.23 → hanzo-0.3.24}/src/hanzo/utils/output.py +0 -0
hanzo-0.3.24/PKG-INFO
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hanzo
|
|
3
|
+
Version: 0.3.24
|
|
4
|
+
Summary: Hanzo AI - Complete AI Infrastructure Platform with CLI, Router, MCP, and Agent Runtime
|
|
5
|
+
Project-URL: Homepage, https://hanzo.ai
|
|
6
|
+
Project-URL: Repository, https://github.com/hanzoai/python-sdk
|
|
7
|
+
Project-URL: Documentation, https://docs.hanzo.ai/cli
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/hanzoai/python-sdk/issues
|
|
9
|
+
Author-email: Hanzo AI <dev@hanzo.ai>
|
|
10
|
+
Keywords: agents,ai,cli,hanzo,llm,local-ai,mcp,private-ai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Requires-Dist: anthropic>=0.25.0
|
|
24
|
+
Requires-Dist: click>=8.1.0
|
|
25
|
+
Requires-Dist: httpx>=0.23.0
|
|
26
|
+
Requires-Dist: openai>=1.0.0
|
|
27
|
+
Requires-Dist: prompt-toolkit>=3.0.0
|
|
28
|
+
Requires-Dist: pydantic>=2.0.0
|
|
29
|
+
Requires-Dist: pyyaml>=6.0
|
|
30
|
+
Requires-Dist: rich>=13.0.0
|
|
31
|
+
Requires-Dist: typer>=0.9.0
|
|
32
|
+
Provides-Extra: agents
|
|
33
|
+
Requires-Dist: hanzo-agents>=0.1.0; extra == 'agents'
|
|
34
|
+
Requires-Dist: hanzo-network>=0.1.3; extra == 'agents'
|
|
35
|
+
Provides-Extra: ai
|
|
36
|
+
Requires-Dist: hanzoai>=1.0.0; extra == 'ai'
|
|
37
|
+
Provides-Extra: all
|
|
38
|
+
Requires-Dist: hanzo-aci>=0.2.8; extra == 'all'
|
|
39
|
+
Requires-Dist: hanzo-agents>=0.1.0; extra == 'all'
|
|
40
|
+
Requires-Dist: hanzo-mcp>=0.7.0; extra == 'all'
|
|
41
|
+
Requires-Dist: hanzo-memory>=1.0.0; extra == 'all'
|
|
42
|
+
Requires-Dist: hanzo-network>=0.1.3; extra == 'all'
|
|
43
|
+
Requires-Dist: hanzo-repl>=0.1.0; extra == 'all'
|
|
44
|
+
Requires-Dist: hanzoai>=1.0.0; extra == 'all'
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: hanzo-aci>=0.2.8; extra == 'dev'
|
|
47
|
+
Provides-Extra: mcp
|
|
48
|
+
Requires-Dist: hanzo-mcp>=0.7.0; extra == 'mcp'
|
|
49
|
+
Provides-Extra: repl
|
|
50
|
+
Requires-Dist: hanzo-repl>=0.1.0; extra == 'repl'
|
|
51
|
+
Provides-Extra: router
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
# Hanzo CLI and Orchestration Tools
|
|
55
|
+
|
|
56
|
+
[](https://pypi.org/project/hanzo/)
|
|
57
|
+
[](https://pypi.org/project/hanzo/)
|
|
58
|
+
|
|
59
|
+
Core CLI and orchestration tools for the Hanzo AI platform.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install hanzo
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Features
|
|
68
|
+
|
|
69
|
+
- **Interactive Chat**: Chat with AI models through CLI
|
|
70
|
+
- **Node Management**: Run local AI inference nodes
|
|
71
|
+
- **Router Control**: Manage LLM proxy router
|
|
72
|
+
- **REPL Interface**: Interactive Python REPL with AI
|
|
73
|
+
- **Batch Orchestration**: Orchestrate multiple AI tasks
|
|
74
|
+
- **Memory Management**: Persistent conversation memory
|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
78
|
+
### CLI Commands
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Interactive chat
|
|
82
|
+
hanzo chat
|
|
83
|
+
|
|
84
|
+
# Use specific model
|
|
85
|
+
hanzo chat --model gpt-4
|
|
86
|
+
|
|
87
|
+
# Use router (local proxy)
|
|
88
|
+
hanzo chat --router
|
|
89
|
+
|
|
90
|
+
# Use cloud API
|
|
91
|
+
hanzo chat --cloud
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Node Management
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Start local node
|
|
98
|
+
hanzo node start
|
|
99
|
+
|
|
100
|
+
# Check status
|
|
101
|
+
hanzo node status
|
|
102
|
+
|
|
103
|
+
# List available models
|
|
104
|
+
hanzo node models
|
|
105
|
+
|
|
106
|
+
# Load specific model
|
|
107
|
+
hanzo node load llama2:7b
|
|
108
|
+
|
|
109
|
+
# Stop node
|
|
110
|
+
hanzo node stop
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Router Management
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Start router proxy
|
|
117
|
+
hanzo router start
|
|
118
|
+
|
|
119
|
+
# Check router status
|
|
120
|
+
hanzo router status
|
|
121
|
+
|
|
122
|
+
# List available models
|
|
123
|
+
hanzo router models
|
|
124
|
+
|
|
125
|
+
# View configuration
|
|
126
|
+
hanzo router config
|
|
127
|
+
|
|
128
|
+
# Stop router
|
|
129
|
+
hanzo router stop
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Interactive REPL
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Start REPL
|
|
136
|
+
hanzo repl
|
|
137
|
+
|
|
138
|
+
# In REPL:
|
|
139
|
+
> /help # Show help
|
|
140
|
+
> /models # List models
|
|
141
|
+
> /model gpt-4 # Switch model
|
|
142
|
+
> /clear # Clear context
|
|
143
|
+
> What is Python? # Ask questions
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Python API
|
|
147
|
+
|
|
148
|
+
### Batch Orchestration
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from hanzo.batch_orchestrator import BatchOrchestrator
|
|
152
|
+
|
|
153
|
+
orchestrator = BatchOrchestrator()
|
|
154
|
+
results = await orchestrator.run_batch([
|
|
155
|
+
"Summarize quantum computing",
|
|
156
|
+
"Explain machine learning",
|
|
157
|
+
"Define artificial intelligence"
|
|
158
|
+
])
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Memory Management
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
from hanzo.memory_manager import MemoryManager
|
|
165
|
+
|
|
166
|
+
memory = MemoryManager()
|
|
167
|
+
memory.add_to_context("user", "What is Python?")
|
|
168
|
+
memory.add_to_context("assistant", "Python is...")
|
|
169
|
+
context = memory.get_context()
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Fallback Handling
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from hanzo.fallback_handler import FallbackHandler
|
|
176
|
+
|
|
177
|
+
handler = FallbackHandler()
|
|
178
|
+
result = await handler.handle_with_fallback(
|
|
179
|
+
primary_fn=api_call,
|
|
180
|
+
fallback_fn=local_inference
|
|
181
|
+
)
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Configuration
|
|
185
|
+
|
|
186
|
+
### Environment Variables
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# API settings
|
|
190
|
+
HANZO_API_KEY=your-api-key
|
|
191
|
+
HANZO_BASE_URL=https://api.hanzo.ai
|
|
192
|
+
|
|
193
|
+
# Router settings
|
|
194
|
+
HANZO_ROUTER_URL=http://localhost:4000/v1
|
|
195
|
+
|
|
196
|
+
# Node settings
|
|
197
|
+
HANZO_NODE_URL=http://localhost:8000/v1
|
|
198
|
+
HANZO_NODE_WORKERS=4
|
|
199
|
+
|
|
200
|
+
# Model preferences
|
|
201
|
+
HANZO_DEFAULT_MODEL=gpt-4
|
|
202
|
+
HANZO_FALLBACK_MODEL=llama2:7b
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Configuration File
|
|
206
|
+
|
|
207
|
+
Create `~/.hanzo/config.yaml`:
|
|
208
|
+
|
|
209
|
+
```yaml
|
|
210
|
+
api:
|
|
211
|
+
key: your-api-key
|
|
212
|
+
base_url: https://api.hanzo.ai
|
|
213
|
+
|
|
214
|
+
router:
|
|
215
|
+
url: http://localhost:4000/v1
|
|
216
|
+
auto_start: true
|
|
217
|
+
|
|
218
|
+
node:
|
|
219
|
+
url: http://localhost:8000/v1
|
|
220
|
+
workers: 4
|
|
221
|
+
models:
|
|
222
|
+
- llama2:7b
|
|
223
|
+
- mistral:7b
|
|
224
|
+
|
|
225
|
+
models:
|
|
226
|
+
default: gpt-4
|
|
227
|
+
fallback: llama2:7b
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Architecture
|
|
231
|
+
|
|
232
|
+
### Components
|
|
233
|
+
|
|
234
|
+
- **CLI**: Command-line interface (`cli.py`)
|
|
235
|
+
- **Chat**: Interactive chat interface (`commands/chat.py`)
|
|
236
|
+
- **Node**: Local AI node management (`commands/node.py`)
|
|
237
|
+
- **Router**: LLM proxy management (`commands/router.py`)
|
|
238
|
+
- **REPL**: Interactive Python REPL (`interactive/repl.py`)
|
|
239
|
+
- **Orchestrator**: Batch task orchestration (`batch_orchestrator.py`)
|
|
240
|
+
- **Memory**: Conversation memory (`memory_manager.py`)
|
|
241
|
+
- **Fallback**: Resilient API handling (`fallback_handler.py`)
|
|
242
|
+
|
|
243
|
+
### Port Allocation
|
|
244
|
+
|
|
245
|
+
- **4000**: Router (LLM proxy)
|
|
246
|
+
- **8000**: Node (local AI)
|
|
247
|
+
- **9550-9553**: Desktop app integration
|
|
248
|
+
|
|
249
|
+
## Development
|
|
250
|
+
|
|
251
|
+
### Setup
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
cd pkg/hanzo
|
|
255
|
+
uv sync --all-extras
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Testing
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Run tests
|
|
262
|
+
pytest tests/
|
|
263
|
+
|
|
264
|
+
# With coverage
|
|
265
|
+
pytest tests/ --cov=hanzo
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Building
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
uv build
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
## License
|
|
275
|
+
|
|
276
|
+
Apache License 2.0
|
hanzo-0.3.24/README.md
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Hanzo CLI and Orchestration Tools
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/hanzo/)
|
|
4
|
+
[](https://pypi.org/project/hanzo/)
|
|
5
|
+
|
|
6
|
+
Core CLI and orchestration tools for the Hanzo AI platform.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install hanzo
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- **Interactive Chat**: Chat with AI models through CLI
|
|
17
|
+
- **Node Management**: Run local AI inference nodes
|
|
18
|
+
- **Router Control**: Manage LLM proxy router
|
|
19
|
+
- **REPL Interface**: Interactive Python REPL with AI
|
|
20
|
+
- **Batch Orchestration**: Orchestrate multiple AI tasks
|
|
21
|
+
- **Memory Management**: Persistent conversation memory
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
### CLI Commands
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Interactive chat
|
|
29
|
+
hanzo chat
|
|
30
|
+
|
|
31
|
+
# Use specific model
|
|
32
|
+
hanzo chat --model gpt-4
|
|
33
|
+
|
|
34
|
+
# Use router (local proxy)
|
|
35
|
+
hanzo chat --router
|
|
36
|
+
|
|
37
|
+
# Use cloud API
|
|
38
|
+
hanzo chat --cloud
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Node Management
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Start local node
|
|
45
|
+
hanzo node start
|
|
46
|
+
|
|
47
|
+
# Check status
|
|
48
|
+
hanzo node status
|
|
49
|
+
|
|
50
|
+
# List available models
|
|
51
|
+
hanzo node models
|
|
52
|
+
|
|
53
|
+
# Load specific model
|
|
54
|
+
hanzo node load llama2:7b
|
|
55
|
+
|
|
56
|
+
# Stop node
|
|
57
|
+
hanzo node stop
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Router Management
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Start router proxy
|
|
64
|
+
hanzo router start
|
|
65
|
+
|
|
66
|
+
# Check router status
|
|
67
|
+
hanzo router status
|
|
68
|
+
|
|
69
|
+
# List available models
|
|
70
|
+
hanzo router models
|
|
71
|
+
|
|
72
|
+
# View configuration
|
|
73
|
+
hanzo router config
|
|
74
|
+
|
|
75
|
+
# Stop router
|
|
76
|
+
hanzo router stop
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Interactive REPL
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Start REPL
|
|
83
|
+
hanzo repl
|
|
84
|
+
|
|
85
|
+
# In REPL:
|
|
86
|
+
> /help # Show help
|
|
87
|
+
> /models # List models
|
|
88
|
+
> /model gpt-4 # Switch model
|
|
89
|
+
> /clear # Clear context
|
|
90
|
+
> What is Python? # Ask questions
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Python API
|
|
94
|
+
|
|
95
|
+
### Batch Orchestration
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
from hanzo.batch_orchestrator import BatchOrchestrator
|
|
99
|
+
|
|
100
|
+
orchestrator = BatchOrchestrator()
|
|
101
|
+
results = await orchestrator.run_batch([
|
|
102
|
+
"Summarize quantum computing",
|
|
103
|
+
"Explain machine learning",
|
|
104
|
+
"Define artificial intelligence"
|
|
105
|
+
])
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Memory Management
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from hanzo.memory_manager import MemoryManager
|
|
112
|
+
|
|
113
|
+
memory = MemoryManager()
|
|
114
|
+
memory.add_to_context("user", "What is Python?")
|
|
115
|
+
memory.add_to_context("assistant", "Python is...")
|
|
116
|
+
context = memory.get_context()
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Fallback Handling
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from hanzo.fallback_handler import FallbackHandler
|
|
123
|
+
|
|
124
|
+
handler = FallbackHandler()
|
|
125
|
+
result = await handler.handle_with_fallback(
|
|
126
|
+
primary_fn=api_call,
|
|
127
|
+
fallback_fn=local_inference
|
|
128
|
+
)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Configuration
|
|
132
|
+
|
|
133
|
+
### Environment Variables
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# API settings
|
|
137
|
+
HANZO_API_KEY=your-api-key
|
|
138
|
+
HANZO_BASE_URL=https://api.hanzo.ai
|
|
139
|
+
|
|
140
|
+
# Router settings
|
|
141
|
+
HANZO_ROUTER_URL=http://localhost:4000/v1
|
|
142
|
+
|
|
143
|
+
# Node settings
|
|
144
|
+
HANZO_NODE_URL=http://localhost:8000/v1
|
|
145
|
+
HANZO_NODE_WORKERS=4
|
|
146
|
+
|
|
147
|
+
# Model preferences
|
|
148
|
+
HANZO_DEFAULT_MODEL=gpt-4
|
|
149
|
+
HANZO_FALLBACK_MODEL=llama2:7b
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Configuration File
|
|
153
|
+
|
|
154
|
+
Create `~/.hanzo/config.yaml`:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
api:
|
|
158
|
+
key: your-api-key
|
|
159
|
+
base_url: https://api.hanzo.ai
|
|
160
|
+
|
|
161
|
+
router:
|
|
162
|
+
url: http://localhost:4000/v1
|
|
163
|
+
auto_start: true
|
|
164
|
+
|
|
165
|
+
node:
|
|
166
|
+
url: http://localhost:8000/v1
|
|
167
|
+
workers: 4
|
|
168
|
+
models:
|
|
169
|
+
- llama2:7b
|
|
170
|
+
- mistral:7b
|
|
171
|
+
|
|
172
|
+
models:
|
|
173
|
+
default: gpt-4
|
|
174
|
+
fallback: llama2:7b
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Architecture
|
|
178
|
+
|
|
179
|
+
### Components
|
|
180
|
+
|
|
181
|
+
- **CLI**: Command-line interface (`cli.py`)
|
|
182
|
+
- **Chat**: Interactive chat interface (`commands/chat.py`)
|
|
183
|
+
- **Node**: Local AI node management (`commands/node.py`)
|
|
184
|
+
- **Router**: LLM proxy management (`commands/router.py`)
|
|
185
|
+
- **REPL**: Interactive Python REPL (`interactive/repl.py`)
|
|
186
|
+
- **Orchestrator**: Batch task orchestration (`batch_orchestrator.py`)
|
|
187
|
+
- **Memory**: Conversation memory (`memory_manager.py`)
|
|
188
|
+
- **Fallback**: Resilient API handling (`fallback_handler.py`)
|
|
189
|
+
|
|
190
|
+
### Port Allocation
|
|
191
|
+
|
|
192
|
+
- **4000**: Router (LLM proxy)
|
|
193
|
+
- **8000**: Node (local AI)
|
|
194
|
+
- **9550-9553**: Desktop app integration
|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
### Setup
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
cd pkg/hanzo
|
|
202
|
+
uv sync --all-extras
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Testing
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Run tests
|
|
209
|
+
pytest tests/
|
|
210
|
+
|
|
211
|
+
# With coverage
|
|
212
|
+
pytest tests/ --cov=hanzo
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Building
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
uv build
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
Apache License 2.0
|
|
@@ -10,13 +10,12 @@ import os
|
|
|
10
10
|
import asyncio
|
|
11
11
|
import logging
|
|
12
12
|
from abc import ABC, abstractmethod
|
|
13
|
-
from typing import Any, Dict, List,
|
|
14
|
-
from dataclasses import dataclass, field
|
|
15
|
-
from datetime import datetime
|
|
13
|
+
from typing import Any, Dict, List, Generic, TypeVar, Optional, Protocol
|
|
16
14
|
from pathlib import Path
|
|
15
|
+
from datetime import datetime
|
|
16
|
+
from dataclasses import field, dataclass
|
|
17
17
|
|
|
18
|
-
from .model_registry import
|
|
19
|
-
|
|
18
|
+
from .model_registry import ModelConfig, registry
|
|
20
19
|
|
|
21
20
|
logger = logging.getLogger(__name__)
|
|
22
21
|
|
|
@@ -5,28 +5,28 @@ consensus mechanisms, and critic chains using the unified base classes.
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
import re
|
|
8
|
+
import json
|
|
8
9
|
import asyncio
|
|
9
10
|
import logging
|
|
10
|
-
from typing import Any, Dict, List, Optional, AsyncIterator, Callable
|
|
11
|
-
from dataclasses import dataclass, field
|
|
12
|
-
from datetime import datetime
|
|
13
|
-
from pathlib import Path
|
|
14
|
-
import json
|
|
15
11
|
import subprocess
|
|
12
|
+
from typing import Any, Dict, List, Callable, Optional, AsyncIterator
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from datetime import datetime
|
|
15
|
+
from dataclasses import field, dataclass
|
|
16
16
|
|
|
17
|
-
from rich.console import Console
|
|
18
|
-
from rich.progress import Progress, TaskID, TextColumn, SpinnerColumn, BarColumn
|
|
19
|
-
from rich.table import Table
|
|
20
17
|
from rich.panel import Panel
|
|
18
|
+
from rich.table import Table
|
|
19
|
+
from rich.console import Console
|
|
20
|
+
from rich.progress import TaskID, Progress, BarColumn, TextColumn, SpinnerColumn
|
|
21
21
|
|
|
22
22
|
try:
|
|
23
23
|
# Try to import from hanzo-mcp if available
|
|
24
|
-
from hanzo_mcp.core.model_registry import registry
|
|
25
24
|
from hanzo_mcp.core.base_agent import AgentConfig, AgentResult, AgentOrchestrator
|
|
25
|
+
from hanzo_mcp.core.model_registry import registry
|
|
26
26
|
except ImportError:
|
|
27
27
|
# Fall back to local imports if hanzo-mcp is not installed
|
|
28
|
-
from .model_registry import registry
|
|
29
28
|
from .base_agent import AgentConfig, AgentResult, AgentOrchestrator
|
|
29
|
+
from .model_registry import registry
|
|
30
30
|
|
|
31
31
|
logger = logging.getLogger(__name__)
|
|
32
32
|
console = Console()
|
|
@@ -906,7 +906,7 @@ class MetaAIOrchestrator:
|
|
|
906
906
|
)
|
|
907
907
|
try:
|
|
908
908
|
return json.loads(result)
|
|
909
|
-
except:
|
|
909
|
+
except Exception:
|
|
910
910
|
pass
|
|
911
911
|
|
|
912
912
|
# Fallback intent detection
|
|
@@ -14,12 +14,13 @@ from .commands import (
|
|
|
14
14
|
mcp,
|
|
15
15
|
auth,
|
|
16
16
|
chat,
|
|
17
|
+
node,
|
|
17
18
|
repl,
|
|
18
19
|
agent,
|
|
19
20
|
miner,
|
|
20
21
|
tools,
|
|
21
22
|
config,
|
|
22
|
-
|
|
23
|
+
router,
|
|
23
24
|
network,
|
|
24
25
|
)
|
|
25
26
|
from .utils.output import console
|
|
@@ -72,7 +73,7 @@ def cli(ctx, verbose: bool, json: bool, config: Optional[str]):
|
|
|
72
73
|
# Register command groups
|
|
73
74
|
cli.add_command(agent.agent_group)
|
|
74
75
|
cli.add_command(auth.auth_group)
|
|
75
|
-
cli.add_command(cluster
|
|
76
|
+
cli.add_command(node.cluster)
|
|
76
77
|
cli.add_command(mcp.mcp_group)
|
|
77
78
|
cli.add_command(miner.miner_group)
|
|
78
79
|
cli.add_command(chat.chat_command)
|
|
@@ -80,6 +81,7 @@ cli.add_command(repl.repl_group)
|
|
|
80
81
|
cli.add_command(tools.tools_group)
|
|
81
82
|
cli.add_command(network.network_group)
|
|
82
83
|
cli.add_command(config.config_group)
|
|
84
|
+
cli.add_command(router.router_group)
|
|
83
85
|
|
|
84
86
|
|
|
85
87
|
# Quick aliases
|
|
@@ -95,12 +97,12 @@ def ask(ctx, prompt: tuple, model: str, local: bool):
|
|
|
95
97
|
|
|
96
98
|
|
|
97
99
|
@cli.command()
|
|
98
|
-
@click.option("--name", "-n", default="hanzo-local", help="
|
|
100
|
+
@click.option("--name", "-n", default="hanzo-local", help="Node name")
|
|
99
101
|
@click.option("--port", "-p", default=8000, help="API port")
|
|
100
102
|
@click.pass_context
|
|
101
103
|
def serve(ctx, name: str, port: int):
|
|
102
|
-
"""Start local AI
|
|
103
|
-
asyncio.run(
|
|
104
|
+
"""Start local AI node (alias for 'hanzo node start')."""
|
|
105
|
+
asyncio.run(node.start_node(ctx, name, port))
|
|
104
106
|
|
|
105
107
|
|
|
106
108
|
@cli.command()
|