Download backend/models/base.py from vynor/stt4: direct link, hf CLI and curl.
- Browser
- Download file 2.39 kB
-
https://huggingface.co/spaces/vynor/stt4/resolve/main/backend/models/base.py
- Command line
-
hf download hf://spaces/vynor/stt4/backend/models/base.py
-
curl -L -o base.py https://huggingface.co/spaces/vynor/stt4/resolve/main/backend/models/base.py
2.39 kB
| from abc import ABC, abstractmethod | |
| from dataclasses import dataclass, field | |
| from typing import Any, AsyncIterator, Dict, List, Optional | |
| class ModelMetadata: | |
| id: str | |
| name: str | |
| provider: str # "qorin" | "ollama" | |
| generation: str # "16M" | "50M" | "100M" | "500M" | "external" | |
| parameters: int | |
| context_length: int | |
| architecture: str | |
| status: str # "ready" | "loading" | "unloaded" | "training_in_progress" | "unavailable" | |
| checkpoint_path: Optional[str] = None | |
| tokenizer_path: Optional[str] = None | |
| supported_params: List[str] = field(default_factory=lambda: [ | |
| "temperature", "top_p", "top_k", "max_new_tokens", "repetition_penalty", "system_prompt" | |
| ]) | |
| description: str = "" | |
| is_native: bool = True | |
| vram_estimate_mb: int = 0 | |
| class GenerationConfig: | |
| temperature: float = 0.6 | |
| top_p: float = 0.9 | |
| top_k: int = 50 | |
| max_new_tokens: int = 200 | |
| repetition_penalty: float = 1.15 | |
| system_prompt: Optional[str] = None | |
| stop_sequences: List[str] = field(default_factory=lambda: ["<|im_end|>", "<|endoftext|>"]) | |
| class StreamChunk: | |
| text: str | |
| is_finished: bool = False | |
| finish_reason: Optional[str] = None | |
| token_count: int = 0 | |
| ttft_ms: Optional[float] = None | |
| elapsed_ms: Optional[float] = None | |
| tok_per_sec: Optional[float] = None | |
| class ModelProvider(ABC): | |
| def list_models(self) -> List[ModelMetadata]: | |
| """List all discoverable models under this provider.""" | |
| pass | |
| def load_model(self, model_id: str, device: Optional[str] = None) -> bool: | |
| """Load the model into memory/VRAM.""" | |
| pass | |
| def unload_model(self, model_id: str) -> bool: | |
| """Unload the model and reclaim memory.""" | |
| pass | |
| def is_loaded(self, model_id: str) -> bool: | |
| """Check whether the model is currently active.""" | |
| pass | |
| async def generate_stream( | |
| self, | |
| model_id: str, | |
| messages: List[Dict[str, str]], | |
| config: GenerationConfig, | |
| ) -> AsyncIterator[StreamChunk]: | |
| """Stream generation tokens.""" | |
| pass | |
| def get_runtime_status(self) -> Dict[str, Any]: | |
| """Return runtime health, active memory, and device stats.""" | |
| pass | |