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
| """ | |
| Tool Base Class - Nền tảng cho tất cả tools | |
| ============================================ | |
| Định nghĩa interface chung cho mọi tool trong Nexus Coder. | |
| """ | |
| from __future__ import annotations | |
| from abc import ABC, abstractmethod | |
| from dataclasses import dataclass, field | |
| from typing import Any, Dict, List, Optional | |
| from enum import Enum | |
| class ToolSafety(str, Enum): | |
| """Mức độ an toàn của tool.""" | |
| SAFE = "safe" # Read-only, no side effects | |
| MODERATE = "moderate" # Writes to local files | |
| DANGEROUS = "dangerous" # Executes commands, network ops | |
| DESTRUCTIVE = "destructive" # Can delete data, requires confirmation | |
| class ToolCategory(str, Enum): | |
| """Phân loại tools.""" | |
| FILE = "file" | |
| EXEC = "exec" | |
| WEB = "web" | |
| CODE = "code" | |
| MATH = "math" | |
| PARSER = "parser" | |
| SYSTEM = "system" | |
| NETWORK = "network" | |
| CRYPTO = "crypto" | |
| DATA = "data" | |
| # v0.3 NEW categories | |
| DATABASE = "database" | |
| DEVOPS = "devops" | |
| CLOUD = "cloud" | |
| ML = "ml" | |
| SECURITY = "security" | |
| CONVERT = "convert" | |
| GIT = "git" | |
| MONITOR = "monitor" | |
| BLOCKCHAIN = "blockchain" | |
| MEDIA = "media" | |
| class ToolContext: | |
| """Context cho tool execution. | |
| Attributes: | |
| working_dir: Thư mục làm việc | |
| timeout: Timeout seconds | |
| env: Environment variables | |
| sandbox: Có chạy trong sandbox không | |
| user_id: ID của user (cho audit) | |
| dry_run: Chỉ simulate, không thực sự chạy | |
| """ | |
| working_dir: str = "." | |
| timeout: int = 30 | |
| env: Dict[str, str] = field(default_factory=dict) | |
| sandbox: bool = True | |
| user_id: Optional[str] = None | |
| dry_run: bool = False | |
| class ToolResult: | |
| """Kết quả trả về từ tool. | |
| Attributes: | |
| success: Có thành công không | |
| output: Output text (stdout) | |
| error: Error output (stderr) | |
| return_code: Exit code (nếu có) | |
| artifacts: Files được tạo/sửa | |
| metadata: Extra metadata | |
| duration: Thời gian thực thi (seconds) | |
| """ | |
| success: bool = True | |
| output: str = "" | |
| error: Optional[str] = None | |
| return_code: int = 0 | |
| artifacts: List[str] = field(default_factory=list) | |
| metadata: Dict[str, Any] = field(default_factory=dict) | |
| duration: float = 0.0 | |
| class Tool(ABC): | |
| """Base class cho mọi tool trong Nexus Coder. | |
| Mỗi tool phải implement: | |
| - name: Tên định danh duy nhất | |
| - description: Mô tả ngắn | |
| - execute: Hàm chính thực thi tool | |
| - validate_args: Validate arguments trước khi chạy | |
| """ | |
| category: ToolCategory = ToolCategory.FILE | |
| safety: ToolSafety = ToolSafety.SAFE | |
| requires_confirmation: bool = False | |
| timeout: int = 30 | |
| def name(self) -> str: | |
| """Tên duy nhất của tool (snake_case).""" | |
| ... | |
| def description(self) -> str: | |
| """Mô tả ngắn gọn tool làm gì.""" | |
| ... | |
| def parameters(self) -> Dict[str, Any]: | |
| """JSON schema cho parameters.""" | |
| return {} | |
| def version(self) -> str: | |
| return "0.3.0" | |
| def author(self) -> str: | |
| return "Hieu Louis" | |
| def validate_args(self, args: Dict[str, Any]) -> Optional[str]: | |
| """Validate args. Trả về error message nếu invalid, None nếu OK.""" | |
| return None | |
| def execute(self, args: Dict[str, Any], context: ToolContext) -> ToolResult: | |
| """Thực thi tool với args và context.""" | |
| ... | |
| def __repr__(self) -> str: | |
| return f"<Tool {self.name} (safety={self.safety.value})>" | |