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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
Multeclaw Configuration — model registry, defaults, and system constants.
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from dataclasses import dataclass, field
|
| 6 |
+
from enum import Enum
|
| 7 |
+
from typing import Optional
|
| 8 |
+
import os
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
# ─── Model Provider Enum ──────────────────────────────────────────────────────
|
| 12 |
+
class Provider(str, Enum):
|
| 13 |
+
OPENAI = "openai"
|
| 14 |
+
ANTHROPIC = "anthropic"
|
| 15 |
+
HUGGINGFACE = "huggingface"
|
| 16 |
+
OLLAMA = "ollama"
|
| 17 |
+
GROQ = "groq"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# ─── Model Definition ─────────────────────────────────────────────────────────
|
| 21 |
+
@dataclass
|
| 22 |
+
class ModelDef:
|
| 23 |
+
display_name: str
|
| 24 |
+
provider: Provider
|
| 25 |
+
model_id: str
|
| 26 |
+
description: str = ""
|
| 27 |
+
max_tokens: int = 4096
|
| 28 |
+
supports_streaming: bool = True
|
| 29 |
+
supports_tools: bool = True
|
| 30 |
+
context_window: int = 128000
|
| 31 |
+
tier: str = "standard" # "fast", "standard", "strong"
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# ─── Model Registry ───────────────────────────────────────────────────────────
|
| 35 |
+
MODEL_REGISTRY: dict[str, ModelDef] = {
|
| 36 |
+
# OpenAI
|
| 37 |
+
"GPT-4o": ModelDef(
|
| 38 |
+
display_name="GPT-4o",
|
| 39 |
+
provider=Provider.OPENAI,
|
| 40 |
+
model_id="gpt-4o",
|
| 41 |
+
description="Most capable OpenAI model — strong reasoning + vision",
|
| 42 |
+
max_tokens=4096,
|
| 43 |
+
context_window=128000,
|
| 44 |
+
tier="strong",
|
| 45 |
+
),
|
| 46 |
+
"GPT-4o Mini": ModelDef(
|
| 47 |
+
display_name="GPT-4o Mini",
|
| 48 |
+
provider=Provider.OPENAI,
|
| 49 |
+
model_id="gpt-4o-mini",
|
| 50 |
+
description="Fast, cost-efficient OpenAI model",
|
| 51 |
+
max_tokens=4096,
|
| 52 |
+
context_window=128000,
|
| 53 |
+
tier="fast",
|
| 54 |
+
),
|
| 55 |
+
"GPT-4 Turbo": ModelDef(
|
| 56 |
+
display_name="GPT-4 Turbo",
|
| 57 |
+
provider=Provider.OPENAI,
|
| 58 |
+
model_id="gpt-4-turbo",
|
| 59 |
+
description="Previous-gen GPT-4 with vision",
|
| 60 |
+
max_tokens=4096,
|
| 61 |
+
context_window=128000,
|
| 62 |
+
tier="standard",
|
| 63 |
+
),
|
| 64 |
+
# Anthropic
|
| 65 |
+
"Claude 4 Opus": ModelDef(
|
| 66 |
+
display_name="Claude 4 Opus",
|
| 67 |
+
provider=Provider.ANTHROPIC,
|
| 68 |
+
model_id="claude-opus-4-5",
|
| 69 |
+
description="Most capable Claude model — deep reasoning",
|
| 70 |
+
max_tokens=4096,
|
| 71 |
+
context_window=200000,
|
| 72 |
+
tier="strong",
|
| 73 |
+
),
|
| 74 |
+
"Claude 4 Sonnet": ModelDef(
|
| 75 |
+
display_name="Claude 4 Sonnet",
|
| 76 |
+
provider=Provider.ANTHROPIC,
|
| 77 |
+
model_id="claude-sonnet-4-5",
|
| 78 |
+
description="Balanced Claude model — strong + fast",
|
| 79 |
+
max_tokens=4096,
|
| 80 |
+
context_window=200000,
|
| 81 |
+
tier="standard",
|
| 82 |
+
),
|
| 83 |
+
"Claude 3.5 Haiku": ModelDef(
|
| 84 |
+
display_name="Claude 3.5 Haiku",
|
| 85 |
+
provider=Provider.ANTHROPIC,
|
| 86 |
+
model_id="claude-3-5-haiku-20241022",
|
| 87 |
+
description="Fastest Claude model",
|
| 88 |
+
max_tokens=4096,
|
| 89 |
+
context_window=200000,
|
| 90 |
+
tier="fast",
|
| 91 |
+
),
|
| 92 |
+
# HuggingFace (via inference providers)
|
| 93 |
+
"Llama 3 8B": ModelDef(
|
| 94 |
+
display_name="Llama 3 8B",
|
| 95 |
+
provider=Provider.HUGGINGFACE,
|
| 96 |
+
model_id="meta-llama/Meta-Llama-3-8B-Instruct",
|
| 97 |
+
description="Meta open-source 8B model via HF Inference",
|
| 98 |
+
max_tokens=2048,
|
| 99 |
+
context_window=8192,
|
| 100 |
+
tier="fast",
|
| 101 |
+
supports_tools=False,
|
| 102 |
+
),
|
| 103 |
+
"Qwen 2.5 72B": ModelDef(
|
| 104 |
+
display_name="Qwen 2.5 72B",
|
| 105 |
+
provider=Provider.HUGGINGFACE,
|
| 106 |
+
model_id="Qwen/Qwen2.5-72B-Instruct",
|
| 107 |
+
description="Qwen large model via HF Inference",
|
| 108 |
+
max_tokens=4096,
|
| 109 |
+
context_window=32768,
|
| 110 |
+
tier="strong",
|
| 111 |
+
supports_tools=False,
|
| 112 |
+
),
|
| 113 |
+
"Mistral 7B": ModelDef(
|
| 114 |
+
display_name="Mistral 7B",
|
| 115 |
+
provider=Provider.HUGGINGFACE,
|
| 116 |
+
model_id="mistralai/Mistral-7B-Instruct-v0.3",
|
| 117 |
+
description="Mistral efficient 7B via HF Inference",
|
| 118 |
+
max_tokens=2048,
|
| 119 |
+
context_window=32768,
|
| 120 |
+
tier="fast",
|
| 121 |
+
supports_tools=False,
|
| 122 |
+
),
|
| 123 |
+
# Groq (fast inference)
|
| 124 |
+
"Llama 3 70B (Groq)": ModelDef(
|
| 125 |
+
display_name="Llama 3 70B (Groq)",
|
| 126 |
+
provider=Provider.GROQ,
|
| 127 |
+
model_id="llama3-70b-8192",
|
| 128 |
+
description="Llama 3 70B on Groq — extremely fast inference",
|
| 129 |
+
max_tokens=4096,
|
| 130 |
+
context_window=8192,
|
| 131 |
+
tier="standard",
|
| 132 |
+
supports_tools=True,
|
| 133 |
+
),
|
| 134 |
+
"Mixtral 8x7B (Groq)": ModelDef(
|
| 135 |
+
display_name="Mixtral 8x7B (Groq)",
|
| 136 |
+
provider=Provider.GROQ,
|
| 137 |
+
model_id="mixtral-8x7b-32768",
|
| 138 |
+
description="Mixtral MoE on Groq",
|
| 139 |
+
max_tokens=4096,
|
| 140 |
+
context_window=32768,
|
| 141 |
+
tier="fast",
|
| 142 |
+
supports_tools=False,
|
| 143 |
+
),
|
| 144 |
+
# Ollama (local)
|
| 145 |
+
"Ollama: Llama 3": ModelDef(
|
| 146 |
+
display_name="Ollama: Llama 3",
|
| 147 |
+
provider=Provider.OLLAMA,
|
| 148 |
+
model_id="llama3",
|
| 149 |
+
description="Local Llama 3 via Ollama",
|
| 150 |
+
max_tokens=4096,
|
| 151 |
+
context_window=8192,
|
| 152 |
+
tier="standard",
|
| 153 |
+
supports_tools=False,
|
| 154 |
+
),
|
| 155 |
+
"Ollama: Mistral": ModelDef(
|
| 156 |
+
display_name="Ollama: Mistral",
|
| 157 |
+
provider=Provider.OLLAMA,
|
| 158 |
+
model_id="mistral",
|
| 159 |
+
description="Local Mistral via Ollama",
|
| 160 |
+
max_tokens=4096,
|
| 161 |
+
context_window=32768,
|
| 162 |
+
tier="fast",
|
| 163 |
+
supports_tools=False,
|
| 164 |
+
),
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
# ─── Agent System Prompts ─────────────────────────────────────────────────────
|
| 169 |
+
SYSTEM_PROMPTS = {
|
| 170 |
+
"Multeclaw Agent": (
|
| 171 |
+
"You are Multeclaw, a high-capability general-purpose AI agent system. "
|
| 172 |
+
"You interpret user intent, decompose complex objectives, reason step by step, "
|
| 173 |
+
"and deliver precise, verified results. You are calm, direct, and thorough. "
|
| 174 |
+
"You never invent facts. You state limitations clearly. "
|
| 175 |
+
"For complex tasks, you think step by step before answering."
|
| 176 |
+
),
|
| 177 |
+
"Code Expert": (
|
| 178 |
+
"You are a senior software engineer. Write clean, well-documented, production-grade code. "
|
| 179 |
+
"Follow best practices. Explain your design choices briefly. Include error handling."
|
| 180 |
+
),
|
| 181 |
+
"Research Analyst": (
|
| 182 |
+
"You are a thorough research analyst. Provide accurate, well-structured analysis "
|
| 183 |
+
"with clear citations of reasoning. Distinguish facts from inferences. "
|
| 184 |
+
"Present findings in organized sections with key takeaways."
|
| 185 |
+
),
|
| 186 |
+
"Creative Writer": (
|
| 187 |
+
"You are a creative writer with a vivid, engaging style. "
|
| 188 |
+
"Write with strong imagery, varied sentence structure, and emotional depth. "
|
| 189 |
+
"Adapt your tone to the request — formal, casual, poetic, or technical."
|
| 190 |
+
),
|
| 191 |
+
"Data Scientist": (
|
| 192 |
+
"You are a data science expert. Provide rigorous statistical analysis, "
|
| 193 |
+
"suggest appropriate methods, explain trade-offs, and write clean analysis code. "
|
| 194 |
+
"Always consider data quality, biases, and limitations."
|
| 195 |
+
),
|
| 196 |
+
"Custom": "",
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
# ─── Agent Loop Config ─────────────────────────────────────────────────────────
|
| 201 |
+
@dataclass
|
| 202 |
+
class AgentConfig:
|
| 203 |
+
max_reasoning_steps: int = 10
|
| 204 |
+
max_tool_retries: int = 3
|
| 205 |
+
max_repair_attempts: int = 2
|
| 206 |
+
verification_enabled: bool = True
|
| 207 |
+
streaming_enabled: bool = True
|
| 208 |
+
temperature: float = 0.7
|
| 209 |
+
top_p: float = 1.0
|
| 210 |
+
presence_penalty: float = 0.0
|
| 211 |
+
frequency_penalty: float = 0.0
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
# ─── Built-in Tools ────────────────────────────────────────────────────────────
|
| 215 |
+
BUILT_IN_TOOLS = {
|
| 216 |
+
"web_search": {
|
| 217 |
+
"name": "web_search",
|
| 218 |
+
"description": "Search the web for current information. Use when you need up-to-date facts.",
|
| 219 |
+
"parameters": {
|
| 220 |
+
"type": "object",
|
| 221 |
+
"properties": {
|
| 222 |
+
"query": {"type": "string", "description": "Search query"}
|
| 223 |
+
},
|
| 224 |
+
"required": ["query"],
|
| 225 |
+
},
|
| 226 |
+
},
|
| 227 |
+
"calculator": {
|
| 228 |
+
"name": "calculator",
|
| 229 |
+
"description": "Evaluate a mathematical expression. Supports Python math syntax.",
|
| 230 |
+
"parameters": {
|
| 231 |
+
"type": "object",
|
| 232 |
+
"properties": {
|
| 233 |
+
"expression": {"type": "string", "description": "Math expression like '2**10 + sqrt(144)'"}
|
| 234 |
+
},
|
| 235 |
+
"required": ["expression"],
|
| 236 |
+
},
|
| 237 |
+
},
|
| 238 |
+
"code_executor": {
|
| 239 |
+
"name": "code_executor",
|
| 240 |
+
"description": "Execute Python code in a sandboxed environment. Returns stdout/stderr.",
|
| 241 |
+
"parameters": {
|
| 242 |
+
"type": "object",
|
| 243 |
+
"properties": {
|
| 244 |
+
"code": {"type": "string", "description": "Python code to execute"}
|
| 245 |
+
},
|
| 246 |
+
"required": ["code"],
|
| 247 |
+
},
|
| 248 |
+
},
|
| 249 |
+
"file_reader": {
|
| 250 |
+
"name": "file_reader",
|
| 251 |
+
"description": "Read the contents of a text file.",
|
| 252 |
+
"parameters": {
|
| 253 |
+
"type": "object",
|
| 254 |
+
"properties": {
|
| 255 |
+
"path": {"type": "string", "description": "File path to read"}
|
| 256 |
+
},
|
| 257 |
+
"required": ["path"],
|
| 258 |
+
},
|
| 259 |
+
},
|
| 260 |
+
"file_writer": {
|
| 261 |
+
"name": "file_writer",
|
| 262 |
+
"description": "Write content to a file. Creates parent directories if needed.",
|
| 263 |
+
"parameters": {
|
| 264 |
+
"type": "object",
|
| 265 |
+
"properties": {
|
| 266 |
+
"path": {"type": "string", "description": "File path to write"},
|
| 267 |
+
"content": {"type": "string", "description": "Content to write"},
|
| 268 |
+
},
|
| 269 |
+
"required": ["path", "content"],
|
| 270 |
+
},
|
| 271 |
+
},
|
| 272 |
+
}
|