Parse n_threads Combo value to integer or None. Args: value: String from Combo input ("All", "Auto", or integer string) Returns: int for "All" or specific count, None for "Auto"
(value: str)
| 28 | |
| 29 | |
| 30 | def parse_n_threads(value: str) -> int | None: |
| 31 | """ |
| 32 | Parse n_threads Combo value to integer or None. |
| 33 | |
| 34 | Args: |
| 35 | value: String from Combo input ("All", "Auto", or integer string) |
| 36 | |
| 37 | Returns: |
| 38 | int for "All" or specific count, None for "Auto" |
| 39 | """ |
| 40 | if value == "All": |
| 41 | try: |
| 42 | if psutil is not None: |
| 43 | return psutil.cpu_count(logical=True) |
| 44 | else: |
| 45 | import multiprocessing |
| 46 | |
| 47 | return multiprocessing.cpu_count() |
| 48 | except Exception: |
| 49 | return 32 |
| 50 | elif value == "Auto": |
| 51 | return None |
| 52 | else: |
| 53 | try: |
| 54 | return int(value) |
| 55 | except (ValueError, TypeError): |
| 56 | return None |
| 57 | |
| 58 | |
| 59 | def check_llm_lazy_status( |