Fix deprecation warning of sre_parse for python 3.13 (#16247)

This commit is contained in:
Lianmin Zheng
2025-12-31 21:25:09 -08:00
committed by GitHub
parent b5af283b1c
commit e4c1e441af
5 changed files with 32 additions and 19 deletions

View File

@@ -14,9 +14,14 @@
"""Sampling parameters for text generation."""
import logging
import sre_parse
from typing import Any, Dict, List, Optional, Union
# sre_parse is deprecated in Python 3.11+, use re._parser instead
try:
import re._parser as sre_parse
except ImportError:
import sre_parse # Python < 3.11
_SAMPLING_EPS = 1e-6
TOP_K_ALL = 1 << 30