hanzo 0.3.12__py3-none-any.whl → 0.3.14__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hanzo might be problematic. Click here for more details.

@@ -0,0 +1,319 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Orchestrator Configuration for Hanzo Dev
4
+
5
+ Supports multiple orchestration modes:
6
+ 1. Router-based: Use hanzo-router to access any LLM
7
+ 2. Direct model: Direct API access to specific models
8
+ 3. Codex mode: Specialized code-focused orchestration
9
+ 4. Hybrid: Combine router and direct access
10
+ """
11
+
12
+ import os
13
+ from enum import Enum
14
+ from typing import Any, Dict, List, Optional
15
+ from dataclasses import field, dataclass
16
+
17
+
18
+ class OrchestratorMode(Enum):
19
+ """Orchestration modes."""
20
+
21
+ ROUTER = "router" # Via hanzo-router (unified gateway)
22
+ DIRECT = "direct" # Direct model API access
23
+ CODEX = "codex" # Codex-specific mode
24
+ HYBRID = "hybrid" # Router + direct combination
25
+ LOCAL = "local" # Local models only
26
+
27
+
28
+ class ModelProvider(Enum):
29
+ """Model providers."""
30
+
31
+ OPENAI = "openai"
32
+ ANTHROPIC = "anthropic"
33
+ GOOGLE = "google"
34
+ MISTRAL = "mistral"
35
+ LOCAL = "local"
36
+ ROUTER = "router" # Via hanzo-router
37
+ CODEX = "codex" # OpenAI Codex
38
+
39
+
40
+ @dataclass
41
+ class ModelConfig:
42
+ """Configuration for a specific model."""
43
+
44
+ name: str # Model name (e.g., "gpt-5", "gpt-4o")
45
+ provider: ModelProvider # Provider type
46
+ endpoint: Optional[str] = None # Custom endpoint
47
+ api_key: Optional[str] = None # API key (if not using env)
48
+ context_window: int = 8192 # Context window size
49
+ max_output: int = 4096 # Max output tokens
50
+ temperature: float = 0.7 # Temperature setting
51
+ capabilities: List[str] = field(default_factory=list) # Model capabilities
52
+ cost_per_1k_input: float = 0.01 # Cost per 1K input tokens
53
+ cost_per_1k_output: float = 0.03 # Cost per 1K output tokens
54
+ supports_tools: bool = True # Supports function calling
55
+ supports_vision: bool = False # Supports image input
56
+ supports_streaming: bool = True # Supports streaming responses
57
+
58
+
59
+ @dataclass
60
+ class RouterConfig:
61
+ """Configuration for hanzo-router."""
62
+
63
+ endpoint: str = "http://localhost:4000" # Router endpoint
64
+ api_key: Optional[str] = None # Router API key
65
+ model_preferences: List[str] = field(default_factory=list) # Preferred models
66
+ fallback_models: List[str] = field(default_factory=list) # Fallback models
67
+ load_balancing: bool = True # Enable load balancing
68
+ cache_enabled: bool = True # Enable response caching
69
+ retry_on_failure: bool = True # Retry failed requests
70
+ max_retries: int = 3 # Max retry attempts
71
+
72
+
73
+ @dataclass
74
+ class CodexConfig:
75
+ """Configuration for Codex mode."""
76
+
77
+ model: str = "code-davinci-002" # Codex model
78
+ mode: str = "code-review" # Mode: code-review, generation, completion
79
+ languages: List[str] = field(default_factory=lambda: ["python", "typescript", "go"])
80
+ max_tokens: int = 8000 # Max tokens for Codex
81
+ stop_sequences: List[str] = field(default_factory=list) # Stop sequences
82
+ enable_comments: bool = True # Generate with comments
83
+ enable_docstrings: bool = True # Generate docstrings
84
+ enable_type_hints: bool = True # Generate type hints
85
+
86
+
87
+ @dataclass
88
+ class OrchestratorConfig:
89
+ """Complete orchestrator configuration."""
90
+
91
+ mode: OrchestratorMode = OrchestratorMode.ROUTER
92
+ primary_model: str = "gpt-5" # Primary orchestrator model
93
+ models: Dict[str, ModelConfig] = field(default_factory=dict)
94
+ router: Optional[RouterConfig] = None
95
+ codex: Optional[CodexConfig] = None
96
+ worker_models: List[str] = field(default_factory=list) # Worker agent models
97
+ critic_models: List[str] = field(default_factory=list) # Critic agent models
98
+ local_models: List[str] = field(default_factory=list) # Local models
99
+ enable_cost_optimization: bool = True # Enable cost optimization
100
+ cost_threshold: float = 0.10 # Cost threshold per request
101
+ prefer_local: bool = True # Prefer local models when possible
102
+ enable_caching: bool = True # Cache responses
103
+ enable_monitoring: bool = True # Monitor performance
104
+ debug: bool = False # Debug mode
105
+
106
+
107
+ # Predefined configurations
108
+ CONFIGS = {
109
+ "gpt-5-pro-codex": OrchestratorConfig(
110
+ mode=OrchestratorMode.HYBRID,
111
+ primary_model="gpt-5-pro",
112
+ models={
113
+ "gpt-5-pro": ModelConfig(
114
+ name="gpt-5-pro",
115
+ provider=ModelProvider.OPENAI,
116
+ context_window=200000,
117
+ capabilities=["reasoning", "code", "analysis", "vision"],
118
+ cost_per_1k_input=0.20,
119
+ cost_per_1k_output=0.60,
120
+ supports_vision=True,
121
+ ),
122
+ "codex": ModelConfig(
123
+ name="code-davinci-002",
124
+ provider=ModelProvider.CODEX,
125
+ context_window=8000,
126
+ capabilities=["code_generation", "completion", "review"],
127
+ cost_per_1k_input=0.02,
128
+ cost_per_1k_output=0.02,
129
+ ),
130
+ },
131
+ codex=CodexConfig(
132
+ model="code-davinci-002",
133
+ mode="code-review",
134
+ enable_comments=True,
135
+ enable_docstrings=True,
136
+ enable_type_hints=True,
137
+ ),
138
+ worker_models=["codex", "gpt-4o"],
139
+ critic_models=["gpt-5-pro"],
140
+ enable_cost_optimization=True,
141
+ ),
142
+ "router-based": OrchestratorConfig(
143
+ mode=OrchestratorMode.ROUTER,
144
+ primary_model="router:gpt-5",
145
+ router=RouterConfig(
146
+ endpoint=os.getenv("HANZO_ROUTER_URL", "http://localhost:4000"),
147
+ model_preferences=["gpt-5", "gpt-4o", "claude-3-5-sonnet"],
148
+ fallback_models=["gpt-4-turbo", "gpt-3.5-turbo"],
149
+ load_balancing=True,
150
+ cache_enabled=True,
151
+ ),
152
+ worker_models=["router:gpt-4o", "router:claude-3-5"],
153
+ critic_models=["router:gpt-5"],
154
+ enable_cost_optimization=True,
155
+ ),
156
+ "direct-gpt5": OrchestratorConfig(
157
+ mode=OrchestratorMode.DIRECT,
158
+ primary_model="gpt-5",
159
+ models={
160
+ "gpt-5": ModelConfig(
161
+ name="gpt-5-latest",
162
+ provider=ModelProvider.OPENAI,
163
+ endpoint="https://api.openai.com/v1",
164
+ context_window=128000,
165
+ capabilities=["reasoning", "code", "analysis"],
166
+ cost_per_1k_input=0.15,
167
+ cost_per_1k_output=0.45,
168
+ ),
169
+ },
170
+ worker_models=["gpt-4o"],
171
+ critic_models=["gpt-5"],
172
+ enable_cost_optimization=False, # Use GPT-5 for everything
173
+ ),
174
+ "codex-focused": OrchestratorConfig(
175
+ mode=OrchestratorMode.CODEX,
176
+ primary_model="codex",
177
+ codex=CodexConfig(
178
+ model="code-davinci-002",
179
+ mode="code-generation",
180
+ languages=["python", "typescript", "rust", "go"],
181
+ max_tokens=8000,
182
+ enable_comments=True,
183
+ ),
184
+ worker_models=["codex"],
185
+ critic_models=["gpt-4o"], # Use GPT-4o for code review
186
+ enable_cost_optimization=True,
187
+ ),
188
+ "cost-optimized": OrchestratorConfig(
189
+ mode=OrchestratorMode.HYBRID,
190
+ primary_model="local:llama3.2",
191
+ models={
192
+ "local:llama3.2": ModelConfig(
193
+ name="llama-3.2-3b",
194
+ provider=ModelProvider.LOCAL,
195
+ context_window=8192,
196
+ capabilities=["basic_reasoning", "simple_tasks"],
197
+ cost_per_1k_input=0.0,
198
+ cost_per_1k_output=0.0,
199
+ ),
200
+ },
201
+ router=RouterConfig(
202
+ endpoint="http://localhost:4000",
203
+ model_preferences=["gpt-4o", "claude-3-5"],
204
+ fallback_models=["gpt-3.5-turbo"],
205
+ ),
206
+ worker_models=["local:llama3.2", "local:qwen2.5"],
207
+ critic_models=["router:gpt-4o"], # Only use API for critical review
208
+ local_models=["llama3.2", "qwen2.5", "mistral"],
209
+ enable_cost_optimization=True,
210
+ prefer_local=True,
211
+ ),
212
+ }
213
+
214
+
215
+ def get_orchestrator_config(name: str) -> OrchestratorConfig:
216
+ """Get a predefined orchestrator configuration.
217
+
218
+ Args:
219
+ name: Configuration name or model spec
220
+
221
+ Returns:
222
+ OrchestratorConfig instance
223
+ """
224
+ # Check predefined configs
225
+ if name in CONFIGS:
226
+ return CONFIGS[name]
227
+
228
+ # Parse model spec (e.g., "router:gpt-5", "direct:gpt-4o", "codex")
229
+ if ":" in name:
230
+ mode, model = name.split(":", 1)
231
+ if mode == "router":
232
+ return OrchestratorConfig(
233
+ mode=OrchestratorMode.ROUTER,
234
+ primary_model=f"router:{model}",
235
+ router=RouterConfig(
236
+ model_preferences=[model],
237
+ ),
238
+ )
239
+ elif mode == "direct":
240
+ return OrchestratorConfig(
241
+ mode=OrchestratorMode.DIRECT,
242
+ primary_model=model,
243
+ )
244
+ elif mode == "local":
245
+ return OrchestratorConfig(
246
+ mode=OrchestratorMode.LOCAL,
247
+ primary_model=f"local:{model}",
248
+ local_models=[model],
249
+ enable_cost_optimization=True,
250
+ prefer_local=True,
251
+ )
252
+
253
+ # Default to router mode with specified model
254
+ return OrchestratorConfig(
255
+ mode=OrchestratorMode.ROUTER,
256
+ primary_model=name,
257
+ router=RouterConfig(
258
+ model_preferences=[name],
259
+ ),
260
+ )
261
+
262
+
263
+ def list_available_configs() -> List[str]:
264
+ """List available orchestrator configurations."""
265
+ return list(CONFIGS.keys()) + [
266
+ "router:<model>",
267
+ "direct:<model>",
268
+ "local:<model>",
269
+ "codex",
270
+ ]
271
+
272
+
273
+ # Export configuration builder
274
+ def build_custom_config(
275
+ mode: str = "router",
276
+ primary_model: str = "gpt-5",
277
+ use_router: bool = True,
278
+ use_codex: bool = False,
279
+ worker_models: Optional[List[str]] = None,
280
+ critic_models: Optional[List[str]] = None,
281
+ enable_cost_optimization: bool = True,
282
+ router_endpoint: Optional[str] = None,
283
+ ) -> OrchestratorConfig:
284
+ """Build a custom orchestrator configuration.
285
+
286
+ Args:
287
+ mode: Orchestration mode (router, direct, codex, hybrid, local)
288
+ primary_model: Primary orchestrator model
289
+ use_router: Use hanzo-router for model access
290
+ use_codex: Enable Codex for code tasks
291
+ worker_models: Worker agent models
292
+ critic_models: Critic agent models
293
+ enable_cost_optimization: Enable cost optimization
294
+ router_endpoint: Custom router endpoint
295
+
296
+ Returns:
297
+ Custom OrchestratorConfig
298
+ """
299
+ config = OrchestratorConfig(
300
+ mode=OrchestratorMode(mode),
301
+ primary_model=primary_model,
302
+ worker_models=worker_models or ["gpt-4o", "claude-3-5"],
303
+ critic_models=critic_models or ["gpt-5"],
304
+ enable_cost_optimization=enable_cost_optimization,
305
+ )
306
+
307
+ if use_router:
308
+ config.router = RouterConfig(
309
+ endpoint=router_endpoint or "http://localhost:4000",
310
+ model_preferences=[primary_model],
311
+ )
312
+
313
+ if use_codex:
314
+ config.codex = CodexConfig(
315
+ model="code-davinci-002",
316
+ mode="code-review",
317
+ )
318
+
319
+ return config
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hanzo
3
- Version: 0.3.12
3
+ Version: 0.3.14
4
4
  Summary: Hanzo AI - Complete AI Infrastructure Platform with CLI, Router, MCP, and Agent Runtime
5
5
  Project-URL: Homepage, https://hanzo.ai
6
6
  Project-URL: Repository, https://github.com/hanzoai/python-sdk
@@ -20,8 +20,10 @@ Classifier: Programming Language :: Python :: 3.12
20
20
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
22
  Requires-Python: >=3.10
23
+ Requires-Dist: anthropic>=0.25.0
23
24
  Requires-Dist: click>=8.1.0
24
25
  Requires-Dist: httpx>=0.23.0
26
+ Requires-Dist: openai>=1.0.0
25
27
  Requires-Dist: prompt-toolkit>=3.0.0
26
28
  Requires-Dist: pydantic>=2.0.0
27
29
  Requires-Dist: pyyaml>=6.0
@@ -1,8 +1,9 @@
1
1
  hanzo/__init__.py,sha256=f6N_RcJZ0F9ADrROlvPi1OrgwjF8cWQm34cml8hb1zk,169
2
2
  hanzo/__main__.py,sha256=F3Vz0Ty3bdAj_8oxyETMIqxlmNRnJOAFB1XPxbyfouI,105
3
- hanzo/cli.py,sha256=8sYh0PFE_AI72TVQcqaq9VwSaaQTUTOAzp6Z7kNX2pY,17133
4
- hanzo/dev.py,sha256=rhtORd66BDUf_SnMags0w8eSAn-tF7DR3GFOjxM2zqw,64642
3
+ hanzo/cli.py,sha256=4cmWgFp1rfefWnNUHfu5Tclfbl0X9_NCygUktRe5C8g,18586
4
+ hanzo/dev.py,sha256=_f1PcGuZ1m6M6B-vRsVpaceGSSMVP5lQe-p30muAGWQ,91152
5
5
  hanzo/mcp_server.py,sha256=XVygFNn-9CVdu8c95sP7fQjIRtA8K7nsGpgQNe44BRg,460
6
+ hanzo/orchestrator_config.py,sha256=JV7DS8aVZwBJ9XzgkQronFwV_A50QyXG3MH_pKwmCB8,11006
6
7
  hanzo/repl.py,sha256=sW1quuqGkJ_AqgjN2vLNdtWgKDlXIkXiO9Bo1QQI0G4,1089
7
8
  hanzo/commands/__init__.py,sha256=7rh94TPNhdq4gJBJS0Ayf0fGNChQYCQCJcJPmYYehiQ,182
8
9
  hanzo/commands/agent.py,sha256=DXCfuxHfmC90IoIOL6BJyp7h2yNUo-VIxrfl4OMh8CU,3480
@@ -23,7 +24,7 @@ hanzo/utils/__init__.py,sha256=5RRwKI852vp8smr4xCRgeKfn7dLEnHbdXGfVYTZ5jDQ,69
23
24
  hanzo/utils/config.py,sha256=FD_LoBpcoF5dgJ7WL4o6LDp2pdOy8kS-dJ6iRO2GcGM,4728
24
25
  hanzo/utils/net_check.py,sha256=YFbJ65SzfDYHkHLZe3n51VhId1VI3zhyx8p6BM-l6jE,3017
25
26
  hanzo/utils/output.py,sha256=W0j3psF07vJiX4s02gbN4zYWfbKNsb8TSIoagBSf5vA,2704
26
- hanzo-0.3.12.dist-info/METADATA,sha256=FjtOZ43UJhuUeQfMHePHxbNFprWE_6lJW2NoYFqKTMM,4217
27
- hanzo-0.3.12.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- hanzo-0.3.12.dist-info/entry_points.txt,sha256=pQLPMdqOXU_2BfTcMDhkqTCDNk_H6ApvYuSaWcuQOOw,171
29
- hanzo-0.3.12.dist-info/RECORD,,
27
+ hanzo-0.3.14.dist-info/METADATA,sha256=9MjoIbpUCHSZyM34z4P4ZsIROnyNQRCKB7HNJp53mw4,4279
28
+ hanzo-0.3.14.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
29
+ hanzo-0.3.14.dist-info/entry_points.txt,sha256=pQLPMdqOXU_2BfTcMDhkqTCDNk_H6ApvYuSaWcuQOOw,171
30
+ hanzo-0.3.14.dist-info/RECORD,,
File without changes