Text Generation
Transformers
English
qwen2
code-generation
python
fine-tuning
Qwen
tools
agent-framework
multi-agent
conversational
Eval Results (legacy)
Instructions to use my-ai-stack/Stack-2-9-finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use my-ai-stack/Stack-2-9-finetuned with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="my-ai-stack/Stack-2-9-finetuned") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("my-ai-stack/Stack-2-9-finetuned") model = AutoModelForCausalLM.from_pretrained("my-ai-stack/Stack-2-9-finetuned") 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
- vLLM
How to use my-ai-stack/Stack-2-9-finetuned with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "my-ai-stack/Stack-2-9-finetuned" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/my-ai-stack/Stack-2-9-finetuned
- SGLang
How to use my-ai-stack/Stack-2-9-finetuned 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 "my-ai-stack/Stack-2-9-finetuned" \ --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": "my-ai-stack/Stack-2-9-finetuned", "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 "my-ai-stack/Stack-2-9-finetuned" \ --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": "my-ai-stack/Stack-2-9-finetuned", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use my-ai-stack/Stack-2-9-finetuned with Docker Model Runner:
docker model run hf.co/my-ai-stack/Stack-2-9-finetuned
walidsobhie-code
feat: Add remaining RTMP tools (FileRead, FileWrite, Sleep, AskQuestion, Brief, TaskGet, TeamDelete, MCPTool, Worktree, SyntheticOutput)
5dc5419 | """WorktreeTool - Git worktree management for Stack 2.9""" | |
| import json | |
| import subprocess | |
| from datetime import datetime | |
| from pathlib import Path | |
| from typing import Any, Dict, Optional | |
| from .base import BaseTool, ToolResult | |
| from .registry import tool_registry | |
| WORKTREES_FILE = Path.home() / ".stack-2.9" / "worktrees.json" | |
| def _load_worktrees() -> Dict[str, Any]: | |
| """Load worktree state.""" | |
| WORKTREES_FILE.parent.mkdir(parents=True, exist_ok=True) | |
| if WORKTREES_FILE.exists(): | |
| return json.loads(WORKTREES_FILE.read_text()) | |
| return {"worktrees": []} | |
| def _save_worktrees(data: Dict[str, Any]) -> None: | |
| """Save worktree state.""" | |
| WORKTREES_FILE.write_text(json.dumps(data, indent=2)) | |
| def _run_git(args: list) -> tuple: | |
| """Run git command.""" | |
| try: | |
| result = subprocess.run( | |
| ["git"] + args, | |
| capture_output=True, | |
| text=True, | |
| timeout=30 | |
| ) | |
| return result.stdout, result.stderr, result.returncode | |
| except Exception as e: | |
| return "", str(e), 1 | |
| class EnterWorktreeTool(BaseTool): | |
| """Enter a git worktree.""" | |
| name = "enter_worktree" | |
| description = "Enter or create a git worktree" | |
| input_schema = { | |
| "type": "object", | |
| "properties": { | |
| "worktree_path": {"type": "string", "description": "Path for the worktree"}, | |
| "branch": {"type": "string", "description": "Branch name (optional, will use current if not specified)"}, | |
| "create": {"type": "boolean", "default": False, "description": "Create worktree if it doesn't exist"} | |
| }, | |
| "required": ["worktree_path"] | |
| } | |
| async def execute(self, worktree_path: str, branch: Optional[str] = None, create: bool = False) -> ToolResult: | |
| """Enter worktree.""" | |
| wt = Path(worktree_path) | |
| if wt.exists() and create: | |
| return ToolResult(success=False, error=f"Worktree path exists and create=true: {worktree_path}") | |
| data = _load_worktrees() | |
| # Check if worktree already registered | |
| for existing in data.get("worktrees", []): | |
| if existing.get("path") == worktree_path: | |
| return ToolResult(success=True, data={ | |
| "worktree_id": existing.get("id"), | |
| "path": worktree_path, | |
| "branch": existing.get("branch"), | |
| "status": "already_registered" | |
| }) | |
| # Create worktree if requested | |
| if create: | |
| if not branch: | |
| # Get current branch | |
| stdout, _, code = _run_git(["branch", "--show-current"]) | |
| branch = stdout.strip() or "main" | |
| stdout, stderr, code = _run_git(["worktree", "add", worktree_path, branch]) | |
| if code != 0: | |
| return ToolResult(success=False, error=f"Failed to create worktree: {stderr}") | |
| # Register worktree | |
| wt_id = f"wt_{len(data.get('worktrees', [])) + 1}" | |
| worktree_entry = { | |
| "id": wt_id, | |
| "path": worktree_path, | |
| "branch": branch, | |
| "created_at": datetime.now().isoformat(), | |
| "status": "active" | |
| } | |
| data.setdefault("worktrees", []).append(worktree_entry) | |
| _save_worktrees(data) | |
| return ToolResult(success=True, data={ | |
| "worktree_id": wt_id, | |
| "path": worktree_path, | |
| "branch": branch, | |
| "status": "entered" | |
| }) | |
| class ExitWorktreeTool(BaseTool): | |
| """Exit a git worktree.""" | |
| name = "exit_worktree" | |
| description = "Exit and optionally remove a worktree" | |
| input_schema = { | |
| "type": "object", | |
| "properties": { | |
| "worktree_id": {"type": "string", "description": "Worktree ID to exit"}, | |
| "cleanup": {"type": "boolean", "default": False, "description": "Remove the worktree directory"} | |
| }, | |
| "required": ["worktree_id"] | |
| } | |
| async def execute(self, worktree_id: str, cleanup: bool = False) -> ToolResult: | |
| """Exit worktree.""" | |
| data = _load_worktrees() | |
| worktree = None | |
| for wt in data.get("worktrees", []): | |
| if wt.get("id") == worktree_id: | |
| worktree = wt | |
| break | |
| if not worktree: | |
| return ToolResult(success=False, error=f"Worktree {worktree_id} not found") | |
| if cleanup: | |
| stdout, stderr, code = _run_git(["worktree", "remove", worktree["path"]]) | |
| if code != 0: | |
| return ToolResult(success=False, error=f"Failed to remove worktree: {stderr}") | |
| # Archive and remove from registry | |
| archive_dir = Path.home() / ".stack-2.9" / "archives" | |
| archive_dir.mkdir(parents=True, exist_ok=True) | |
| archive_file = archive_dir / f"worktree_{worktree_id}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.json" | |
| archive_file.write_text(json.dumps(worktree, indent=2)) | |
| data["worktrees"] = [w for w in data["worktrees"] if w.get("id") != worktree_id] | |
| _save_worktrees(data) | |
| return ToolResult(success=True, data={ | |
| "worktree_id": worktree_id, | |
| "path": worktree.get("path"), | |
| "status": "exited", | |
| "cleaned_up": cleanup, | |
| "archived_to": str(archive_file) if cleanup else None | |
| }) | |
| class ListWorktreesTool(BaseTool): | |
| """List all registered worktrees.""" | |
| name = "list_worktrees" | |
| description = "List all git worktrees" | |
| input_schema = { | |
| "type": "object", | |
| "properties": {}, | |
| "required": [] | |
| } | |
| async def execute(self) -> ToolResult: | |
| """List worktrees.""" | |
| data = _load_worktrees() | |
| return ToolResult(success=True, data={ | |
| "worktrees": data.get("worktrees", []), | |
| "count": len(data.get("worktrees", [])) | |
| }) | |
| # Register tools | |
| tool_registry.register(EnterWorktreeTool()) | |
| tool_registry.register(ExitWorktreeTool()) | |
| tool_registry.register(ListWorktreesTool()) | |