Text Generation
Transformers
Safetensors
qwen2
coder
code
agent
conversational
text-generation-inference
Instructions to use AdminReal/NexusCoder with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AdminReal/NexusCoder with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AdminReal/NexusCoder") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AdminReal/NexusCoder") model = AutoModelForCausalLM.from_pretrained("AdminReal/NexusCoder", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AdminReal/NexusCoder with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AdminReal/NexusCoder" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdminReal/NexusCoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AdminReal/NexusCoder
- SGLang
How to use AdminReal/NexusCoder with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "AdminReal/NexusCoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdminReal/NexusCoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "AdminReal/NexusCoder" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AdminReal/NexusCoder", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AdminReal/NexusCoder with Docker Model Runner:
docker model run hf.co/AdminReal/NexusCoder
| """ | |
| Code Runner Tool - Run code trong nhiều ngôn ngữ. | |
| Author: Hieu Louis (2026) | |
| Hỗ trợ: | |
| - python : python3 <file> | |
| - javascript : node <file> | |
| - go : go run <file> | |
| - rust : rustc -o <bin> <file> && <bin> | |
| - c : gcc -o <bin> <file> && <bin> | |
| - cpp : g++ -o <bin> <file> && <bin> | |
| Subprocess có timeout=context.timeout, capture stdout+stderr. | |
| DANGEROUS (executes arbitrary code), requires_confirmation. | |
| """ | |
| from __future__ import annotations | |
| import os | |
| import shlex | |
| import shutil | |
| import subprocess | |
| import tempfile | |
| from typing import Any, Dict, List, Optional | |
| from .base import Tool, ToolResult, ToolContext, ToolCategory, ToolSafety | |
| # Map language → interpreter/compiler command, file extension, mode | |
| LANGUAGE_RUNNERS: Dict[str, Dict[str, str]] = { | |
| "python": {"cmd": "python3", "ext": ".py", "mode": "interpret"}, | |
| "javascript": {"cmd": "node", "ext": ".js", "mode": "interpret"}, | |
| "go": {"cmd": "go", "ext": ".go", "mode": "interpret"}, # go run | |
| "rust": {"cmd": "rustc", "ext": ".rs", "mode": "compile_run"}, | |
| "c": {"cmd": "gcc", "ext": ".c", "mode": "compile_run"}, | |
| "cpp": {"cmd": "g++", "ext": ".cpp", "mode": "compile_run"}, | |
| } | |
| class CodeRunnerTool(Tool): | |
| """Run code Python/JS/Go/Rust/C/C++ trong subprocess sandbox.""" | |
| category = ToolCategory.EXEC | |
| safety = ToolSafety.DANGEROUS | |
| requires_confirmation = True | |
| def name(self) -> str: | |
| return "code_runner" | |
| def description(self) -> str: | |
| return ( | |
| "Run code trong nhiều ngôn ngữ (Python, JavaScript/node, Go, Rust, C, C++). " | |
| "Capture stdout+stderr. Có timeout. Subprocess sandbox." | |
| ) | |
| def parameters(self) -> Dict[str, Any]: | |
| return { | |
| "type": "object", | |
| "properties": { | |
| "code": {"type": "string", "description": "Source code để chạy"}, | |
| "language": { | |
| "type": "string", | |
| "enum": sorted(LANGUAGE_RUNNERS.keys()), | |
| "description": "Ngôn ngữ của code", | |
| }, | |
| "stdin": {"type": "string", "description": "Stdin input (optional)"}, | |
| }, | |
| "required": ["code", "language"], | |
| } | |
| def validate_args(self, args: Dict[str, Any]) -> Optional[str]: | |
| if not args.get("code"): | |
| return "Missing required arg: code" | |
| lang = args.get("language") | |
| if not lang: | |
| return "Missing required arg: language" | |
| if lang not in LANGUAGE_RUNNERS: | |
| return f"Unsupported language: {lang}. Chọn: {sorted(LANGUAGE_RUNNERS.keys())}" | |
| return None | |
| def execute(self, args: Dict[str, Any], context: ToolContext) -> ToolResult: | |
| code: str = args["code"] | |
| lang: str = args["language"] | |
| stdin_data: Optional[str] = args.get("stdin") | |
| if context.dry_run: | |
| return ToolResult( | |
| success=True, | |
| output=f"[dry-run] Sẽ chạy {lang} code ({len(code)} bytes)", | |
| metadata={"language": lang, "dry_run": True, "code_length": len(code)}, | |
| ) | |
| spec = LANGUAGE_RUNNERS[lang] | |
| cmd = spec["cmd"] | |
| if not shutil.which(cmd): | |
| return ToolResult( | |
| success=False, | |
| error=( | |
| f"Interpreter/Compiler '{cmd}' không tìm thấy trong PATH. " | |
| f"Cài đặt để chạy {lang}." | |
| ), | |
| return_code=127, | |
| metadata={"language": lang, "missing": cmd}, | |
| ) | |
| # Tạo temp dir + temp source file | |
| tmpdir = tempfile.mkdtemp(prefix="nexus_runner_") | |
| src_path = os.path.join(tmpdir, f"main{spec['ext']}") | |
| try: | |
| with open(src_path, "w", encoding="utf-8") as f: | |
| f.write(code) | |
| except Exception as e: | |
| return ToolResult(success=False, error=f"Write temp file lỗi: {e}", return_code=1) | |
| # Build command | |
| if spec["mode"] == "interpret": | |
| if lang == "go": | |
| full_cmd: List[str] = [cmd, "run", src_path] | |
| else: | |
| full_cmd = [cmd, src_path] | |
| cwd = tmpdir | |
| else: # compile_run | |
| binary = os.path.join(tmpdir, "main_bin") | |
| compile_cmd = [cmd, "-o", binary, src_path] | |
| # Step 1: compile | |
| try: | |
| cp_compile = subprocess.run( | |
| compile_cmd, | |
| capture_output=True, | |
| text=True, | |
| timeout=context.timeout, | |
| cwd=tmpdir, | |
| env={**os.environ, **context.env}, | |
| ) | |
| except subprocess.TimeoutExpired: | |
| return ToolResult( | |
| success=False, | |
| error=f"Compile timeout ({context.timeout}s)", | |
| return_code=124, | |
| metadata={"language": lang, "phase": "compile"}, | |
| ) | |
| except FileNotFoundError: | |
| return ToolResult(success=False, error=f"{cmd} not found", return_code=127) | |
| if cp_compile.returncode != 0: | |
| return ToolResult( | |
| success=False, | |
| output=cp_compile.stdout, | |
| error=cp_compile.stderr, | |
| return_code=cp_compile.returncode, | |
| metadata={"phase": "compile", "language": lang, "command": " ".join(compile_cmd)}, | |
| ) | |
| full_cmd = [binary] | |
| cwd = tmpdir | |
| # Step 2: run | |
| try: | |
| cp = subprocess.run( | |
| full_cmd, | |
| input=stdin_data, | |
| capture_output=True, | |
| text=True, | |
| timeout=context.timeout, | |
| cwd=cwd, | |
| env={**os.environ, **context.env}, | |
| ) | |
| except subprocess.TimeoutExpired: | |
| return ToolResult( | |
| success=False, | |
| error=f"Runtime timeout ({context.timeout}s)", | |
| return_code=124, | |
| metadata={"language": lang, "phase": "run", "command": " ".join(full_cmd)}, | |
| ) | |
| except FileNotFoundError: | |
| return ToolResult(success=False, error=f"{full_cmd[0]} not found", return_code=127) | |
| return ToolResult( | |
| success=(cp.returncode == 0), | |
| output=cp.stdout, | |
| error=cp.stderr if cp.stderr else None, | |
| return_code=cp.returncode, | |
| metadata={ | |
| "language": lang, | |
| "command": " ".join(full_cmd), | |
| "phase": "run", | |
| "timeout": context.timeout, | |
| }, | |
| ) | |