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
Download nexus/tools/elasticsearch_tool.py from AdminReal/NexusCoder: direct link, hf CLI and curl.
- Browser
- Download file 7.58 kB
-
https://huggingface.co/AdminReal/NexusCoder/resolve/main/nexus/tools/elasticsearch_tool.py
- Command line
-
hf download hf://AdminReal/NexusCoder/nexus/tools/elasticsearch_tool.py
-
curl -L -o elasticsearch_tool.py https://huggingface.co/AdminReal/NexusCoder/resolve/main/nexus/tools/elasticsearch_tool.py
7.58 kB
| """ | |
| Elasticsearch Tool - Quản lý Elasticsearch qua elasticsearch-py. | |
| Author: Hieu Louis (2026) | |
| Operations: search, index, create, update, delete, bulk. | |
| """ | |
| from __future__ import annotations | |
| import json | |
| from datetime import datetime, date | |
| from typing import Any, Dict, List, Optional | |
| from .base import Tool, ToolResult, ToolContext, ToolCategory, ToolSafety | |
| # Write/delete ops (cần confirmation) // write ops | |
| WRITE_OPS = {"index", "create", "update", "delete", "bulk"} | |
| def _json_default(o: Any) -> Any: | |
| if isinstance(o, (datetime, date)): | |
| return o.isoformat() | |
| if isinstance(o, bytes): | |
| try: | |
| return o.decode("utf-8") | |
| except Exception: | |
| return o.hex() | |
| return str(o) | |
| class ElasticsearchTool(Tool): | |
| """Quản lý Elasticsearch: search, index, create, update, delete, bulk.""" | |
| category = ToolCategory.DATABASE | |
| safety = ToolSafety.DANGEROUS | |
| requires_confirmation = True | |
| def name(self) -> str: | |
| return "elasticsearch" | |
| def description(self) -> str: | |
| return ( | |
| "Quản lý Elasticsearch qua elasticsearch-py: search, index, create, " | |
| "update, delete, bulk. Hỗ trợ auth header và cloud_id." | |
| ) | |
| def parameters(self) -> Dict[str, Any]: | |
| return { | |
| "type": "object", | |
| "properties": { | |
| "hosts": { | |
| "oneOf": [{"type": "string"}, {"type": "array", "items": {"type": "string"}}], | |
| "description": "ES host(s), vd: http://localhost:9200", | |
| }, | |
| "api_key": {"type": "string", "description": "API key (optional)"}, | |
| "operation": { | |
| "type": "string", | |
| "enum": ["search", "index", "create", "update", "delete", "bulk"], | |
| "description": "ES operation", | |
| }, | |
| "index": {"type": "string", "description": "Tên ES index"}, | |
| "id": {"type": "string", "description": "Document ID (create/update/delete)"}, | |
| "body": {"type": "object", "description": "Document body hoặc query DSL"}, | |
| "query": {"type": "object", "description": "Query DSL (search)"}, | |
| "doc": {"type": "object", "description": "Partial doc (update)"}, | |
| "actions": {"type": "array", "items": {"type": "object"}, "description": "Bulk actions (vd: [{index:{_id:1}}, {doc:..}])"}, | |
| "size": {"type": "integer", "description": "Số kết quả trả về (default 50)"}, | |
| }, | |
| "required": ["hosts", "operation"], | |
| } | |
| def validate_args(self, args: Dict[str, Any]) -> Optional[str]: | |
| if not args.get("hosts"): | |
| return "Missing required arg: hosts" | |
| op = args.get("operation") | |
| if not op: | |
| return "Missing required arg: operation" | |
| if op in {"search", "index", "create", "update", "delete"} and not args.get("index"): | |
| return f"Operation '{op}' requires 'index' arg" | |
| if op in {"create", "update", "delete"} and not args.get("id"): | |
| return f"Operation '{op}' requires 'id' arg" | |
| if op == "search" and not (args.get("query") or args.get("body")): | |
| return "Operation 'search' requires 'query' or 'body' arg" | |
| if op == "bulk" and not args.get("actions"): | |
| return "Operation 'bulk' requires 'actions' arg" | |
| return None | |
| def execute(self, args: Dict[str, Any], context: ToolContext) -> ToolResult: | |
| hosts = args["hosts"] | |
| api_key = args.get("api_key") | |
| op: str = args["operation"] | |
| # Lazy import elasticsearch // lazy import | |
| try: | |
| from elasticsearch import Elasticsearch # type: ignore | |
| except ImportError as e: | |
| return ToolResult( | |
| success=False, | |
| error=f"elasticsearch not installed: {e}. Cài: pip install elasticsearch", | |
| return_code=127, | |
| ) | |
| # Dry-run cho write ops // dry-run | |
| if context.dry_run and op in WRITE_OPS: | |
| return ToolResult( | |
| success=True, | |
| output=f"[dry-run] Would run {op} on index={args.get('index')!r}", | |
| metadata={"dry_run": True, "operation": op, "index": args.get("index")}, | |
| ) | |
| try: | |
| client = Elasticsearch(hosts, api_key=api_key, request_timeout=context.timeout) | |
| if op == "search": | |
| body = args.get("body") or {"query": args["query"]} | |
| body.setdefault("size", int(args.get("size") or 50)) | |
| resp = client.search(index=args["index"], body=body) | |
| hits = resp.get("hits", {}).get("hits", []) | |
| payload = json.dumps(resp, default=_json_default, ensure_ascii=False, indent=2) | |
| return ToolResult(success=True, output=payload, metadata={"hits": len(hits), "took": resp.get("took")}) | |
| if op == "index": | |
| resp = client.index(index=args["index"], id=args.get("id"), document=args["body"]) | |
| return ToolResult( | |
| success=resp.get("result") in {"created", "updated"}, | |
| output=json.dumps(resp, default=_json_default, ensure_ascii=False, indent=2), | |
| metadata={"result": resp.get("result"), "id": resp.get("_id")}, | |
| ) | |
| if op == "create": | |
| resp = client.create(index=args["index"], id=args["id"], document=args["body"]) | |
| return ToolResult( | |
| success=resp.get("result") == "created", | |
| output=json.dumps(resp, default=_json_default, ensure_ascii=False, indent=2), | |
| metadata={"result": resp.get("result"), "id": resp.get("_id")}, | |
| ) | |
| if op == "update": | |
| resp = client.update(index=args["index"], id=args["id"], doc=args.get("doc") or args.get("body")) | |
| return ToolResult( | |
| success=resp.get("result") == "updated", | |
| output=json.dumps(resp, default=_json_default, ensure_ascii=False, indent=2), | |
| metadata={"result": resp.get("result")}, | |
| ) | |
| if op == "delete": | |
| resp = client.delete(index=args["index"], id=args["id"]) | |
| return ToolResult( | |
| success=resp.get("result") == "deleted", | |
| output=json.dumps(resp, default=_json_default, ensure_ascii=False, indent=2), | |
| metadata={"result": resp.get("result")}, | |
| ) | |
| if op == "bulk": | |
| # actions là list các cặp action_header/doc // actions list | |
| body_lines: List[str] = [] | |
| for item in args["actions"]: | |
| body_lines.append(json.dumps(item, default=_json_default)) | |
| body = "\n".join(body_lines) + "\n" | |
| resp = client.bulk(index=args.get("index"), body=body) | |
| errors = bool(resp.get("errors")) | |
| return ToolResult( | |
| success=not errors, | |
| output=json.dumps(resp, default=_json_default, ensure_ascii=False, indent=2), | |
| metadata={"errors": errors, "took": resp.get("took")}, | |
| ) | |
| return ToolResult(success=False, error=f"Unknown operation: {op}", return_code=1) | |
| except Exception as e: | |
| return ToolResult(success=False, error=str(e), return_code=1) | |