Skip to content

A programming framework for agentic AI

isinstance(x, int) -> isinstance(x, (int, np.integer)) (#627)

Xueqing Liu6cb6a2a19a5a
diff --git a/flaml/nlp/utils.py b/flaml/nlp/utils.py
index 5f0d1464e..7e6d13b14 100644
--- a/flaml/nlp/utils.py
+++ b/flaml/nlp/utils.py
@@ -562,7 +562,7 @@ class LabelEncoderforTokenClassification:
# if the labels are not tokens, they must be ids
else:
assert all(
- isinstance(id, int) for id in y[0]
+ isinstance(id, (int, np.integer)) for id in y[0]
), "The labels must either be tokens or ids"
return y