Instructions to use botezx/flagtldr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Grok
How to use botezx/flagtldr with Grok:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download classifier/src/xaddons_classifier/spec.py from botezx/flagtldr: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/botezx/flagtldr/resolve/main/classifier/src/xaddons_classifier/spec.py
- Command line
-
hf download hf://botezx/flagtldr/classifier/src/xaddons_classifier/spec.py
-
curl -L -o spec.py https://huggingface.co/botezx/flagtldr/resolve/main/classifier/src/xaddons_classifier/spec.py
1.49 kB
| """Label-set format shared with the extension (see ../shared/labelset.example.json).""" | |
| from __future__ import annotations | |
| from typing import Literal | |
| from pydantic import BaseModel, Field, model_validator | |
| class Label(BaseModel): | |
| key: str | |
| rubric: str = "" | |
| color: str = "#1d9bf0" | |
| icon: str = "" | |
| action: Literal["mark", "collapse", "hide"] = "mark" | |
| class Example(BaseModel): | |
| text: str | |
| label: str | |
| class LabelSet(BaseModel): | |
| id: str = "custom" | |
| name: str = "" | |
| description: str = "" | |
| labels: list[Label] = Field(min_length=2) | |
| examples: list[Example] = [] | |
| none: bool = False | |
| threshold: float = 0.6 | |
| def _check(self) -> "LabelSet": | |
| keys = [l.key for l in self.labels] | |
| if len(set(keys)) != len(keys): | |
| raise ValueError("duplicate label keys") | |
| unknown = {e.label for e in self.examples} - set(keys) | |
| if unknown: | |
| raise ValueError(f"examples use unknown labels: {sorted(unknown)}") | |
| return self | |
| class Author(BaseModel): | |
| handle: str | None = None | |
| class Post(BaseModel): | |
| id: str | |
| text: str | |
| author: Author | None = None | |
| parent_text: str | None = None | |
| class Result(BaseModel): | |
| label: str | |
| probabilities: dict[str, float] | |
| confidence: float | |
| backend: str | |
| class ClassifyRequest(BaseModel): | |
| labelset: LabelSet | |
| posts: list[Post] | |
| class ClassifyResponse(BaseModel): | |
| results: dict[str, Result] | |