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
| """ | |
| GraphQL Client Tool - Gửi GraphQL query/mutation tới một endpoint. | |
| Author: Hieu Louis (2026) | |
| Dùng stdlib urllib (fallback) hoặc requests nếu có. Hỗ trợ variables + headers. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from typing import Any, Dict, Optional | |
| from .base import Tool, ToolResult, ToolContext, ToolCategory, ToolSafety | |
| class GraphQLClientTool(Tool): | |
| """Gửi GraphQL query/mutation tới một endpoint HTTP.""" | |
| category = ToolCategory.WEB # theo spec: category=WEB | |
| safety = ToolSafety.MODERATE # network call nhưng query GraphQL | |
| requires_confirmation = False | |
| def name(self) -> str: | |
| return "graphql_client" | |
| def description(self) -> str: | |
| return ( | |
| "Gửi GraphQL query hoặc mutation tới một endpoint. Hỗ trợ variables, " | |
| "headers (auth), timeout. Trả về JSON response." | |
| ) | |
| def parameters(self) -> Dict[str, Any]: | |
| return { | |
| "type": "object", | |
| "properties": { | |
| "endpoint": {"type": "string", "description": "GraphQL endpoint URL (https://...)"}, | |
| "query": {"type": "string", "description": "GraphQL query/mutation string"}, | |
| "variables": {"type": "object", "description": "Biến cho GraphQL operation"}, | |
| "operation_name": {"type": "string", "description": "Tên operation (nếu nhiều op trong query)"}, | |
| "headers": {"type": "object", "description": "HTTP headers (Authorization, Content-Type, ...)"}, | |
| "method": {"type": "string", "enum": ["POST", "GET"], "description": "HTTP method (default POST)"}, | |
| "timeout": {"type": "integer", "description": "Request timeout (s)"}, | |
| }, | |
| "required": ["endpoint", "query"], | |
| } | |
| def validate_args(self, args: Dict[str, Any]) -> Optional[str]: | |
| if not args.get("endpoint"): | |
| return "Missing required arg: endpoint" | |
| if not args.get("query"): | |
| return "Missing required arg: query" | |
| if not str(args["endpoint"]).startswith(("http://", "https://")): | |
| return "endpoint phải là URL http(s)://" | |
| return None | |
| def execute(self, args: Dict[str, Any], context: ToolContext) -> ToolResult: | |
| endpoint: str = args["endpoint"] | |
| query: str = args["query"] | |
| variables = args.get("variables") or {} | |
| operation_name = args.get("operation_name") | |
| headers: Dict[str, str] = args.get("headers") or {} | |
| method = str(args.get("method") or "POST").upper() | |
| timeout = int(args.get("timeout") or context.timeout or 30) | |
| # Dry-run // dry-run | |
| if context.dry_run: | |
| return ToolResult( | |
| success=True, | |
| output=f"[dry-run] Would send {method} GraphQL to {endpoint}", | |
| metadata={"dry_run": True, "endpoint": endpoint, "method": method, "operation_name": operation_name}, | |
| ) | |
| payload = { | |
| "query": query, | |
| "variables": variables, | |
| } | |
| if operation_name: | |
| payload["operationName"] = operation_name | |
| # Ưu tiên requests (nếu có), fallback urllib // prefer requests, fallback urllib | |
| try: | |
| import requests # type: ignore | |
| use_requests = True | |
| except ImportError: | |
| use_requests = False | |
| try: | |
| if use_requests: | |
| # POST application/json (chuẩn GraphQL) // standard JSON POST | |
| if method == "POST": | |
| resp = requests.post( # type: ignore[union-attr] | |
| endpoint, | |
| json=payload, | |
| headers=headers, | |
| timeout=timeout, | |
| ) | |
| else: | |
| # GET với query string // GET with querystring | |
| import urllib.parse as up | |
| qs = up.urlencode({"query": query, "variables": json.dumps(variables)}) | |
| resp = requests.get( # type: ignore[union-attr] | |
| f"{endpoint}?{qs}", | |
| headers=headers, | |
| timeout=timeout, | |
| ) | |
| status = resp.status_code | |
| try: | |
| body = resp.json() | |
| except Exception: | |
| body = {"raw": resp.text} | |
| else: | |
| # Fallback urllib // urllib fallback | |
| import urllib.request as ur | |
| import urllib.parse as up | |
| if method == "POST": | |
| data = json.dumps(payload).encode("utf-8") | |
| req_headers = dict(headers) | |
| req_headers.setdefault("Content-Type", "application/json") | |
| req = ur.Request(endpoint, data=data, headers=req_headers, method="POST") | |
| else: | |
| qs = up.urlencode({"query": query, "variables": json.dumps(variables)}) | |
| req = ur.Request(f"{endpoint}?{qs}", headers=headers, method="GET") | |
| with ur.urlopen(req, timeout=timeout) as r: # noqa: S310 | |
| status = r.status | |
| raw = r.read().decode("utf-8", errors="replace") | |
| try: | |
| body = json.loads(raw) | |
| except Exception: | |
| body = {"raw": raw} | |
| # GraphQL trả về 200 ngay cả khi có errors // GraphQL may have errors | |
| has_errors = isinstance(body, dict) and bool(body.get("errors")) | |
| return ToolResult( | |
| success=(200 <= status < 300) and not has_errors, | |
| output=json.dumps(body, ensure_ascii=False, indent=2), | |
| error=(json.dumps(body.get("errors"), ensure_ascii=False, indent=2) if has_errors else None), | |
| return_code=status, | |
| metadata={ | |
| "endpoint": endpoint, | |
| "method": method, | |
| "status_code": status, | |
| "has_errors": has_errors, | |
| "operation_name": operation_name, | |
| }, | |
| ) | |
| except Exception as e: | |
| return ToolResult(success=False, error=str(e), return_code=1) | |