File size: 682 Bytes
db06ffa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""GPU model server configuration."""

from __future__ import annotations

from dataclasses import dataclass


@dataclass(slots=True)
class GPUModelConfig:
    backend: str = "transformers"
    provider: str = "huggingface_spaces"
    space_name: str = "zeroshotGPU"
    max_batch_size: int = 4

    @classmethod
    def from_config(cls, config: dict) -> "GPUModelConfig":
        gpu = config.get("gpu", {})
        return cls(
            backend=gpu.get("backend", "transformers"),
            provider=gpu.get("provider", "huggingface_spaces"),
            space_name=gpu.get("space_name", "zeroshotGPU"),
            max_batch_size=int(gpu.get("max_batch_size", 4)),
        )