Text Generation
MLX
Safetensors
English
Korean
Japanese
solar_open2
solar
solar-open2
Mixture of Experts
quantized
4bit
conversational
4-bit precision
Instructions to use TensorFold/Solar-Open2-250B-MLX-4bit with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use TensorFold/Solar-Open2-250B-MLX-4bit with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("TensorFold/Solar-Open2-250B-MLX-4bit") prompt = "Write a story about Einstein" messages = [{"role": "user", "content": prompt}] prompt = tokenizer.apply_chat_template( messages, add_generation_prompt=True ) text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- Pi
How to use TensorFold/Solar-Open2-250B-MLX-4bit with Pi:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "TensorFold/Solar-Open2-250B-MLX-4bit"
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "mlx-lm": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "TensorFold/Solar-Open2-250B-MLX-4bit" } ] } } }Run Pi
# Start Pi in your project directory: pi
- MLX LM
How to use TensorFold/Solar-Open2-250B-MLX-4bit with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Interactive chat REPL mlx_lm.chat --model "TensorFold/Solar-Open2-250B-MLX-4bit"
Run an OpenAI-compatible server
# Install MLX LM uv tool install mlx-lm # Start the server mlx_lm.server --model "TensorFold/Solar-Open2-250B-MLX-4bit" # Calling the OpenAI-compatible server with curl curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "TensorFold/Solar-Open2-250B-MLX-4bit", "messages": [ {"role": "user", "content": "Hello"} ] }' - Hermes Agent
How to use TensorFold/Solar-Open2-250B-MLX-4bit with Hermes Agent:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "TensorFold/Solar-Open2-250B-MLX-4bit"
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default TensorFold/Solar-Open2-250B-MLX-4bit
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use TensorFold/Solar-Open2-250B-MLX-4bit with OpenClaw:
Start the MLX server
# Install MLX LM: uv tool install mlx-lm # Start a local OpenAI-compatible server: mlx_lm.server --model "TensorFold/Solar-Open2-250B-MLX-4bit"
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "TensorFold/Solar-Open2-250B-MLX-4bit" \ --custom-provider-id mlx-lm \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Download omlx/solar_open2_tool_parser.py from TensorFold/Solar-Open2-250B-MLX-4bit: direct link, hf CLI and curl.
- Browser
- Download file 3.81 kB
-
https://huggingface.co/TensorFold/Solar-Open2-250B-MLX-4bit/resolve/main/omlx/solar_open2_tool_parser.py
- Command line
-
hf download hf://TensorFold/Solar-Open2-250B-MLX-4bit/omlx/solar_open2_tool_parser.py
-
curl -L -o solar_open2_tool_parser.py https://huggingface.co/TensorFold/Solar-Open2-250B-MLX-4bit/resolve/main/omlx/solar_open2_tool_parser.py
3.81 kB
| import ast | |
| import json | |
| import re | |
| from typing import Any | |
| tool_call_start = "<|tool_call:start|>" | |
| tool_call_end = "<|tool_call:end|>" | |
| _ARG_RE = re.compile( | |
| r"<\|tool_arg:start\|>(.*?)<\|tool_arg:value\|>(.*?)<\|tool_arg:end\|>", | |
| re.DOTALL, | |
| ) | |
| _STRING_TYPES = {"string", "str", "text", "varchar", "char", "enum"} | |
| _BOOL_TYPES = {"boolean", "bool", "binary"} | |
| _INT_PREFIXES = ("int", "uint", "long", "short", "unsigned") | |
| _FLOAT_PREFIXES = ("num", "float", "double", "decimal") | |
| _JSON_TYPES = {"object", "array", "arr", "dict", "list"} | |
| def _tool_properties(name: str, tools: Any | None) -> dict[str, Any]: | |
| if not tools: | |
| return {} | |
| for tool in tools: | |
| function = tool.get("function") if isinstance(tool, dict) else None | |
| if function and function.get("name") == name: | |
| params = function.get("parameters") or {} | |
| return params.get("properties") or {} | |
| return {} | |
| def _schema_type(properties: dict[str, Any], key: str) -> str: | |
| schema = properties.get(key) or {} | |
| typ = schema.get("type", "string") | |
| if isinstance(typ, list): | |
| typ = next((item for item in typ if item != "null"), typ[0] if typ else "string") | |
| return str(typ).lower() | |
| def _coerce(value: str, key: str, properties: dict[str, Any]) -> Any: | |
| value = value.strip() | |
| typ = _schema_type(properties, key) | |
| if value.lower() == "null": | |
| return None | |
| if typ in _STRING_TYPES: | |
| return value | |
| if typ in _BOOL_TYPES: | |
| normalized = value.lower() | |
| if normalized in {"1", "true", "yes"}: | |
| return True | |
| if normalized in {"0", "false", "no"}: | |
| return False | |
| return value | |
| if typ.startswith(_INT_PREFIXES): | |
| try: | |
| return int(value) | |
| except (TypeError, ValueError): | |
| return value | |
| if typ.startswith(_FLOAT_PREFIXES): | |
| try: | |
| number = float(value) | |
| return int(number) if number.is_integer() else number | |
| except (TypeError, ValueError): | |
| return value | |
| if typ in _JSON_TYPES or typ.startswith(("dict", "list")): | |
| try: | |
| return json.loads(value) | |
| except (TypeError, ValueError, json.JSONDecodeError): | |
| try: | |
| return ast.literal_eval(value) | |
| except (SyntaxError, ValueError): | |
| return value | |
| try: | |
| return json.loads(value) | |
| except (TypeError, json.JSONDecodeError): | |
| return value | |
| def parse_tool_call(text: str, tools: Any | None = None) -> dict[str, Any]: | |
| body = text.strip() | |
| if body.startswith(tool_call_start): | |
| body = body[len(tool_call_start) :].strip() | |
| if body.endswith(tool_call_end): | |
| body = body[: -len(tool_call_end)].strip() | |
| first_arg = body.find("<|tool_arg:start|>") | |
| if first_arg == -1: | |
| try: | |
| payload = json.loads(body) | |
| except json.JSONDecodeError as exc: | |
| raise ValueError(f"No Solar tool arguments found in: {text!r}") from exc | |
| name = payload.get("name") or payload.get("tool") or payload.get("function") | |
| args = payload.get("arguments") or payload.get("args") or {} | |
| if not name: | |
| raise ValueError(f"No Solar tool name found in: {text!r}") | |
| if isinstance(args, str): | |
| args = json.loads(args) | |
| return {"name": name, "arguments": args} | |
| name = body[:first_arg].strip().splitlines()[0].strip() | |
| if not name: | |
| raise ValueError(f"No Solar tool name found in: {text!r}") | |
| properties = _tool_properties(name, tools) | |
| arguments: dict[str, Any] = {} | |
| for key, value in _ARG_RE.findall(body[first_arg:]): | |
| key = key.strip() | |
| if key: | |
| arguments[key] = _coerce(value, key, properties) | |
| return {"name": name, "arguments": arguments} | |