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
File size: 6,352 Bytes
eca5751 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | """
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
@property
def name(self) -> str:
return "graphql_client"
@property
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."
)
@property
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)
|